Motivation

Three problems come up as soon as cores share memory:

Issue Question it answers
Cache coherence If several caches hold copies of the same block, how do they all see the latest value?
Synchronization How do threads get controlled, atomic access to shared data?
Memory consistency In what order do memory operations to different addresses become visible to other cores?

Two ways to implement coherence:

Flynn’s taxonomy

Single data stream Multiple data streams
Single instruction stream SISD: an ordinary uniprocessor SIMD: one instruction on many data elements (vector units, GPUs, SSE/AVX)
Multiple instruction streams MISD: rare (redundant systems, systolic arrays) MIMD: multiprocessors, each core runs its own instruction stream. This unit’s focus.

Thread-level parallelism and shared memory

The running example: an ATM withdrawal.

Why caches break correctness

Two $100 withdrawals hit the same account, which starts at $500, on two processors.