









































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
Loop parallelization techniques, focusing on eliminating dependences and performing data dependence tests. It covers concepts such as iteration space graphs, distance vectors, and loop-carried dependences. The document also mentions various tests like the gcd test, banerjee test, omega test, and range test for detecting dependences.
Typology: Study notes
1 / 49
This page cannot be seen from the preview
Don't miss anything!










































1
2
Do i = 1, n a(i) = b(i) S 1 c(i) = a(i-1) S 2 End do Is it legal to
4
Do i = 1, n a(i) = b(i) S 1 c(i) = a(i-1) S 2 End do i = 1 b(1) a(1) a(0) c(1) i = 2 b(2) a(2) a(1) c(2) i = 3 b(3) a(3) a(2) c(3) i = 4 b(4) a(4) a(3) c(4) i = 5 b(5) a(5) a(4) c(5) i = 6 b(6) a(6) a(5) c(6) Assume 1 iteration per processor, then if for some reason some iterations execute out of lock-step, bad things can happen In this case, read of a(2) in i=3 will get an invalid value! time
5
Do i = 1, n a(i) = b(i) S 1 c(i) = a(i-1) S 2 End do Do i = 1, n c(i) = a(i-1) S 2 a(i) = b(i) S 1 End do
No problem with a serial execution.
Access order before statement reordering i=1 i=2 i=3 i= i=1 i=2 i=3 i= Access order after statement reordering
7
… = a(2) a(2) = … Anti-dependence – write to a location cannot occur before a previous read is finished Let the program in be: a(2) = … … = a(2) a(2) = … = … a(2) Create additional storage to eliminate the anti- dependence The new program is: a(2) = … … = a(2) aa(2) = … = … aa(2) No more anti-dependence!
8
a(2) = … a(2) = … Output dependence – write a location must wait for a previous write to finish Let the program be: a(2) = … … = a(2) a(2) = … … = a(2) Again, by creating new storage we can eliminate the output dependence. The new program is: a(2) = … … = a(2) aa(2) = … … = aa(2)
10
Do i = 1, n a(3i-1) = … a(2i) = … = … a(i) End do A(3i) writes locations 2, 5, 8, 11, 14, 17, 20, 23 A(2i) writes locations 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 A(i) reads from outside the of loop when i = 1, 3, 7, 9, 13, 15, 19, 21 A(i) reads from a(3i-1) when I = 5, 11, 17, 23 A(i) reads from a(2i) when I = 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22
11
Do i = 1, n a(i) = b(i) S 1 End do Do i c(i) = a(i-1) S 2 End do Do i = 1, n a(i) = b(i) S 1 c(i) = a(i-1) S 2 End do In original execution of the unfused loops :
13
for (i=1; i < nl i++) { a[i] = … … = a[i-1] } a[1] = = a[0] a[2] = = a[1] a[3] = = a[2] a[4] = = a[3]
14 Data Dependence Tests: Concepts Terms for data dependences between statements of loop iterations.
16 Data Dependence Tests: Distance Vectors Distance (vector): indicates how many iterations apart are the source and sink of dependence. i 2 = 1 i 2 = 3 i 2 = 2
i 2 = 5 i 1 = 1 2 3 4 5 6
do i 1 = 1, n do i 2 = 1, n a(i 1 ,i 2 ) = a(i 1 -2,i 2 +3) end do end do
17 Data Dependence Tests: Direction Vectors Direction (vector): is basically the sign of the distance. There are different notations: (<,=,>) or (-1,0,+1) meaning dependence (from earlier to later, within the same, from later to earlier) iteration. do i 1 = 1, n do i 2 = 1, n a(i 1 ,i 2 ) = a(i 1 -2,i 2 +3) end do end do i 1 = 1 2 3 4 5 6 I=(1,4) I’ = (3,1) I’ – I = d = (2,-3) Direction = (<,>) (or (sign(2),sign(-3) == (+1,-1) in some works I 2 = 1 i 2 = 3 i 2 = 2
i 2 = 5
19 Data Dependence Tests: Loop Carried
Lower bound 20
A loop do i = 4 , n, 3 a(i) end do Can be always be normalized to the loop do i = 0, (n-1)/ 3 -1, 1 a( 3 i+ 4 ) end do This makes discussing the data-dependence problem easier since we only worry about loops from 0, n, 1 More precisely, do i = lower, upper, stride { a(i)} becomes do i’ = 0, (upper – lower + incre)/stride – 1, 1 {a(i’stride + lower)} Stride Upper bound