Iterative Optimization in the Polyhedral Model: One...
Transcript of Iterative Optimization in the Polyhedral Model: One...
![Page 1: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/1.jpg)
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
![Page 2: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/2.jpg)
Outline: 2nd HiPEAC Industrial Workshop
1 IntroductionMotivationThe Polyhedral ModelPolyhedral Representation of programs
2 Iterative Optimization in the Polyhedral ModelOne-Dimensional SchedulesLegal Scheduling Space
3 Experimental ResultsExhaustive ScanA Transformation Example
4 Conclusion
2
![Page 3: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/3.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Iterative Optimization
Instead of predicting profitability of a transformation,perform it and run the programMost of the time, adresses parameters tuning or phaseselection
Alternatively, some works replace the heuristic itself byiterative search
→ We focus on Loop Nest Optimization
3
![Page 4: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/4.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Iterative Optimization
Instead of predicting profitability of a transformation,perform it and run the programMost of the time, adresses parameters tuning or phaseselection
Alternatively, some works replace the heuristic itself byiterative search
→ We focus on Loop Nest Optimization
3
![Page 5: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/5.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Iterative Optimization
Instead of predicting profitability of a transformation,perform it and run the programMost of the time, adresses parameters tuning or phaseselection
Alternatively, some works replace the heuristic itself byiterative search
→ We focus on Loop Nest Optimization
3
![Page 6: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/6.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Iterative Optimization
Instead of predicting profitability of a transformation,perform it and run the programMost of the time, adresses parameters tuning or phaseselection
Alternatively, some works replace the heuristic itself byiterative search
→ We focus on Loop Nest Optimization
3
![Page 7: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/7.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Drawbacks
Limitations:The set of combinations of transformations is huge!Only a subset of them respects the program semantics
→ Only a (very small) subset of transformation sequences isactually tested
→ The search space is either too restrictive, or too large dueto the postponed legality check
⇒ Can we improve the search space construction: model allsequences of transformations, and model only legal ones?
4
![Page 8: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/8.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Drawbacks
Limitations:The set of combinations of transformations is huge!Only a subset of them respects the program semantics
→ Only a (very small) subset of transformation sequences isactually tested
→ The search space is either too restrictive, or too large dueto the postponed legality check
⇒ Can we improve the search space construction: model allsequences of transformations, and model only legal ones?
4
![Page 9: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/9.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Drawbacks
Limitations:The set of combinations of transformations is huge!Only a subset of them respects the program semantics
→ Only a (very small) subset of transformation sequences isactually tested
→ The search space is either too restrictive, or too large dueto the postponed legality check
⇒ Can we improve the search space construction: model allsequences of transformations, and model only legal ones?
4
![Page 10: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/10.jpg)
Introduction: Motivation 2nd HiPEAC Industrial Workshop
Drawbacks
Limitations:The set of combinations of transformations is huge!Only a subset of them respects the program semantics
→ Only a (very small) subset of transformation sequences isactually tested
→ The search space is either too restrictive, or too large dueto the postponed legality check
⇒ Can we improve the search space construction: model allsequences of transformations, and model only legal ones?
4
![Page 11: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/11.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
Iterative Optimization in the PolyhedralModel
Focus on a Static Control program Parts (SCoP)Use a polyhedral abstraction to represent programinformationUse iterative optimization techniques in the constructedsearch space
→ In the polyhedral model (Feautrier, 92):Compositions of transformations are easily expressedTransformation legality is easily checkedNatural expression of parallelism
5
![Page 12: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/12.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
Iterative Optimization in the PolyhedralModel
Focus on a Static Control program Parts (SCoP)Use a polyhedral abstraction to represent programinformationUse iterative optimization techniques in the constructedsearch space
→ In the polyhedral model (Feautrier, 92):Compositions of transformations are easily expressedTransformation legality is easily checkedNatural expression of parallelism
5
![Page 13: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/13.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
Iterative Optimization in the PolyhedralModel
Focus on a Static Control program Parts (SCoP)Use a polyhedral abstraction to represent programinformationUse iterative optimization techniques in the constructedsearch space
→ In the polyhedral model (Feautrier, 92):Compositions of transformations are easily expressedTransformation legality is easily checkedNatural expression of parallelism
5
![Page 14: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/14.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
Iterative Optimization in the PolyhedralModel
Focus on a Static Control program Parts (SCoP)Use a polyhedral abstraction to represent programinformationUse iterative optimization techniques in the constructedsearch space
→ In the polyhedral model (Feautrier, 92):Compositions of transformations are easily expressedTransformation legality is easily checkedNatural expression of parallelism
5
![Page 15: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/15.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
do i = 1, 3do j = 1, 3
A(i+j) = ...
1 Analysis: from code to model ⇓
1
1 2
2
i
3
3 4 5 6
j
2 Transformation in the modelHere: θ
(ij
)= t = i + j ⇓
123
12
32 3 4 5 61
j
i
t
3 Code generation:from model to code ⇓
do t = 2, 6do i = max(1,t-3), min(t-1,3)
A(t) = ...
6
![Page 16: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/16.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
do i = 1, 3do j = 1, 3
A(i+j) = ...
1 Analysis: from code to model ⇓
1
1 2
2
i
3
3 4 5 6
j
2 Transformation in the modelHere: θ
(ij
)= t = i + j ⇓
123
12
32 3 4 5 61
j
i
t
3 Code generation:from model to code ⇓
do t = 2, 6do i = max(1,t-3), min(t-1,3)
A(t) = ...
6
![Page 17: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/17.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
do i = 1, 3do j = 1, 3
A(i+j) = ...
1 Analysis: from code to model ⇓
1
1 2
2
i
3
3 4 5 6
j
2 Transformation in the modelHere: θ
(ij
)= t = i + j ⇓
123
12
32 3 4 5 61
j
i
t
3 Code generation:from model to code ⇓
do t = 2, 6do i = max(1,t-3), min(t-1,3)
A(t) = ...
6
![Page 18: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/18.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
do i = 1, 3do j = 1, 3
A(i+j) = ...
1 Analysis: from code to model ⇓
1
1 2
2
i
3
3 4 5 6
j
2 Transformation in the modelHere: θ
(ij
)= t = i + j ⇓
123
12
32 3 4 5 61
j
i
t
3 Code generation:from model to code ⇓
do t = 2, 6do i = max(1,t-3), min(t-1,3)
A(t) = ...
6
![Page 19: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/19.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
1 Analysis: from code to model→ Existing prototype tools→ GCC GRAPHITE branch in development
2 Transformation in the model→ Build a search space of (legal) transformations
3 Code generation: from model to code→ Use the CLooG tool for code generation (Bastoul, 04)→ Produce C compilable code
7
![Page 20: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/20.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
1 Analysis: from code to model→ Existing prototype tools→ GCC GRAPHITE branch in development
2 Transformation in the model→ Build a search space of (legal) transformations
3 Code generation: from model to code→ Use the CLooG tool for code generation (Bastoul, 04)→ Produce C compilable code
7
![Page 21: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/21.jpg)
Introduction: The Polyhedral Model 2nd HiPEAC Industrial Workshop
A Three-Stage Process
1 Analysis: from code to model→ Existing prototype tools→ GCC GRAPHITE branch in development
2 Transformation in the model→ Build a search space of (legal) transformations
3 Code generation: from model to code→ Use the CLooG tool for code generation (Bastoul, 04)→ Produce C compilable code
7
![Page 22: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/22.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Extract the Instance Set
matvectdo i = 0, n
R s(i) = 0do j = 0, n
S s(i) = s(i) + a(i,j) * x(j)end do
end do
Iteration domain of R:iteration vector ~xR = (i)Exact set of instances of R is DR : {i | 0 ≤ i ≤ n}
8
![Page 23: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/23.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Extract the Instance Set
matvectdo i = 0, n
R s(i) = 0do j = 0, n
S s(i) = s(i) + a(i,j) * x(j)end do
end do
Iteration domain of R:iteration vector ~xR = (i)Exact set of instances of R is DR : {i | 0 ≤ i ≤ n}
8
![Page 24: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/24.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Extract the Instance Set
matvectdo i = 0, n
R s(i) = 0do j = 0, n
S s(i) = s(i) + a(i,j) * x(j)end do
end do
Iteration domain of S:iteration vector ~xS =
(ij
)Exact set of instances of S isDS : {i , j | 0 ≤ i ≤ n, 0 ≤ j ≤ n, }
8
![Page 25: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/25.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Scheduling a Program
Definition (Schedule)A schedule of a program is a function which associates alogical date (a timestamp) to each instance of each statement.It can be written, for a statement S (T is a constant matrix):
θS( ~xS) = T(
~xS~n1
)
Two instances having the same date can be run in parallelSchedule dimension corresponds to the number of nestedsequential loops
9
![Page 26: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/26.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Scheduling a Program
Definition (Schedule)A schedule of a program is a function which associates alogical date (a timestamp) to each instance of each statement.It can be written, for a statement S (T is a constant matrix):
θS( ~xS) = T(
~xS~n1
)
Two instances having the same date can be run in parallelSchedule dimension corresponds to the number of nestedsequential loops
9
![Page 27: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/27.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Scheduling a Program
Definition (Schedule)A schedule of a program is a function which associates alogical date (a timestamp) to each instance of each statement.It can be written, for a statement S (T is a constant matrix):
θS( ~xS) = T(
~xS~n1
)
Two instances having the same date can be run in parallelSchedule dimension corresponds to the number of nestedsequential loops
9
![Page 28: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/28.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Program Transformations in the Model
Every composition of loop transformations can beexpressed as affine schedules (Wolf, 92)
⇒ A schedule is the result of an arbitrarily complexcomposition of transformation
10
![Page 29: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/29.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
Program Transformations in the Model
Every composition of loop transformations can beexpressed as affine schedules (Wolf, 92)
⇒ A schedule is the result of an arbitrarily complexcomposition of transformation
10
![Page 30: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/30.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
A Scheduling ExampleOriginal Schedule
1
2
3
5
6
4
1 2 3 4 5 6
123
i
j
1
2
3
5
6
4
1 2 3 4 5 6
123
i
j
=⇒
θR
(ij
)=
(ij
)=
[ 1 00 1
] (ij
)
do i = 1, 2do j = 1, 3
a(i,j) = a(i,j) * 0.2
do i = 1, 2do j = 1, 3
a(i,j) = a(i,j) * 0.2
11
![Page 31: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/31.jpg)
Introduction: Polyhedral Representation of programs 2nd HiPEAC Industrial Workshop
A Scheduling ExampleAnother Schedule
1
2
3
5
6
4
1 2 3 4 5 6
123
i
j
1 2 3
4 5 6
0 1 2 3 4 5 6 i’0123
j’
=⇒
θR
(ij
)=
(ji
)=
[ 0 11 0
] (ij
)
do i = 1, 2do j = 1, 3
a(i,j) = a(i,j) * 0.2
do j = 1, 3do i = 1, 2
a(i,j) = a(i,j) * 0.2
12
![Page 32: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/32.jpg)
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
ContextFocus on one-dimensional schedules (T is a constant rowmatrix)One-dimensional schedule can represent compositions of:
Transformation Descriptionreversal Changes the direction in which a loop
traverses its iteration rangeskewing Makes the bounds of a given loop depend on
an outer loop counterinterchange Exchanges two loops in a perfectly nested
loop, a.k.a. permutationpeeling Extracts one iteration of a given loopshifting Allows to reorder loopsfusion Fuses two loops, a.k.a. jamming
distribution Splits a single loop nest into many,a.k.a. fission or splitting
13
![Page 33: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/33.jpg)
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
ContextFocus on one-dimensional schedules (T is a constant rowmatrix)One-dimensional schedule can represent compositions of:
Transformation Descriptionreversal Changes the direction in which a loop
traverses its iteration rangeskewing Makes the bounds of a given loop depend on
an outer loop counterinterchange Exchanges two loops in a perfectly nested
loop, a.k.a. permutationpeeling Extracts one iteration of a given loopshifting Allows to reorder loopsfusion Fuses two loops, a.k.a. jamming
distribution Splits a single loop nest into many,a.k.a. fission or splitting
13
![Page 34: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/34.jpg)
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
Potential Transformations
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
The two prototype affine schedules for R and S are:
θR(~xR) = t1R .iR + t2R .n + t3R .1θS(~xS) = t1S .iS + t2S .jS + t3S .n + t4S .1
⇒ For −1 ≤ t ≤ 1, there are 59049 values!
matvect locality matmul gauss crout
Bounds −1, 1 −1, 1 −1, 1 −1, 1 −3, 3#Sched. 2.1× 103 5.9× 104 1.9× 104 5.9× 104 2.6× 1015
14
![Page 35: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/35.jpg)
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
Potential Transformations
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
The two prototype affine schedules for R and S are:
θR(~xR) = t1R .iR + t2R .n + t3R .1θS(~xS) = t1S .iS + t2S .jS + t3S .n + t4S .1
⇒ For −1 ≤ t ≤ 1, there are 59049 values!
matvect locality matmul gauss crout
Bounds −1, 1 −1, 1 −1, 1 −1, 1 −3, 3#Sched. 2.1× 103 5.9× 104 1.9× 104 5.9× 104 2.6× 1015
14
![Page 36: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/36.jpg)
Iterative Optimization in the Polyhedral Model: One-Dimensional Schedules 2nd HiPEAC Industrial Workshop
Potential Transformations
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
The two prototype affine schedules for R and S are:
θR(~xR) = t1R .iR + t2R .n + t3R .1θS(~xS) = t1S .iS + t2S .jS + t3S .n + t4S .1
⇒ For −1 ≤ t ≤ 1, there are 59049 values!
matvect locality matmul gauss crout
Bounds −1, 1 −1, 1 −1, 1 −1, 1 −3, 3#Sched. 2.1× 103 5.9× 104 1.9× 104 5.9× 104 2.6× 1015
14
![Page 37: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/37.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Objectives
Build the set of all legal program versions (i.e. whichrespects all the data dependence of the program)
→ Perform an exact dependence analysis→ Build the set of all possible values of T
⇒ The resulting space represents all the distinct possible waysto legally reschedule the program, using arbitrarily complexsequences of transformations.
15
![Page 38: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/38.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Objectives
Build the set of all legal program versions (i.e. whichrespects all the data dependence of the program)
→ Perform an exact dependence analysis→ Build the set of all possible values of T
⇒ The resulting space represents all the distinct possible waysto legally reschedule the program, using arbitrarily complexsequences of transformations.
15
![Page 39: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/39.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Objectives
Build the set of all legal program versions (i.e. whichrespects all the data dependence of the program)
→ Perform an exact dependence analysis→ Build the set of all possible values of T
⇒ The resulting space represents all the distinct possible waysto legally reschedule the program, using arbitrarily complexsequences of transformations.
15
![Page 40: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/40.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Dependence ExpressionNeed to represent the exact set of instances independenceExact computation made possible thanks to the SCoP andStatic reference assumptions (Feautrier, 92)Use a subset of the Cartesian product of iteration domains:
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
16
![Page 41: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/41.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Dependence ExpressionNeed to represent the exact set of instances independenceExact computation made possible thanks to the SCoP andStatic reference assumptions (Feautrier, 92)Use a subset of the Cartesian product of iteration domains:
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
i
Iterations of R
DRδS :
1 0 0 0 −1
−1 0 0 0 30 1 0 0 −10 −1 0 0 30 0 1 0 −10 0 −1 0 31 −1 0 0 0
.
(iRiSjSn1
)≥ ~0= 0
16
![Page 42: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/42.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Dependence ExpressionNeed to represent the exact set of instances independenceExact computation made possible thanks to the SCoP andStatic reference assumptions (Feautrier, 92)Use a subset of the Cartesian product of iteration domains:
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
i
Iterations of S
Iterations of R
DRδS :
1 0 0 0 −1−1 0 0 0 3
0 1 0 0 −10 −1 0 0 30 0 1 0 −10 0 −1 0 31 −1 0 0 0
.
(iRiSjSn1
)≥ ~0= 0
16
![Page 43: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/43.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Dependence ExpressionNeed to represent the exact set of instances independenceExact computation made possible thanks to the SCoP andStatic reference assumptions (Feautrier, 92)Use a subset of the Cartesian product of iteration domains:
do i = 1, 3R s(i) = 0
do j = 1, 3S s(i) = s(i) + a(i)(j) * x(j)
i
Iterations of R
Iterations of S DRδS :
1 0 0 0 −1
−1 0 0 0 30 1 0 0 −10 −1 0 0 30 0 1 0 −10 0 −1 0 31 −1 0 0 0
.
(iRiSjSn1
)≥ ~0= 0
16
![Page 44: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/44.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Formal Definition [1/2]
Legal Schedule
⇒ Assuming RδS, θR( ~xR) and θS( ~xS) are legal iff:
∆R,S = θS( ~xS)− θR( ~xR)− 1
Is non-negative for each point in DRδS.
17
![Page 45: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/45.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Formal Definition [2/2]
→ We can express the legality condition as a set of affinenon-negative functions over DRδS
Lemma (Affine form of Farkas lemma)Let D be a nonempty polyhedron defined by the inequalitiesA~x + ~b ≥ ~0. Then any affine function f (~x) is non-negativeeverywhere in D iff it is a positive affine combination:
f (~x) = λ0 + ~λT (A~x + ~b), with λ0 ≥ 0 and ~λ ≥ ~0.
λ0 and ~λT are called the Farkas multipliers.
⇒ We can express the set of affine, non-negative functionsover DRδS
18
![Page 46: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/46.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Formal Definition [2/2]
→ We can express the legality condition as a set of affinenon-negative functions over DRδS
Lemma (Affine form of Farkas lemma)Let D be a nonempty polyhedron defined by the inequalitiesA~x + ~b ≥ ~0. Then any affine function f (~x) is non-negativeeverywhere in D iff it is a positive affine combination:
f (~x) = λ0 + ~λT (A~x + ~b), with λ0 ≥ 0 and ~λ ≥ ~0.
λ0 and ~λT are called the Farkas multipliers.
⇒ We can express the set of affine, non-negative functionsover DRδS
18
![Page 47: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/47.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Formal Definition [2/2]
→ We can express the legality condition as a set of affinenon-negative functions over DRδS
Lemma (Affine form of Farkas lemma)Let D be a nonempty polyhedron defined by the inequalitiesA~x + ~b ≥ ~0. Then any affine function f (~x) is non-negativeeverywhere in D iff it is a positive affine combination:
f (~x) = λ0 + ~λT (A~x + ~b), with λ0 ≥ 0 and ~λ ≥ ~0.
λ0 and ~λT are called the Farkas multipliers.
⇒ We can express the set of affine, non-negative functionsover DRδS
18
![Page 48: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/48.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
An Example
do i = 1, nR s(i) = 0
do j = 1, nS s(i) = s(i) + a(i,j) * x(j)
The two prototype affine schedules for R and S are:θR (~xR ) = t1R
.iR + t2R.n + t3R
.1θS(~xS) = t1S
.iS + t2S.jS + t3S
.n + t4S.1
The set of instances of R and S in dependence arerepresented by:
DRδS :
1 −1 0 0 01 0 0 0 0−1 0 0 1 0
0 1 0 0 00 −1 0 1 00 0 1 0 00 0 −1 1 0
.
(iRiSjSn1
)= 0
≥ ~0
19
![Page 49: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/49.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
An Example
do i = 1, nR s(i) = 0
do j = 1, nS s(i) = s(i) + a(i,j) * x(j)
The two prototype affine schedules for R and S are:θR (~xR ) = t1R
.iR + t2R.n + t3R
.1θS(~xS) = t1S
.iS + t2S.jS + t3S
.n + t4S.1
1 Express the set of non-negative functions over DRδS2 Equate the coefficients3 Solve the system
19
![Page 50: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/50.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
An Example
do i = 1, nR s(i) = 0
do j = 1, nS s(i) = s(i) + a(i,j) * x(j)
The two prototype affine schedules for R and S are:θR (~xR ) = t1R
.iR + t2R.n + t3R
.1θS(~xS) = t1S
.iS + t2S.jS + t3S
.n + t4S.1
We get the following system for RδS:
DRδS iR : −t1R= λD1,1
− λD1,2+ λD1,7
iS : t1S= λD1,3
− λD1,4− λD1,7
jS : t2S= λD1,5
− λD1,6n : t3S
− t2R= λD1,2
+ λD1,4+ λD1,6
1 : t4S− t3R
− 1 = λD1,0
⇒ The constraints on t gives the set of possible values torespect the legality condition
19
![Page 51: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/51.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
An Example
do i = 1, nR s(i) = 0
do j = 1, nS s(i) = s(i) + a(i,j) * x(j)
The two prototype affine schedules for R and S are:θR (~xR ) = t1R
.iR + t2R.n + t3R
.1θS(~xS) = t1S
.iS + t2S.jS + t3S
.n + t4S.1
We get the following system for RδS:
DRδS iR : −t1R= λD1,1
− λD1,2+ λD1,7
iS : t1S= λD1,3
− λD1,4− λD1,7
jS : t2S= λD1,5
− λD1,6n : t3S
− t2R= λD1,2
+ λD1,4+ λD1,6
1 : t4S− t3R
− 1 = λD1,0
⇒ The constraints on t gives the set of possible values torespect the legality condition
19
![Page 52: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/52.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Construction Algorithm
Need to add the constraints obtained for each dependenceThe set of legal transformations can be infinite→ Need to bound the space
⇒ To each (integral) point in Dt corresponds a different versionof the original program where the semantics is preserved.
20
![Page 53: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/53.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Construction Algorithm
Need to add the constraints obtained for each dependenceThe set of legal transformations can be infinite→ Need to bound the space
⇒ To each (integral) point in Dt corresponds a different versionof the original program where the semantics is preserved.
20
![Page 54: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/54.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Construction Algorithm
Need to add the constraints obtained for each dependenceThe set of legal transformations can be infinite→ Need to bound the space
⇒ To each (integral) point in Dt corresponds a different versionof the original program where the semantics is preserved.
20
![Page 55: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/55.jpg)
Iterative Optimization in the Polyhedral Model: Legal Scheduling Space 2nd HiPEAC Industrial Workshop
Legal Search Space
Multiple orders of magnitude reduction in the size of thesearch space compared to state-of-the-art techniques
Benchmark Bounds #Sched #Legal Timematvect −1, 1 2.1× 103 129 0.024locality −1, 1 5.9× 104 6561 0.022matmul −1, 1 1.9× 104 912 0.029gauss −1, 1 5.9× 104 506 0.047crout −3, 3 2.6× 1015 798 0.046
21
![Page 56: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/56.jpg)
Experimental Results: 2nd HiPEAC Industrial Workshop
Experimental Protocol
We provide a source-to-source framework. Given an inputprogram:
1 Use LetSee to generate a CLooG formatted file per legaltransformation.
2 Generate the target code with CLooG.3 Compile and launch the whole set of transformed (C) code,
and sort the results regarding cycle count.
⇒ Exhaustive scan is achievable on small kernels
22
![Page 57: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/57.jpg)
Experimental Results: 2nd HiPEAC Industrial Workshop
Experimental Protocol
We provide a source-to-source framework. Given an inputprogram:
1 Use LetSee to generate a CLooG formatted file per legaltransformation.
2 Generate the target code with CLooG.3 Compile and launch the whole set of transformed (C) code,
and sort the results regarding cycle count.
⇒ Exhaustive scan is achievable on small kernels
22
![Page 58: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/58.jpg)
Experimental Results: Exhaustive Scan 2nd HiPEAC Industrial Workshop
Performance Distribution [1/2]
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
Cyc
les
(M)
Transfo. ID
matxmat
Original
5e+08
1e+09
1.5e+09
2e+09
2.5e+09
3e+09
3.5e+09
4e+09
0 1000 2000 3000 4000 5000 6000 7000
Cyc
les
(M)
Transfo. ID
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
Cyc
les
(M)
Transfo. ID
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
0 100 200 300 400 500 600 700 800
Cyc
les
(M)
Transfo. ID
crout
Original
Figure: Performance distribution for matmul, locality, mvt andcrout
23
![Page 59: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/59.jpg)
Experimental Results: Exhaustive Scan 2nd HiPEAC Industrial Workshop
Performance Distribution [2/2]
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
0 100 200 300 400 500 600 700 800
Cyc
les
(M)
Transfo. ID
crout
Original
(a) GCC -O3
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
0 100 200 300 400 500 600 700 800
Cyc
les
(M)
Transfo. ID
crout
Original
(b) ICC -fast
Figure: The effect of the compiler
24
![Page 60: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/60.jpg)
Experimental Results: Exhaustive Scan 2nd HiPEAC Industrial Workshop
Some Speedups
Benchmark Compiler Options Parameters ID best Speedup
h264 PathCC -Ofast N=8 352 36.1%h264 GCC -O2 N=8 234 13.3%h264 GCC -O3 N=8 250 25.0%h264 ICC -O2 N=8 290 12.9%h264 ICC -fast N=8 N/A 0%
fir PathCC -Ofast N=150000 72 6.0%fir GCC -O2 N=150000 192 15.2%fir GCC -O3 N=150000 289 13.2%fir ICC -O2 N=150000 242 18.4%fir ICC -fast N=150000 392 3.4%
MVT PathCC -Ofast N=2000 4934 27.4%MVT GCC -O2 N=2000 13301 18.0%MVT GCC -O3 N=2000 13320 21.2%MVT ICC -O2 N=2000 14093 24.0%MVT ICC -fast N=2000 4879 29.1%
matmul PathCC -Ofast N=250 283 308.1%matmul GCC -O2 N=250 573 243.6%matmul GCC -O3 N=250 143 248.7%matmul ICC -O2 N=250 311 356.6%matmul ICC -fast N=250 641 645.4%
25
![Page 61: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/61.jpg)
Experimental Results: A Transformation Example 2nd HiPEAC Industrial Workshop
The mvt Kernel
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 -O3 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 -fast 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 -Ofast 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
![Page 62: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/62.jpg)
Experimental Results: A Transformation Example 2nd HiPEAC Industrial Workshop
Generated Code
Optimal Transformation for mvt, GCC 4 -O3, P4 XeonS1: x1[i] = 0S2: x2[i] = 0S3: 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
![Page 63: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/63.jpg)
Experimental Results: A Transformation Example 2nd HiPEAC Industrial Workshop
Heuristic ScanPropose a decoupling heuristic:
The general “form” of the schedule is embedded in theiterator coefficientsParameters and constant coefficients can be seen as arefinement
→ On some distributions a random heuristic may convergefaster
Figure: Heuristic convergence
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
![Page 64: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/64.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29
![Page 65: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/65.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29
![Page 66: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/66.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29
![Page 67: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/67.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29
![Page 68: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/68.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29
![Page 69: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/69.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29
![Page 70: Iterative Optimization in the Polyhedral Model: One ...web.cse.ohio-state.edu/~pouchet.2/doc/hipeac-cm-10.16.06-slides.pdf · Iterative Optimization in the Polyhedral Model: One-Dimensional](https://reader035.fdocuments.net/reader035/viewer/2022070818/5f166abad502983789243f18/html5/thumbnails/70.jpg)
Conclusion: 2nd HiPEAC Industrial Workshop
Conclusion
→ Iterative Compilation Framework independent of thecompiler and the architecture
→ Optimizing and / or Enabling transformation process→ Leads to encouraging speedups→ On small kernels, exhaustive scan is achievable
Future work:→ Develop new exploration heuristics→ Deal with multidimensional schedules→ Integrate in GCC GRAPHITE branch
29