ECE 468
Problem Set 8: Dependence analysis
1. Consider the following code:
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
A[i][j] = A[i  1][j + 1] + A[i + 1][j + 1];
}
}
(a) Draw the iteration space graph for this loop nest. Use solid arrows for ﬂow
dependences, dashed arrows for antidependences and dotted arrows for output
dependences.
Answer:
0
1
2
3
4
5
0
1
2
3
4
5
(b) Give the distance and direction vectors for each type of dependence.
Answer:
Flow: (1
,

1) or (+
,

). Anti: (1
,
1) or (+
,
+)
(c) Can we perform loop interchange on this loop? Why or why not?
Answer:
No, we cannot. The ﬂow dependence would turn into an anti de
pendence if we performed loop interchange.
2. Consider the following code:
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Documentfor (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
A[j][i] = A[j  1][i  1] + B[i][j];
A[j+1][i] = B[i + 1][j  1];
}
}
(a) Give the distance and direction vectors for the dependences in this loop. Indi
cate which array the dependences are on.
Answer:
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 TEST
 Vector Motors, Locality of reference, Rowmajor order, Inplace matrix transposition

Click to edit the document details