Chapter 6 Parallel and Concurrent Computing
Chapter 6 Parallel and Concurrent Computing
Topics in Computer
Science
Chapter 5 Parallel and
Concurrent Systems
1
Some Definitions
6
How to View a SIMD
Machine
Think of soldiers all in a unit.
The commander selects certain
soldiers as active – for example, the
first row.
The commander barks out an order
to all the active soldiers, who execute
the order synchronously.
The remaining soldiers do not
execute orders until they are re-
activated.
7
MIMD
Multiple instruction, multiple data
Processors are asynchronous, since they can
independently execute different programs
on different data sets.
Communications are handled either
through shared memory.
(multiprocessors)
byuse of message passing
(multicomputers)
MIMD’shave been considered by most
researchers to include the most powerful 8
9
MIMD (cont 3/4)
A more common technique for programming MIMDs is to
use multi-tasking:
The problem solution is broken up into various tasks.
Tasks are distributed among processors initially.
If new tasks are produced during executions, these may
handled by parent processor or distributed
Each processor can execute its collection of tasks
concurrently.
Ifsome of its tasks must wait for results from other tasks or new
data , the processor will focus the remaining tasks.
Larger programs usually run a load balancing algorithm in
the background that re-distributes the tasks assigned to
the processors during execution
Either dynamic load balancing or called at specific times
Dynamic scheduling algorithms may be needed to assign
a higher execution priority to time-critical tasks
E.g., on critical path, more important, earlier deadline, etc.
10
Multiprocessors
(Shared Memory MIMDs)
Allprocessors have access to all memory
locations .
Two types: UMA and NUMA
UMA (uniform memory access)
Frequently called symmetric multiprocessors or
SMPs
Similar to uniprocessor, except additional,
identical CPU’s are added to the bus.
Each processor has equal access to memory
and can do anything that any other processor
can do. 11
multiple processes.
Multiprocessors vs
Multicomputers
Programmingdisadvantages of
message-passing
Programmers must make explicit message-
passing calls in the code
This
is low-level programming and is error
prone.
Datais not shared between processors but
copied, which increases the total data size.
Dataintegrity problem: Difficulty to
maintain correctness of multiple copies of
data item.
14
Multiprocessors vs Multicomputers (cont)
16
Data Parallelism
All tasks (or processors) apply the same set of
operations to different data.
Example: for i 0 to 99 do
a[i] b[i] + c[i]
endfor
17
Data Parallelism Features
Each processor performs the same data
computation on different data sets
Computations can be performed either
synchronously or asynchronously
Defn: Grain Size is the average number of
computations performed between
communication or synchronization steps
18
Task/Functional/
Control/Job Parallelism
Independent tasks apply different operations to
different data elements
a2
b3
m (a + b) / 2
s (a2 + b2) / 2
v s - m2
20
Pipelining
Divide a process into stages
Produce several items simultaneously
21
Compute Partial Sums
Consider the for loop:
p[0] a[0]
for i 1 to 3 do
p[i] p[i-1] + a[i]
endfor
This computes the partial sums:
p[0] a[0]
p[1] a[0] + a[1]
p[2] a[0] + a[1] + a[2]
p[3] a[0] + a[1] + a[2] + a[3]
The loop is not data parallel as there are dependencies.
However, we can stage the calculations in order to
22