Module 17: Loops
  Lecture 33: Data Dependence in Parallel Loops
 
Consider:
dopar i = 2, 20
X[i] = Y[i] + 1
Z[i] = X[i-1] + X[i] + X[i+1]
enddopar
I
S2
S3
2
3
4
X[2]=Y[2]+1
X[3]=Y[3]+1
X[4]=Y[4]+1
Z[2]=X[1]+X[2]+X[3]
Z[3]=X[2]+X[3]+X[4]
Z[4]=X[3]+X[4]+X[5]
  • Within each iteration
  • Across the iteration anti dependence from X[i] to X[i-1] and X[i+1]

Dosingle Loop

  • Single assignment rules excludes output dependence
  • There can not be anti dependence since each variable is defined only once
  • Any access conflict must resolve in favour of definition first followed by use, therefore, only flow dependencies
Consider:
dosingle i = 2, 20
X[i] = Y[i] + 1
Z[i] = X[i-1] + X[i] + X[i+1]
enddosingle
Def
Use
Dependence
Distance
X[i]
X[i-1]
X[i]
X[i+1]
flow
flow
flow

1
0
-1