Week 01 Lec 2 - 05!03!2024 (Types of Parallelism)
Week 01 Lec 2 - 05!03!2024 (Types of Parallelism)
and Distributed
Computing
Lecture # 02
Spring 2021
Agenda
2
Karp-Flatt Metric
Types of Parallelism
Data-parallelism
Functional-parallelism
Pipelining
Multi-processor vs Multi-computer
Derivation
Let’s suppose you have a sequential code for a
problem that can be executed in total T(s)time.
T(p) be the parallel time for the same algorithm
over p processors.
Then speedup can be calculated using:-
CS443
Amdahl’s Law
5
Derivation
Again
CS443
Amdahl’s Law
6
CS443
Amdahl’s Law
7
CS443
Karp-Flatt Metric
9
CS443
10
Types of Parallelism
CS443
Types of Parallelism
11
1. Data-parallelism
When there are independent sub-tasks applying
the same operation to different elements of a
data set
When just distributing the data provides sufficient
parallelism
Example code
for i=0 to 99 do
a[ i ] = b[ i ] + c [ i ]
Endfor
Here same operation (i.e., addition) is being performed on
first 100 elements of ‘b’ and ‘c’
All 100 iterations of the loop could be executed
CS443
simultaneously.
Types of Parallelism
12
2. Functional-parallelism
When there are independent tasks applying
different operations to different data elements
Example code
1) a=2
2) b=3
3) m= (a+b)/2
4) s= ( + )/2
5) v= s -
Here (1, 2) and (3, 4) statements could be
performed concurrently.
CS443
Types of Parallelism
13
3. Pipelining
Usually used for the problems where single
instance of the problem can not be parallelized
The output of one stage is input of the other stage
Divide whole computation of each instance into
multiple stages (if there are multiple instances of
the problem)
An effective method of attaining parallelism
(concurrency) on the uniprocessor architectures
Also depends on pipelining abilities of the
processor
CS443
Types of
Parallelism
3. Pipelining
Example:
Assembly line
analogy
Sequential Execution
14 CS443
Types of
Parallelism
3. Pipelining
Example:
Assembly line
analogy
Pipelining
15 CS443
Types of
Parallelism
3. Pipelining
Example:
Overlap
instructions in
a single
instruction
cycle to
achieve
parallelism 4-stage Pipelining
16 CS443
Questions
2
6
CS443