1. A method for maintaining coherence of memory lines in a shared memory multiprocessor system that includes a system area network and a plurality of compute nodes connected to said system area network, wherein each of said compute nodes includes a main memory, a shared cache, a coherence controller and a directory, said method comprising: maintaining, by each of said compute nodes, state information of said main memory cached in said shared caches of other compute nodes; organizing a cache directory so that the state information can be stored first in an area efficient directory format; switching to a sparse directory format if an entry is shared by more than one compute node; and dynamically switching between said area efficient directory format and said sparse directory format so as to maximize the number of entries stored in the directory.