Shared Memory Consistency Conditions for Nonsequential Execution: Definitions and Programming Strategies

Hagit Attiya, Soma Chaudhuri, Roy Friedman, and Jennifer L. Welch

To enhance performance on shared memory multiprocessors, various techniques have been proposed to reduce the latency of memory accesses, including pipelining of accesses, out-of-order execution of accesses, and branch prediction with speculative execution. These optimizations can, however, complicate the user's model of memory. This paper attacks the problem of simplifying programming on two fronts.

First, a general framework is presented for defining shared memory consistency conditions that allows non-sequential execution of memory accesses. The interface at which conditions are defined is between the program and the system, and is architecture-independent. The framework is used to generalize three consistency conditions -- sequential consistency, hybrid consistency, and weak consistency -- for non-sequential execution. Thus familiar consistency conditions can be precisely specified even in optimized architectures.

Second, several techniques are described for structuring programs so that a shared memory that provides the weaker (and more efficient) condition of hybrid consistency appears to guarantee the stronger (and more costly) condition of sequential consistency. The benefit is that sequentially consistent executions are easier to reason about. The first technique statically classifies accesses based on their type. This approach is extremely simple to use and leads to a general methodology for writing efficient synchronization code. The second technique is to avoid data races in the program, which was previously studied in a somewhat different setting.

Prcise, yet short and comprehensible, proofs are provided for the correctness of the programming techniques. Such proofs shed light on the reasons these technqiues work; we believe that the insight gained can lead to the development of other techniques.