













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of dependence analysis, a crucial concept in parallel computing. It covers various types of dependences, including flow, anti, and output, and their impact on parallelism. The document also introduces techniques for testing data dependences, such as gcd, banerjee, and omega tests. Additionally, it discusses the importance of understanding dependence in loops and array parallelism.
Typology: Slides
1 / 21
This page cannot be seen from the preview
Don't miss anything!














Michael OāBoyleFebruary, 2012
M. OāBoyle
Dependence Analysis
1
Course Structure
5 lectures on high level restructuring for parallelism and memory
-^
Dependence Analysis
-^
Program Transformation
-^
Automatic vectorisation
-^
Automatic parallelisation
-^
Speculative parallelisation
-^
Then adaptive compilation M. OāBoyle
Dependence Analysis
3
References
R. Allen and K Kennedy Optimizing compilers for modern architectures:
dependence based approach Morgan Kaufmann 2001. Main reference for thissection of lecture notes
-^
Michael Wolfe High Performance Compilers for Parallel Computing Addison-Wesley 1996.
-^
H. Zima and B. Chapman. Supercompilers for Parallel and Vector Computers.ACM Press Frontier Series 1990
-^
Today : The Omega Test: a fast and practical integer programming algorithmfor dependence analysis Supercomputing 1992 M. OāBoyle
Dependence Analysis
February, 2012
4
Programming Parallel Computers
Two extremes: User specifies parallelism and mapping
-^
Compiler parallelises and maps ādusty deckā sequential codes- Debatable how far this can go
-^
A popular approach is to break the transformation process into stages
-^
Transform
to
maximise
parallelism
i.e
minimise
critical
path
of
program
execution graph
-^
Map
parallelism
so
as
to
minimise
āsignificantā
machine
costs
i.e.
communication/ non-local access etc. M. OāBoyle
Dependence Analysis
February, 2012
6
Loop Parallelism / Array Parallelism
Original loop
Parallel loop
Do i = 1 , n
a(i) = b(i) EndDo
Doall i = 1 , n
a(i) = b(i) EndDo
All iterations of the iterator
i
can be performed independently
Independence implies Parallelism
-^
We will concentrate on loop parallelism O(n) potential parallelism. Statementand Operation - O(1).
-^
Recursive
parallelism
is
rich
but
very
dynamic.
Exploited
in
functional
computational models M. OāBoyle
Dependence Analysis
February, 2012
7
Parallelism and Data Dependence
Do i = 1,
a(i) = b(i) + c(i) EndDo
1
2
3
10
Do i = 2,
a(i) = a(i-1)
EndDo
1
2
3
10
Completely parallel each iteration is totally independentCompletely serial each iteration depends on the previous iterationNote: iterations NOT array elements M. OāBoyle
Dependence Analysis
9
Data Dependence
In general we need to know if two usages of an array access the same memorylocation and what type of dependence
-^
Helpful as this can be done relatively cheaply for simple programs
-^
General dependence is intractable - equivalent to Hilbertās tenth problem a (f
(i
a
(g
(i
for arbitrary
f
g
Decidable (NP) if
f, g
linear
M. OāBoyle
Dependence Analysis
10
Dependence in loops
Do i =1,N a(f(i)) =
= a(g(i))
EndDo^ ā¢
Conditions for flow dependence from iteration
w
to
r
w
r^
f
Iw
g
)r
Conditions for anti dependence from iteration
r^
to
w
r^
w
g
) =r
f
Iw
Conditions for output dependence from iteration
w
1
to
w
2
w
1
w
2
f
w
f
w
M. OāBoyle
Dependence Analysis
12
Dependence distance and direction: (approx) summarising dependence Do i =1,N
Do j = 1,M
a(i,j) = a(i-1,j+1) + EndDo EndDo^ ā¢
Flow dependence
Dependence
Iw
w
Ir
) :r
r^
w
r^
w
Distance vector is [1,-1].
Direction vector [+,-] or [
] sign of direction.
Any: [*], 0 [=],Positive [
], Negative [
First non zero vector element cannot be negative - why? M. OāBoyle
Dependence Analysis
13
Hiearchical Computing of Dependence Directions in loops.
Do i =1,N a(f(i)) =
= a(g(i))
EndDo^ ā¢
Test for any dependence from iteration
w
to
:r
w
r^
f
Iw
g
)r
Use this test to test any direction[*].
-^
If solutions add additional constraints:
direction: add
w
,r
add
w
.r
Extend for multi loops,
then
etc - hierarchical testing
M. OāBoyle
Dependence Analysis
15
Separable SIV test
Do i =1,N Do j= 1,N Do k = 1,N
x(aI+b,..,..) = x(cI+d,..,..)
EndDo^ ā¢
If equations for one iterator appear in only one subscript, we can separate itand solve independently. ⢠a
w
b
c
r^
d
Strong SIV,
a
c
, so
r^
w
b^
d
)/a
If a divides b-d and result is in range of I, then we have the dependencedistance. Weak SIV : a or c =0. M. OāBoyle
Dependence Analysis
16
General SIV test or Greatest Common Divisor
Do i =1,N Do j= 1,N Do k = 1,N
x(aI+b,..,..) = x(cI+d,..,..)
EndDo^ ā¢
We have
a
w
b
c
r^
d
If gcd(a,c) does not divide d-b no solution try a=c=2, d=1,b=
-^
ELSE ... potentially many solutions. M. OāBoyle
Dependence Analysis
18
Example using flow constraint
Do i =1,
a(2*i+3) = a(i+7)
-^
We have
Iw
r^
, h
Iw
r^
and
w
r^
Min h = (21 -100 -4) = -102, Max h = (2100-1-4)=195 195
hence solution
Simple example can be extended. Technical difficulties with complex iterationspaces
-^
Performed sub-script at a time, Used for MIV M. OāBoyle
Dependence Analysis
19
Omega Test - Read the paper!
Most compilers still use classification and special tests for dependence
-^
However
Pughās
Omega
Test
can
solve
exactly
using
integer
linear
programming.
-^
Basically state constraints and put into a smart Fourier-Motzkin eliminationbased solver
-^
Shown that worst case double exponential cost on manipulating Presburgherformula is frequently low-end polynomial M. OāBoyle
Dependence Analysis
February, 2012