Professional Documents
Culture Documents
Part 3
Analysis of Algorithms - Big-O Notation
Let f,g:ℕ→ℝ, g(n)>0, for all large enough n values.
Lower- and upper bound should take into account the computation model, the
number of processors, the architecture.
Analysis of Parallel Algorithms - Running Time
● The most important criteria
● The time elapsed from the start of the algorithm until it finishes.
● If the processors do not start at the same time, it is the time elapsed since the
first processor start until the last one finishes.
● For MIMD it is the only method to evaluate an algorithm
Analysis of Parallel Algorithms - Running Time
● Usually the estimation is based on counting the number of basic operations
(additions, comparisons, swaps). What a “basic operation” is depends on the
architecture.
● Number of operations on average or in the worst case scenario.
● For SIMD or MIMD: computation steps and communication steps.
● In the parallel architecture, the running time depends also on the number of
processors. If the number of processors depends on n, we can write it as t(n).
If it is constant, it does not change the result in big-O notation.
● t(n) is the number of steps in the worst case scenario.
● Speedup = tseq/tpar
Analysis of Parallel Algorithms - Processors & Cost
● Noted p(n), where n is the size of the problem
● Importance:
○ Acquisition cost
○ Maintenance cost
○ Architecture constraints
● In some cases it does not depend on n
● The cost of the algorithm c(n) = t(n)*p(n)
● Efficiency efficiency = tseq(n)/c(n)
● A parallel algorithm has an optimal cost if its cost is of the same order with
an optimal sequential algorithm.
Analysis of Parallel Algorithms - Example 1
Problem: Search a value in a file with n records using N processors on EREW
SIMD.
D is the location holding the searched value but EREW means exclusive read.
We use an array A of length (N+1)/2 to hold the values to broadcast.
The number of configured processors doubles at every step, therefore the algorithm’s order is O(log N).
Analysis of Parallel Algorithms - Example 1 (N=8, D=5)
D 5 A
Step 1
5 P
D 5 5 A
Step 2, i = 0
5 5 P
D 5 5 5 5 A
Step 2, i = 1
5 5 5 5 P
D 5 5 5 5 5 5 5 5 A
Step 2, i = 2
5 5 5 5 5 5 5 5 P
Analysis of Parallel Algorithms - Example 1
t(n) = log N + n/N = O(n/N)
tseq = O(n)
Efficiency = tseq/c(n) = 1