Iterative Optimization in the Polyhedral Model: One-Dimensional Affine Schedules
Louis-Noël Pouchet, Cédric Bastoul and Albert Cohen
ALCHEMY, LRI - INRIA Futurs
October 17, 2006
2nd HiPEAC Industrial Workshop, Eindhoven, NL
Iterative Optimization in the Polyhedral Model: One-Dimensional - - PowerPoint PPT Presentation
Iterative Optimization in the Polyhedral Model: One-Dimensional Affine Schedules Louis-Nol Pouchet , Cdric Bastoul and Albert Cohen ALCHEMY, LRI - INRIA Futurs October 17, 2006 2nd HiPEAC Industrial Workshop, Eindhoven, NL Outline: 2nd
2nd HiPEAC Industrial Workshop, Eindhoven, NL
Outline: 2nd HiPEAC Industrial Workshop
2
Introduction: Motivation 2nd HiPEAC Industrial Workshop
3
Introduction: Motivation 2nd HiPEAC Industrial Workshop
3
Introduction: Motivation 2nd HiPEAC Industrial Workshop
3
Introduction: Motivation 2nd HiPEAC Industrial Workshop
3
Introduction: Motivation 2nd HiPEAC Industrial Workshop
4
Introduction: Motivation 2nd HiPEAC Industrial Workshop
4
Introduction: Motivation 2nd HiPEAC Industrial Workshop
4
Introduction: Motivation 2nd HiPEAC Industrial Workshop
4
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
5
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
5
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
5
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
5
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
do i = 1, 3 do j = 1, 3 A(i+j) = ...
1 1 2 2
i
3 3 4 5 6
j
j
1 2 3 1 2 3 2 3 4 5 6 1
j i t
do t = 2, 6 do i = max(1,t-3), min(t-1,3) A(t) = ... 6
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
do i = 1, 3 do j = 1, 3 A(i+j) = ...
1 1 2 2
i
3 3 4 5 6
j
j
1 2 3 1 2 3 2 3 4 5 6 1
j i t
do t = 2, 6 do i = max(1,t-3), min(t-1,3) A(t) = ... 6
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
do i = 1, 3 do j = 1, 3 A(i+j) = ...
1 1 2 2
i
3 3 4 5 6
j
j
1 2 3 1 2 3 2 3 4 5 6 1
j i t
do t = 2, 6 do i = max(1,t-3), min(t-1,3) A(t) = ... 6
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
do i = 1, 3 do j = 1, 3 A(i+j) = ...
1 1 2 2
i
3 3 4 5 6
j
j
1 2 3 1 2 3 2 3 4 5 6 1
j i t
do t = 2, 6 do i = max(1,t-3), min(t-1,3) A(t) = ... 6
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
7
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
7
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
7
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
8
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
8
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
8
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
xS
1
9
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
xS
1
9
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
xS
1
9
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
10
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
10
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
1 2 3 5 6 4
1 2 3 5 6 4
θR
j
j
1 1 i j
do j = 1, 3 a(i,j) = a(i,j) * 0.2 do i = 1, 2 do j = 1, 3 a(i,j) = a(i,j) * 0.2 11
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
1 2 3 5 6 4
1 2 3 4 5 6
θR
j
j i
1 1 i j
do j = 1, 3 a(i,j) = a(i,j) * 0.2 do j = 1, 3 do i = 1, 2 a(i,j) = a(i,j) * 0.2 12
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
13
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
13
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j)
14
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j)
14
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j)
14
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
15
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
15
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
15
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j) 16
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j)
Iterations of R
1 −1 −1 3 1 −1 −1 3 1 −1 −1 3 1 −1
iS jS n 1
16
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j)
Iterations of S Iterations of R
1 −1 −1 3 1 −1 −1 3 1 −1 −1 3 1 −1
iS jS n 1
16
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, 3 R s(i) = 0 do j = 1, 3 S s(i) = s(i) + a(i)(j) * x(j)
Iterations of R Iterations of S
1 −1 −1 3 1 −1 −1 3 1 −1 −1 3 1 −1
iS jS n 1
16
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
17
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
18
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
18
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
18
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, n R s(i) = 0 do j = 1, n S s(i) = s(i) + a(i,j) * x(j)
θR( xR) = t1R .iR + t2R .n + t3R .1 θS( xS) = t1S .iS + t2S .jS + t3S .n + t4S .1
1 −1 1 −1 1 1 −1 1 1 −1 1
iS jS n 1
19
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, n R s(i) = 0 do j = 1, n S s(i) = s(i) + a(i,j) * x(j)
θR( xR) = t1R .iR + t2R .n + t3R .1 θS( xS) = t1S .iS + t2S .jS + t3S .n + t4S .1 1
2
3
19
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, n R s(i) = 0 do j = 1, n S s(i) = s(i) + a(i,j) * x(j)
θR( xR) = t1R .iR + t2R .n + t3R .1 θS( xS) = t1S .iS + t2S .jS + t3S .n + t4S .1
DRδS iR : −t1R = λD1,1 − λD1,2 + λD1,7 iS : t1S = λD1,3 − λD1,4 − λD1,7 jS : t2S = λD1,5 − λD1,6 n : t3S − t2R = λD1,2 + λD1,4 + λD1,6 1 : t4S − t3R − 1 = λD1,0
19
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
do i = 1, n R s(i) = 0 do j = 1, n S s(i) = s(i) + a(i,j) * x(j)
θR( xR) = t1R .iR + t2R .n + t3R .1 θS( xS) = t1S .iS + t2S .jS + t3S .n + t4S .1
DRδS iR : −t1R = λD1,1 − λD1,2 + λD1,7 iS : t1S = λD1,3 − λD1,4 − λD1,7 jS : t2S = λD1,5 − λD1,6 n : t3S − t2R = λD1,2 + λD1,4 + λD1,6 1 : t4S − t3R − 1 = λD1,0
19
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
20
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
20
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
20
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
21
Experimental Results: 2nd HiPEAC Industrial Workshop
1
2
3
22
Experimental Results: 2nd HiPEAC Industrial Workshop
1
2
3
22
Experimental Results: Exhaustive Scan 2nd HiPEAC Industrial Workshop
6e+08 8e+08 1e+09 1.2e+09 1.4e+09 1.6e+09 1.8e+09 2e+09 2.2e+09 0 100 200 300 400 500 600 700 800 900 1000 Cycles (M)
matxmat Original 5e+08 1e+09 1.5e+09 2e+09 2.5e+09 3e+09 3.5e+09 4e+09 1000 2000 3000 4000 5000 6000 7000 Cycles (M)
locality Original 4e+08 5e+08 6e+08 7e+08 8e+08 9e+08 1e+09 1.1e+09 1.2e+09 1.3e+09 0 2000 4000 6000 8000 10000 12000 14000 16000 18000 Cycles (M)
matvecttransp Original 1.26e+09 1.28e+09 1.3e+09 1.32e+09 1.34e+09 1.36e+09 1.38e+09 1.4e+09 1.42e+09 100 200 300 400 500 600 700 800 Cycles (M)
crout Original
23
Experimental Results: Exhaustive Scan 2nd HiPEAC Industrial Workshop
1.26e+09 1.28e+09 1.3e+09 1.32e+09 1.34e+09 1.36e+09 1.38e+09 1.4e+09 1.42e+09 100 200 300 400 500 600 700 800 Cycles (M)
crout Original
1.26e+09 1.27e+09 1.28e+09 1.29e+09 1.3e+09 1.31e+09 1.32e+09 1.33e+09 1.34e+09 100 200 300 400 500 600 700 800 Cycles (M)
crout Original
24
Experimental Results: Exhaustive Scan 2nd HiPEAC Industrial Workshop
Benchmark Compiler Options Parameters ID best Speedup h264 PathCC
N=8 352 36.1% h264 GCC
N=8 234 13.3% h264 GCC
N=8 250 25.0% h264 ICC
N=8 290 12.9% h264 ICC
N=8 N/A 0% fir PathCC
N=150000 72 6.0% fir GCC
N=150000 192 15.2% fir GCC
N=150000 289 13.2% fir ICC
N=150000 242 18.4% fir ICC
N=150000 392 3.4% MVT PathCC
N=2000 4934 27.4% MVT GCC
N=2000 13301 18.0% MVT GCC
N=2000 13320 21.2% MVT ICC
N=2000 14093 24.0% MVT ICC
N=2000 4879 29.1% matmul PathCC
N=250 283 308.1% matmul GCC
N=250 573 243.6% matmul GCC
N=250 143 248.7% matmul ICC
N=250 311 356.6% matmul ICC
N=250 641 645.4% 25
Experimental Results: A Transformation Example 2nd HiPEAC Industrial Workshop
for (i = 0; i <= M; i++) { S1 x1[i] = 0; S2 x2[i] = 0; for (j = 0; j <= M; j++) { S3 x1[i] += a[i][j] * y1[j]; S4 x2[i] += a[j][i] * y2[j]; } } Compiler Option Original Best Schedule Speedup GCC 4.1.1
6.9 5.1 θS1( xS1) = −i − n − 1 θS2( xS2) = −1 θS1( xS1) = j + 1 θS2( xS2) = i + j + n + 1 35.3% ICC 9.0.1
6.1 4.9 θS1( xS1) = n − 1 θS2( xS2) = −n − 1 θS1( xS1) = j + n + 1 θS2( xS2) = j − n 24.5% PathCC 2.5
7.3 5.9 θS1( xS1) = −i − n − 1 θS2( xS2) = −i − n θS1( xS1) = −i + j + n + 1 θS2( xS2) = −i + j + 1 23.8% 26
Experimental Results: A Transformation Example 2nd HiPEAC Industrial Workshop
S1: x1[i] = 0 S2: x2[i] = 0 S3: x1[i] += a[i][j] * y1[j] S4: x2[i] += a[j][i] * y2[j] for (i = 0; i <= M; i++) { S1(i); S2(i); for (j = 0; j <= M; j++) { S3(i,j); S4(i,j); } } for (i = 0; i <= M; i++) S2(i); for (c1 = 1; c1 <= M-1; c1++) for (i = 0; i <= M; i++) { S4(i,c1-1); } for (i = 0; i <= M; i++) { S1(i); S4(i,M-1); } S3(0,0); S4(0,M); for (i = 1 ; i <= M; i++) S4(i,M); for (c1 = M+2; c1 <= 3*M+1; c1++) for (i = max(c1-2*M-1,0); i <= min(M,c1-M-1); i++) { S3(i,c1-i-M-1); } 27
Experimental Results: A Transformation Example 2nd HiPEAC Industrial Workshop
Benchmark #Schedules Heuristic. #Runs %Speedup locality 6561 Rand 125 96.1% DH 123 98.3% matmul 912 Rand 170 99.9% DH 170 99.8% mvt 16641 Rand 30 93.3% DH 31 99.0% 28
Conclusion: 2nd HiPEAC Industrial Workshop
29
Conclusion: 2nd HiPEAC Industrial Workshop
29
Conclusion: 2nd HiPEAC Industrial Workshop
29
Conclusion: 2nd HiPEAC Industrial Workshop
29
Conclusion: 2nd HiPEAC Industrial Workshop
29
Conclusion: 2nd HiPEAC Industrial Workshop
29
Conclusion: 2nd HiPEAC Industrial Workshop
29