120 likes | 280 Views
Parallel Programming models I. Parallel Machines: an abstract introduction. Our main focus will be on three kinds of machines Bus-based shared memory machines Scalable shared memory machines Cache coherent Hardware support for remote memory access Distributed memory machines.
E N D
Parallel Machines: an abstract introduction • Our main focus will be on three kinds of machines • Bus-based shared memory machines • Scalable shared memory machines • Cache coherent • Hardware support for remote memory access • Distributed memory machines
Bus based machines Mem0 Mem1 Memk PE0 PE1 PE N-1
Bus based machines • Any processor can access any memory location • Read and write • Bus bandwidth is a limiting factor • Also, how do you deal with 2 processors changing the same data? • Locks (more on this later)
Scalable shared memory m/cs PE0 PE0 PE0
Scalable shared memory m/cs PE0 PE0 PE0 Interconnection Network with support for remote memory access Mem0 Mem0 Mem0
Distributed memory m/cs PE0 PE0 PE0 Interconnection Network Mem0 Mem0 Mem0
Writing parallel programs • Programming model • How should a programmer view the parallel machine? • Sequential programming: von Neumann model • Parallel programming models: • Shared memory (Shared address space) model • Message passing model • Shared Objects model
Shared Address Space Model • All memory is accessible to all processes • Processes are mapped to processors, typically by a symmetric OS • Coordination among processes: • by sharing variables • Avoid “stepping on toes”: • using locks and barriers
Matrix multiplication for (i=0; i<M; i++) for (j=0; j<N; j++) for (k=0; k<N; k++) C[I][j] += A[i][k]*B[k][j]; In a shared memory style, this program is trivial to parallelize Just have each processor deal with a different range of I (or J?) (or Both?)