Multiprocessor Architecture
35 flashcards · Computer Science · by Athena Papkouf
Instruction-level parallelism
Multiple instructions executing concurrently on the same core Limited by control and data dependences
Task-level parallelism
Multiple threads of the same app executing concurrently on different cores, exploiting parallelism Limited by the algorithm and sync. overheads
Data-level parallelism
One instruction operating concurrently on different data Limited by irregular data access patterns & memory BW
Amdhal's law
Models of Communication for synchronisation
1.Shared address space 2.Message passing 3.Data parallel
Shared Address Space
Threads communicate by reading/writing to shared vars Shared variables are like a big bulletin board Any thread can read or write Communication is unstructured, implicit in loads and stores Arguably easier to program, but harder to scale
Non-uniform Memory Access (NUMA)
All processors can access any memory location, but... cost of memory access is different for different processors (more scalable) High bandwidth & low latency access to local memory BW scales with # of nodes if most accesses are local
Message Passing
Different address spaces Communicate explicitly via sending/receiving messages Synchronization is implicit in the messages Arguably harder to program, but easier to scale
Data Parallel
Structure computation as a big “map” over a collection Severely limits communication between iterations of the map (goal: preserve independent processing of iterations)
Single Writer, Multiple Reader (SWMR) Invariant
Either the last writer or any reader has a valid copy
MSI Protocol State Diagram
Total directory storage per L2 bank
# of L1 tags * bits/entry
reducing true sharing
Partition the data structures and merge later privatise results
reducing false sharing
move data in different cache blocks by padding
Loop unrolling
Perform multiple loop iterations in one Reduce loop overhead
Loop fusion
Combine two back-to-back loops with exactly the same iteration pattern to reduce loop overhead
Loop fission
Split a big loop into smaller loops to improve L1 data and instruction cache miss rate
Desirable Lock Characteristics (5)
◆ Low latency ◆ Processors should be able to acquire free locks quickly ◆ Low traffic ◆ Waiting for lock should generate little/no traffic ◆ A busy lock should be handed off between processors with as little traffic as possible ◆ Scalability ◆ Latency/traffic should scale reasonably with number of processors ◆ Low storage cost ◆ Fairness ◆ Avoid starvation or substantial unfairness ◆ Ideal: processors should acquire lock in order they request access
Simple TS Lock Performance Characteristics (5)
◆ Low latency (under low contention) ◆ High coherence traffic ◆ Poor scaling ◆ Low storage cost (one int) ◆ No provisions for fairness
TTS Lock Performance Characteristics
◆ Slightly higher latency than TS in uncontended case ◆ Generates much less interconnect traffic ◆ More scalable (due to less traffic) ◆ Storage cost unchanged (one int) ◆ Still no provisions for fairness
TS w/ Exp. Back-off Characteristics
◆ Same uncontended latency as TS ◆ Generates less traffic than TS ◆ Improves scalability (due to less traffic) ◆ Storage cost unchanged ◆ Exponential back-off can cause severe unfairness ◆ Newer requesters back off for shorter intervals
Busy Waiting
threads spinning while waiting
Blocking Synchronization
◆ Preempt the running thread (suspend) ◆ OS schedules another thread to run ◆ The other thread can run and make progress preferable if: Scheduling overhead is larger than expected wait time Scheduling overhead is in the order of microseconds While a few spinning iterations is in the order of nanoseconds Processor’s resources not needed for other tasks
Coarse-grained Locking
◆ Simple implementation ◆ Lots of contention ◆ No concurrency inside the data structure
Fine-grained Locking
◆ Contention for objects only ◆ Lots of concurrency exposed Limited only to updating and reading each object Cannot actually modify the hash table structure
Speculative Address Tracking
◆ Scaling the ”link register” idea to memory ◆ Don’t let instructions retire, all addresses stay in LSQ ◆ Keep speculative addresses in the LSQ ◆ Check for conflicts in the critical section ◆ Other corner cases to roll back ◆ If multiple rollbacks, retry with the lock!
Benefits of HLE (hardware lock elision)
◆ Conservative Locking Easier to show correctness than fine grained locking Our code locks more often than necessary (Why?) ◆ Locking Granularity Tradeoff between Performance and Complexity ◆ Thread-unsafe legacy libraries Require global locking
When does lock elision fail?
◆ Atomicity violation Detected by coherence protocol Restart from “ts LCK” ◆ Resource constraints Critical section bigger than ROB LD/ST in critical section conflict in cache ◆ Interrupts
issues with locks
◆ Priority inversion Higher priority threads waiting for a lock held by a lower-priority thread ◆ Convoying Threads holding locks and are de-scheduled ◆ Deadlocks/livelocks Locking in a different order across threads, is deadlock Threads constantly looping to get locks, is livelock
Transactional Memory (TM)
◆ Memory (not disk) transactions An atomic & isolated sequence of memory accesses Supported in hardware by processor & cache hierarchy ◆ Atomicity Upon commit, all memory writes take effect at once On abort, none of the writes take effect ◆ Isolation No other processor can observe writes before commit ◆ Serializability Transactions seem to commit in a single serial order The exact order is not guaranteed
horizontal waste
unable to use full issue width Software not exposing enough ILP for hardware
Vertical waste
whole cycle empty, nothing issued Most common after long latency events
(Coarse Grain) Multithreading
Switch to a new thread on a long latency event Pay a small cost to switch in a new context Addresses purely vertical waste May increase utilization But, required to swap on long latency events Advantage: small changes to existing hardware Drawback: single-thread performance suffers
Fine Grained Multithreading
Cycle between multiple threads periodically Advantages: With flexible interleave: Reasonable single thread performance and High processor utilization (esp. in case of many thread) Without: Suits “regular” applications with repetitive latencies Drawbacks: More complicated hardware to track dependences Many more contexts means we need many registers Without flex. interleaving, limited single thread perf.
Simultaneous Multithreading (SMT)
Instructions from multiple threads in same cycle