Arch13 Multiprocessors Afterlecture
Arch13 Multiprocessors Afterlecture
n Recommended
q Mike Flynn, “Very High-Speed Computing Systems,” Proc. of IEEE,
1966
q Hill, Jouppi, Sohi, “Multiprocessors and Multicomputers,” pp. 551-
560 in Readings in Computer Architecture.
q Hill, Jouppi, Sohi, “Dataflow and Multithreading,” pp. 309-314 in
Readings in Computer Architecture.
2
Memory Consistency
n Required
q Lamport, “How to Make a Multiprocessor Computer That Correctly
Executes Multiprocess Programs,” IEEE Transactions on Computers,
1979
3
Readings: Cache Coherence
n Required
q Papamarcos and Patel, “A low-overhead coherence solution
for multiprocessors with private cache memories,” ISCA 1984.
n Recommended:
q Culler and Singh, Parallel Computer Architecture
n Chapter 5.1 (pp 269 – 283), Chapter 5.3 (pp 291 – 305)
q P&H, Computer Organization and Design
n Chapter 5.8 (pp 534 – 538 in 4th and 4th revised eds.)
4
Multiprocessors and
Issues in Multiprocessing
Remember: Flynn’s Taxonomy of Computers
n Mike Flynn, “Very High-Speed Computing Systems,” Proc.
of IEEE, 1966
n Other Goals
q Reduce power consumption
n (4N units at freq F/4) consume less power than (N units at freq F)
n Why?
q Improve cost efficiency and scalability, reduce complexity
n Harder to design a single unit that performs as well as N simpler units
q Improve dependability: Redundant execution in space
7
Types of Parallelism and How to Exploit Them
n Instruction Level Parallelism
q Different instructions within a stream can be executed in parallel
q Pipelining, out-of-order execution, speculative execution, VLIW
q Dataflow
n Data Parallelism
q Different pieces of data can be operated on in parallel
q SIMD: Vector processing, array processing
q Systolic arrays, streaming processors
10
Multiprocessor Types
n Loosely coupled multiprocessors
q No shared global memory address space
q Multicomputer network
n Network-based multiprocessors
q Usually programmed via message passing
n Explicit calls (send, receive) for communication
n Cache coherence
q How to ensure correct operation in the presence of private
caches keeping the same memory address cached
n Communication: Interconnects
12
Main Programming Issues in Tightly-Coupled MP
n Load imbalance
q How to partition a single task into multiple tasks
n Synchronization
q How to synchronize (efficiently) between tasks
q How to communicate between tasks
q Locks, barriers, pipeline stages, condition variables,
semaphores, atomic operations, …
13
Aside: Hardware-based Multithreading
n Coarse grained
q Quantum based
q Event based (switch-on-event multithreading), e.g., switch on L3 miss
n Fine grained
q Cycle by cycle
q Thornton, “CDC 6600: Design of a Computer,” 1970.
q Burton Smith, “A pipelined, shared resource MIMD computer,” ICPP
1978.
n Simultaneous
q Can dispatch instructions from multiple threads at the same time
q Good for improving execution unit utilization
14
Lecture on Fine-Grained Multithreading
https://www.youtube.com/watch?v=6e5KZcCGBYw&list=PL5Q2soXY2Zi_uej3aY39YB5pfW4SJ7LlN&index=16 15
More on Multithreading (I)
https://www.youtube.com/onurmutlulectures 16
More on Multithreading (II)
https://www.youtube.com/onurmutlulectures 17
More on Multithreading (III)
https://www.youtube.com/onurmutlulectures 18
More on Multithreading (IV)
https://www.youtube.com/onurmutlulectures 19
Lectures on Multithreading
n Parallel Computer Architecture, Fall 2012, Lecture 9
q Multithreading I (CMU, Fall 2012)
q https://www.youtube.com/watch?v=iqi9wFqFiNU&list=PL5PHm2jkkXmgDN1PLwOY
_tGtUlynnyV6D&index=51
n Parallel Computer Architecture, Fall 2012, Lecture 10
q Multithreading II (CMU, Fall 2012)
q https://www.youtube.com/watch?v=e8lfl6MbILg&list=PL5PHm2jkkXmgDN1PLwOY_
tGtUlynnyV6D&index=52
n Parallel Computer Architecture, Fall 2012, Lecture 13
q Multithreading III (CMU, Fall 2012)
q https://www.youtube.com/watch?v=7vkDpZ1-
hHM&list=PL5PHm2jkkXmgDN1PLwOY_tGtUlynnyV6D&index=53
n Parallel Computer Architecture, Fall 2012, Lecture 15
q Speculation I (CMU, Fall 2012)
q https://www.youtube.com/watch?v=-
hbmzIDe0sA&list=PL5PHm2jkkXmgDN1PLwOY_tGtUlynnyV6D&index=54
https://www.youtube.com/onurmutlulectures 20
Limits of Parallel Speedup
21
Parallel Speedup Example
n a4x4 + a3x3 + a2x2 + a1x + a0
22
23
24
Speedup with 3 Processors
25
Revisiting the Single-Processor Algorithm
26
27
Superlinear Speedup
n Can speedup be greater than P with P processing
elements?
n Unfair comparisons
Compare best parallel
algorithm to wimpy serial
algorithm à unfair
n Cache/memory effects
More processors à
more cache or memory à
fewer misses in cache/mem
28
Utilization, Redundancy, Efficiency
n Traditional metrics
q Assume all P processors are tied up for parallel computation
n Efficiency
q E = (Time with 1 processor) / (processors x Time with P processors)
q E = U/R
29
Utilization of a Multiprocessor
30
31
Amdahl’s Law and
Caveats of Parallelism
32
Caveats of Parallelism (I)
33
Amdahl’s Law
35
Amdahl’s Law Implication 2
36
Caveats of Parallelism (II)
n Amdahl’s Law
q f: Parallelizable fraction of a program
q N: Number of processors
1
Speedup =
f
1-f + N
200
190
180
170
160
150
140
130
120
110 N=10
100
90 N=100
80 N=1000
70
60
50
40
30
20
10
0
0.04
0.08
0.12
0.16
0.24
0.28
0.32
0.36
0.44
0.48
0.52
0.56
0.64
0.68
0.72
0.76
0.84
0.88
0.92
0.96
0
1
0.2
0.4
0.6
38
Why the Sequential Bottleneck?
n Parallel machines have the
sequential bottleneck
39
Another Example of Sequential Bottleneck (I)
Suleman+, “Accelerating Critical Section Execution with Asymmetric Multi-Core Architectures,” ASPLOS 2009. 40
Another Example of Sequential Bottleneck (II)
Suleman+, “Accelerating Critical Section Execution with Asymmetric Multi-Core Architectures,” ASPLOS 2009. 41
Bottlenecks in Parallel Portion
n Synchronization: Operations manipulating shared data
cannot be parallelized
q Locks, mutual exclusion, barrier synchronization
q Communication: Tasks may need values from each other
Each thread:
loop {
Compute N
lock(A)
Update shared data
unlock(A) C
}
44
Remember: Barriers
n Synchronization point
n Threads have to wait until all threads reach the barrier
n Last thread arriving to the barrier is on the critical path
Each thread:
loop1 {
Compute
}
barrier
loop2 {
Compute
}
45
Remember: Stages of Pipelined Programs
n Loop iterations are statically divided into code segments called stages
n Threads execute stages on different cores
n Thread executing the slowest stage is on the critical path
A B C
loop {
Compute1 A
Compute2 B
Compute3 C
}
46
Difficulty in Parallel Programming
n Little difficulty if parallelism is natural
q “Embarrassingly parallel” applications
q Multimedia, physical simulation, graphics
q Large web servers, databases?
n Difficulty is in
q Getting parallel programs to work correctly
q Optimizing performance in the presence of bottlenecks
48
In Previous Two Lectures
n Lecture 17b: Parallelism and Heterogeneity
q https://www.youtube.com/watch?v=GLzG_rEDn9A&list=PL5Q
2soXY2Zi-Mnk1PxjEIG32HAGILkTOF&index=18
49
More on Accelerated Critical Sections
n M. Aater Suleman, Onur Mutlu, Moinuddin K. Qureshi, and Yale N. Patt,
"Accelerating Critical Section Execution with Asymmetric
Multi-Core Architectures"
Proceedings of the 14th International Conference on Architectural
Support for Programming Languages and Operating
Systems (ASPLOS), pages 253-264, Washington, DC, March
2009. Slides (ppt)
One of the 13 computer architecture papers of 2009 selected
as Top Picks by IEEE Micro.
50
More on Bottleneck Identification & Scheduling
n Jose A. Joao, M. Aater Suleman, Onur Mutlu, and Yale N. Patt,
"Bottleneck Identification and Scheduling in Multithreaded
Applications"
Proceedings of the 17th International Conference on Architectural
Support for Programming Languages and Operating
Systems (ASPLOS), London, UK, March 2012. Slides (ppt) (pdf)
51
More on Utility-Based Acceleration
n Jose A. Joao, M. Aater Suleman, Onur Mutlu, and Yale N. Patt,
"Utility-Based Acceleration of Multithreaded Applications
on Asymmetric CMPs"
Proceedings of the 40th International Symposium on Computer
Architecture (ISCA), Tel-Aviv, Israel, June 2013. Slides (ppt)
Slides (pdf)
52
More on Data Marshaling
n M. Aater Suleman, Onur Mutlu, Jose A. Joao, Khubaib, and Yale N. Patt,
"Data Marshaling for Multi-core Architectures"
Proceedings of the 37th International Symposium on Computer
Architecture (ISCA), pages 441-450, Saint-Malo, France, June
2010. Slides (ppt)
One of the 11 computer architecture papers of 2010 selected
as Top Picks by IEEE Micro.
53
Computer Architecture
Lecture 19a: Multiprocessors
56
Parallel Task Assignment: Tradeoffs
n Problem: N tasks, P processors, N>P. Do we assign tasks to
processors statically (fixed) or dynamically (adaptive)?
n Static assignment
+ Simpler: No movement of tasks.
- Inefficient: Underutilizes resources when load is not balanced
When can load not be balanced?
n Dynamic assignment
+ Efficient: Better utilizes processors when load is not balanced
- More complex: Need to move tasks to balance processor load
- Higher overhead: Task movement takes time, can disrupt
locality
57
Parallel Task Assignment: Example
n Compute histogram of a large set of values
n Parallelization:
q Divide the values across T tasks
q Each task computes a local histogram for its value set
q Local histograms merged with global histograms in the end
58
Parallel Task Assignment: Example (II)
n How to schedule tasks updating local histograms?
q Static: Assign equal number of tasks to each processor
q Dynamic: Assign tasks to a processor that is available
q When does static work as well as dynamic?
59
Software Task Queues
n What are the advantages and disadvantages of each?
q Centralized
q Distributed
q Hierarchical
60
Task Stealing
n Idea: When a processor’s task queue is empty it steals a
task from another processor’s task queue
q Whom to steal from? (Randomized stealing works well)
q How many tasks to steal?
61
Parallel Task Assignment: Tradeoffs
n Who does the assignment? Hardware versus software?
n Software
+ Better scope
- More time overhead
- Slow to adapt to dynamic events (e.g., a processor becoming
idle)
n Hardware
+ Low time overhead
+ Can adjust to dynamic events faster
- Requires hardware changes (area and possibly energy
overhead)
62
How Can the Hardware Help?
n Managing task queues in software has overhead
q Especially high when task sizes are small
63
Dynamic Task Generation
n Does static task assignment work in this case?
64
Programming Model vs.
Hardware Execution Model
Programming Models vs. Architectures
n Five major models
q (Sequential)
q Shared memory
q Message passing
q Data parallel (SIMD)
q Dataflow
q Systolic
n Hybrid models?
66
Shared Memory vs. Message Passing
n Are these programming models or execution models
supported by the hardware architecture?
67
Programming Models: Message Passing vs. Shared Memory
n Difference: how communication is achieved between tasks
n Message passing programming model
q Explicit communication via messages
q Loose coupling of program components
q Analogy: telephone call or letter, no shared location accessible to
all
n Shared memory programming model
q Implicit communication via memory operations (load/store)
q Tight coupling of program components
q Analogy: bulletin board, post information at a shared space
70