loop transformations convexity pruning and optimization
play

Loop Transformations: Convexity, Pruning and Optimization Louis-Nol - PowerPoint PPT Presentation

Loop Transformations: Convexity, Pruning and Optimization Louis-Nol Pouchet 1 Uday Bondhugula 2 Cdric Bastoul 3 Albert Cohen 3 J. Ramanujam 4 P . Sadayappan 1 Nicolas Vasilache 5 1 The Ohio State University 2 IBM T.J. Watson Research Center 3


  1. Loop Transformations: Convexity, Pruning and Optimization Louis-Noël Pouchet 1 Uday Bondhugula 2 Cédric Bastoul 3 Albert Cohen 3 J. Ramanujam 4 P . Sadayappan 1 Nicolas Vasilache 5 1 The Ohio State University 2 IBM T.J. Watson Research Center 3 ALCHEMY group, INRIA Saclay / University of Paris-Sud 11 4 Louisiana State University 5 Reservoir Labs, Inc. January 28, 2011 ACM 2011 Symposium on Principles of Programming Languages Austin, TX

  2. Overview: POPL’11 Compiler Optimizations for Performance ◮ High-level loop transformations are critical for performance... ◮ Coarse-grain parallelism (OpenMP) ◮ Fine-grain parallelism (SIMD) ◮ Data locality (reduce cache misses) OSU / IBM / INRIA / LSU / Reservoir 2

  3. Overview: POPL’11 Compiler Optimizations for Performance ◮ High-level loop transformations are critical for performance... ◮ Coarse-grain parallelism (OpenMP) ◮ Fine-grain parallelism (SIMD) ◮ Data locality (reduce cache misses) ◮ ... But deciding the best sequence of transformations is hard! ◮ Conflicting objectives: more SIMD implies less locality, etc. ◮ It is machine-dependent and of course program-dependent ◮ Expressive search spaces are required, but challenge the search! OSU / IBM / INRIA / LSU / Reservoir 2

  4. Overview: POPL’11 Compiler Optimizations for Performance ◮ High-level loop transformations are critical for performance... ◮ Coarse-grain parallelism (OpenMP) ◮ Fine-grain parallelism (SIMD) ◮ Data locality (reduce cache misses) ◮ ... But deciding the best sequence of transformations is hard! ◮ Conflicting objectives: more SIMD implies less locality, etc. ◮ It is machine-dependent and of course program-dependent ◮ Expressive search spaces are required, but challenge the search! ◮ Our approach: ◮ Convexity: model optimization spaces as convex set (ILP , scan, project, etc.) ◮ Pruning: make our spaces contain all and only semantically equivalent programs in our framework ◮ Optimization: decompose in two more tractable sub-problems without any loss of expressiveness, empirical search + ILP models OSU / IBM / INRIA / LSU / Reservoir 2

  5. Overview: POPL’11 Spaces of Affine Loop transformations !""#$%&'$(#)*$%+(+ !""#$%&'$(#1(/,%0&21456(1(67&%8 ,-.%(#/$"0&+&/(%1&*%,"#123(+$"(1 -$1&*%#9#+&106&)$0&*%#9#2*+(#/*0&*%#23*&2(1 !""#$%&'$(#1(/,%0&21456(1(67&%8 ,-.%(#/$"0&+&/(%1&*%,"#123(+$"(1 OSU / IBM / INRIA / LSU / Reservoir 3

  6. Overview: POPL’11 Spaces of Affine Loop transformations !""#$%&'$(#)*$%+(+ !""#$%&'$(#1(/,%0&21456(1(67&%8 ,-.%(#/$"0&+&/(%1&*%,"#123(+$"(1 -$1&*%#9#+&106&)$0&*%#9#2*+(#/*0&*%#23*&2(1 !""#$%&'$(#1(/,%0&21456(1(67&%8 ,-.%(#/$"0&+&/(%1&*%,"#123(+$"(1 Bounded: 10 200 Legal: 10 50 Empirical search: 10 OSU / IBM / INRIA / LSU / Reservoir 3

  7. Overview: POPL’11 Spaces of Affine Loop transformations !""#$%&'$(#)*$%+(+ ,-.%(#/$"0&+&/(%1&*%,"#123(+$"(1 1 point ↔ 1 unique transformed program OSU / IBM / INRIA / LSU / Reservoir 3

  8. Polyhedral Model: Program Representation POPL’11 Polyhedral Representation of Programs Static Control Parts ◮ Loops have affine control only (over-approximation otherwise) OSU / IBM / INRIA / LSU / Reservoir 4

  9. Polyhedral Model: Program Representation POPL’11 Polyhedral Representation of Programs Static Control Parts ◮ Loops have affine control only (over-approximation otherwise) ◮ Iteration domain: represented as integer polyhedra   for (i=1; i<=n; ++i) 1 0 0 − 1   i − 1 0 1 0 . for (j=1; j<=n; ++j)   j     ≥ �  D S 1 = 0 1 0 − 1 . 0     n . . if (i<=n-j+2)    − 1 0 1 0   1 . . . s[i] = ... − 1 − 1 1 2 OSU / IBM / INRIA / LSU / Reservoir 4

  10. Polyhedral Model: Program Representation POPL’11 Polyhedral Representation of Programs Static Control Parts ◮ Loops have affine control only (over-approximation otherwise) ◮ Iteration domain: represented as integer polyhedra ◮ Memory accesses: static references, represented as affine functions of � x S and � p   � x S 2 � 1 f s ( � x S 2 ) = 0 � 0 0 . n   1 for (i=0; i<n; ++i) {   . s[i] = 0; � x S 2 � � 1 0 0 0 . for (j=0; j<n; ++j) f a ( � x S 2 ) = . n   0 1 0 0 . . s[i] = s[i]+a[i][j]*x[j]; 1 }   x S 2 � � 0 f x ( � x S 2 ) = 0 � 1 0 . n   1 OSU / IBM / INRIA / LSU / Reservoir 4

  11. Polyhedral Model: Program Representation POPL’11 Polyhedral Representation of Programs Static Control Parts ◮ Loops have affine control only (over-approximation otherwise) ◮ Iteration domain: represented as integer polyhedra ◮ Memory accesses: static references, represented as affine functions of � x S and � p ◮ Data dependence between S1 and S2: a subset of the Cartesian product of D S 1 and D S 2 ( exact analysis ) S1 iterations − 1 for (i=1; i<=3; ++i) { 1 0 0   1 0 0 − 1 . s[i] = 0;     iS 1  − 1 0 0 3  = 0   iS 2 . for (j=1; j<=3; ++j)   D S 1 δ S 2 :  0 1 0 − 1  . S2 iterations     jS 2 ≥ � 0   . . s[i] = s[i] + 1;  0 − 1 0 3    1 0 0 1 − 1   } 0 0 − 1 3 i OSU / IBM / INRIA / LSU / Reservoir 4

  12. Polyhedral Model: Transformations in the Polyhedral Model POPL’11 Affine Transformations for Iteration Reordering Interchange Transformation The transformation matrix is the identity with a permutation of two rows. j j’ 3 3 6 3 2 2 2 5 4 5 6 1 1 1 2 3 1 4 0 i’ i 1 2 3 4 5 6 0 1 2 3 4 5 6 = ⇒ �� i � 0 1 i ′ � � �  0 1   − 1  − 1 i ′  1 0    = − 1 � � � i 0 2  ≥ � + 0 � j ′     − 1 j ′ 0 2 j − 1  ≥ � 1 0  1 0   + 0     j − 1  0 1   − 1 0 3 − 1 0 3 (a) original polyhedron (b) transformation function (c) target polyhedron do i = 1, 2 do i’ = 1, 3 do j = 1, 3 do j’ = 1, 2 S(i,j) S(i=j’,j=i’) OSU / IBM / INRIA / LSU / Reservoir 6

  13. Polyhedral Model: Transformations in the Polyhedral Model POPL’11 Affine Transformations for Iteration Reordering Reversal Transformation The transformation matrix is the identity with one diagonal element replaced by − 1 . j j’ 3 3 3 6 5 3 2 2 2 5 4 2 1 1 1 4 6 1 i’ i 1 2 3 4 5 6 −3 −2 −1 0 1 2 = ⇒ �� i � − 1 0 i ′ � � � − 1  0   − 1  − 1 i ′  1 0    = � � � i 1 0 2  ≥ � + 0 � j ′     − 1 j ′ 0 2 j − 1  ≥ � 0 1  0 1   + 0     j − 1  0 1   − 1 0 3 − 1 0 3 (a) original polyhedron (b) transformation function (c) target polyhedron do i = 1, 2 do i’ = -1, -2, -1 do j = 1, 3 do j’ = 1, 3 S(i,j) S(i=3-i’,j=j’) OSU / IBM / INRIA / LSU / Reservoir 6

  14. Polyhedral Model: Transformations in the Polyhedral Model POPL’11 Affine Transformations for Iteration Reordering Coumpound Transformation The transformation matrix is the composition of an interchange and reversal j j’ 3 3 3 6 2 2 2 5 6 5 4 1 1 1 4 3 2 1 i’ i 1 2 3 4 5 6 −3 −2 −1 0 1 2 = ⇒ �� i � 0 − 1 i ′ � � � − 1  0   − 1  − 1 i ′  1 0    = � � � i 0 1 2  ≥ � + 0 � j ′     − 1 j ′ 0 2 j − 1  ≥ � 1 0  1 0   + 0     j − 1  0 1   − 1 0 3 − 1 0 3 (a) original polyhedron (b) transformation function (c) target polyhedron do i = 1, 2 do j’ = -1, -3, -1 do j = 1, 3 do i’ = 1, 2 S(i,j) S(i=4-j’,j=i’) OSU / IBM / INRIA / LSU / Reservoir 6

  15. Polyhedral Model: Transformations in the Polyhedral Model POPL’11 Affine Transformations for Iteration Reordering Coumpound Transformation The transformation matrix is the composition of an interchange and reversal j j’ 3 3 3 6 2 2 2 5 6 5 4 1 1 1 4 3 2 1 i’ i 1 2 3 4 5 6 −3 −2 −1 0 1 2 = ⇒ �� i � 0 − 1 i ′ � � � − 1  0   − 1  − 1 i ′  1 0    = � � � i 0 1 2  ≥ � + 0 � j ′     − 1 j ′ 0 2 j − 1  ≥ � 1 0  1 0   + 0     j − 1  0 1   − 1 0 3 − 1 0 3 (a) original polyhedron (b) transformation function (c) target polyhedron do i = 1, 2 do j’ = -1, -3, -1 do j = 1, 3 do i’ = 1, 2 S(i,j) S(i=4-j’,j=i’) OSU / IBM / INRIA / LSU / Reservoir 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend