Docsity

Memory Consistency in Computer Architecture: Sync & Ordering in Multiprocessors, Lecture notes of Architecture

Partial preview of the text

Download Memory Consistency in Computer Architecture: Sync & Ordering in Multiprocessors and more Lecture notes Architecture in PDF only on Docsity!

740: Computer Architecture

Memory Consistency

Prof. Onur Mutlu Carnegie Mellon University

Readings: Memory Consistency

 Required

 Lamport, “How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs,” IEEE Transactions on Computers, 1979

 Recommended

 Gharachorloo et al., “Memory Consistency and Event Ordering in Scalable Shared-Memory Multiprocessors,” ISCA 1990.  Charachorloo et al., “Two Techniques to Enhance the Performance of Memory Consistency Models,” ICPP 1991.  Ceze et al., “BulkSC: bulk enforcement of sequential consistency,” ISCA 2007.

Review: Multiprocessor Types

 Loosely coupled multiprocessors

 No shared global memory address space  Multicomputer network  Network-based multiprocessors  Usually programmed via message passing  Explicit calls (send, receive) for communication

 Tightly coupled multiprocessors

 Shared global memory address space  Traditional multiprocessing: symmetric multiprocessing (SMP)  Existing multi-core processors, multithreaded processors  Programming model similar to uniprocessors (i.e., multitasking uniprocessor) except  Operations on shared data require synchronization

Review: Main Issues in Tightly-Coupled MP

 Shared memory synchronization

 Locks, atomic operations

 Cache consistency

 More commonly called cache coherence

 Ordering of memory operations

 What should the programmer expect the hardware to provide?

 Resource sharing, contention, partitioning

 Communication: Interconnection networks

 Load imbalance

Bottlenecks in Parallel Portion

 Synchronization: Operations manipulating shared data cannot be parallelized  Locks, mutual exclusion, barrier synchronization  Communication: Tasks may need values from each other

  • Causes thread serialization when shared data is contended

 Load Imbalance: Parallel tasks may have different lengths

 Due to imperfect parallelization or microarchitectural effects

  • Reduces speedup in parallel portion

 Resource Contention: Parallel tasks can share hardware resources, delaying each other  Replicating all resources (e.g., memory) expensive

  • Additional latency not present when each task runs alone

Difficulty in Parallel Programming

 Little difficulty if parallelism is natural

 “Embarrassingly parallel” applications  Multimedia, physical simulation, graphics  Large web servers, databases?

 Difficulty is in

 Getting parallel programs to work correctly  Optimizing performance in the presence of bottlenecks

 Much of parallel computer architecture is about

 Designing machines that overcome the sequential and parallel bottlenecks to achieve higher performance and efficiency  Making programmer’s job easier in writing correct and high- performance parallel programs

Ordering of Operations

 Operations: A, B, C, D

 In what order should the hardware execute (and report the results of) these operations?

 A contract between programmer and microarchitect

 Specified by the ISA

 Preserving an “expected” (more accurately, “agreed upon”) order simplifies programmer’s life  Ease of debugging; ease of state recovery, exception handling

 Preserving an “expected” order usually makes the hardware designer’s life difficult  Especially if the goal is to design a high performance processor: Load-store queues in out of order execution

Memory Ordering in a Single Processor

 Specified by the von Neumann model

 Sequential order

 Hardware executes the load and store operations in the order specified by the sequential program

 Out-of-order execution does not change the semantics

 Hardware retires (reports to software the results of) the load and store operations in the order specified by the sequential program

 Advantages: 1) Architectural state is precise within an execution. 2) Architectural state is consistent across different runs of the program  Easier to debug programs

 Disadvantage: Preserving order adds overhead, reduces performance

Memory Ordering in a MIMD Processor

 Each processor’s memory operations are in sequential order with respect to the “thread” running on that processor (assume each processor obeys the von Neumann model)

 Multiple processors execute memory operations concurrently

 How does the memory see the order of operations from all processors?  In other words, what is the ordering of operations across different processors?

Why Does This Even Matter?

 Ease of debugging

 It is nice to have the same execution done at different times have the same order of memory operations

 Correctness

 Can we have incorrect execution if the order of memory operations is different from the point of view of different processors?

 Performance and overhead

 Enforcing a strict “sequential ordering” can make life harder for the hardware designer in implementing performance enhancement techniques (e.g., OoO execution, caches)

Supporting Mutual Exclusion

 Programmer needs to make sure mutual exclusion (synchronization) is correctly implemented  We will assume this  But, correct parallel programming is an important topic  Reading: Dijkstra, “Cooperating Sequential Processes,” 1965.  http://www.cs.utexas.edu/users/EWD/transcriptions/EWD01xx/EWD 123.html  See Dekker’s algorithm for mutual exclusion

 Programmer relies on hardware primitives to support correct synchronization

 If hardware primitives are not correct (or unpredictable), programmer’s life is tough

 If hardware primitives are correct but not easy to reason about or use, programmer’s life is still tough

Protecting Shared Data

Assume P1 is in critical section. Intuitively, it must have executed A, which means F1 must be 1 (as A happens before B), which means P2 should not enter the critical section.

Both Processors in Critical Section