scop detection a fast algorithm for industrial compilers
play

SCoP Detection: A Fast Algorithm for Industrial Compilers Sebastian - PowerPoint PPT Presentation

SCoP Detection: A Fast Algorithm for Industrial Compilers Sebastian Pop and Aditya Kumar SARC: Samsung Austin R&D Center Jan 19, 2016 1/14 Polyhedral compilation in industrial compilers Goal: enable isl scheduler in GCC at -O3 2/14


  1. SCoP Detection: A Fast Algorithm for Industrial Compilers Sebastian Pop and Aditya Kumar SARC: Samsung Austin R&D Center Jan 19, 2016 1/14

  2. Polyhedral compilation in industrial compilers ◮ Goal: enable isl scheduler in GCC at -O3 2/14

  3. Polyhedral compilation in industrial compilers ◮ Goal: enable isl scheduler in GCC at -O3 ◮ search loops that can benefit from polyhedral compilation ◮ minimal overhead: search as fast as possible ◮ only use existing analysis information ◮ use the right abstract representation 2/14

  4. What is a SCoP? Regions of code that can be represented in the Polyhedral Model. ◮ SCoPs = Static Control Parts 3/14

  5. What is a SCoP? Regions of code that can be represented in the Polyhedral Model. ◮ SCoPs = Static Control Parts ◮ ACLs = Affine Control Loops ◮ PWACs = Parts With Affine Control 3/14

  6. Step 1: accept natural loops Natural loop e a x b maybe SCoP 4/14

  7. Step 1: accept natural loops Natural loop Nested loops e e a x a x b b maybe SCoP c d maybe SCoP 4/14

  8. Step 1: accept natural loops Natural loop Nested loops Irreducible c e e e a x b a x a x not a SCoP b b maybe SCoP c d maybe SCoP 4/14

  9. Natural Loop Tree int foo(int N) { int i, j, k; for(i=0; i<N; ++i){// Loop1 stmt1; for (j=0; j<N; ++j)// Loop2 stmt2; for (k=0; k<N; ++k)// Loop3 stmt3; } } 5/14

  10. Natural Loop Tree int foo(int N) Function { int i, j, k; inner for(i=0; i<N; ++i){// Loop1 stmt1; for (j=0; j<N; ++j)// Loop2 Loop 1 stmt2; for (k=0; k<N; ++k)// Loop3 inner stmt3; } next Loop 2 Loop 3 } 5/14

  11. Step 2: check for side-effects ◮ function calls ◮ inline assembly ◮ volatile operations 6/14

  12. Step 3: affine scalar evolutions Linear i0 = phi_l1 (0, i1) // i0={0 ,+ ,1} _l1 i1 = i0 + 1 // i1={1 ,+ ,1} _l1 maybe SCoP 7/14

  13. Step 3: affine scalar evolutions Linear i0 = phi_l1 (0, i1) // i0={0 ,+ ,1} _l1 i1 = i0 + 1 // i1={1 ,+ ,1} _l1 maybe SCoP Non-linear j2 = phi_l1 (3, j3) j3 = j2 + i1 // j2={3 ,+ ,{1 ,+ ,1} _l1}_l1 not an ACL: polynomial of degree 2 7/14

  14. Step 3: affine scalar evolutions Linear Non-linear i0 = phi_l1 (0, i1) k4 = phi_l2 (4, k5) // i0={0 ,+ ,1} _l1 k5 = k4 * 2 i1 = i0 + 1 // k4={4 ,* ,2} _l2 // i1={1 ,+ ,1} _l1 not an ACL: exponential maybe SCoP Non-linear j2 = phi_l1 (3, j3) j3 = j2 + i1 // j2={3 ,+ ,{1 ,+ ,1} _l1}_l1 not an ACL: polynomial of degree 2 7/14

  15. Step 3: affine scalar evolutions Linear Non-linear i0 = phi_l1 (0, i1) k4 = phi_l2 (4, k5) // i0={0 ,+ ,1} _l1 k5 = k4 * 2 i1 = i0 + 1 // k4={4 ,* ,2} _l2 // i1={1 ,+ ,1} _l1 not an ACL: exponential maybe SCoP Non-linear analyzed expressions j2 = phi_l1 (3, j3) ◮ branch conditions j3 = j2 + i1 ◮ memory accesses // j2={3 ,+ ,{1 ,+ ,1} _l1}_l1 not an ACL: polynomial of degree 2 7/14

  16. Step 4: delinearize memory access functions Linear access functions A[100*i + 400*j] B[i][j] can represent in isl 8/14

  17. Step 4: delinearize memory access functions Linear access functions A[100*i + 400*j] B[i][j] can represent in isl Non-linear access functions C[i*i] D[4*N*M*i + 4*M*j + 4*k] E[4*i*N + 4*j] cannot represent in isl 8/14

  18. Step 4: delinearize memory access functions Linear access functions delinearization ◮ recognize array A[100*i + 400*j] B[i][j] multi-dimensions ◮ compute linear access can represent in isl functions Non-linear access functions C[i*i] D[4*N*M*i + 4*M*j + 4*k] E[4*i*N + 4*j] cannot represent in isl 8/14

  19. Step 4: delinearize memory access functions Linear access functions delinearization ◮ recognize array A[100*i + 400*j] B[i][j] multi-dimensions ◮ compute linear access can represent in isl functions delinearized access functions Non-linear access functions int D[][N][M]; C[i*i] D[i][j][k] D[4*N*M*i + 4*M*j + 4*k] E[4*i*N + 4*j] int E[][N]; cannot represent in isl E[i][j] can represent in isl 8/14

  20. Overall picture: SCoP detection Natural loops no side-effects? affine branch conditions? affine memory accesses? SCoP 9/14

  21. Overall picture: SCoP detection Required analyses: Natural loops ◮ natural loops tree ◮ (post-)dominators tree no side-effects? ◮ alias analysis affine branch conditions? ◮ scalar evolution analysis affine memory accesses? SCoP 9/14

  22. Detecting SCoPs by induction on Natural Loops Tree ◮ Start with a loop in the natural loops tree rather than the root of the CFG 10/14

  23. Detecting SCoPs by induction on Natural Loops Tree ◮ Start with a loop in the natural loops tree rather than the root of the CFG ◮ Focus on structure of natural loops before the validity of each statement 10/14

  24. Example: Induction on Natural Loops Tree Function inner Loop 1 inner next Loop 2 Loop 3 11/14

  25. Example: Induction on Natural Loops Tree Function inner Loop 1 inner next Loop 2 Loop 3 11/14

  26. Example: Induction on Natural Loops Tree Function inner Loop 1 inner next Loop 2 Loop 3 11/14

  27. Example: Induction on Natural Loops Tree Function inner Loop 1 inner next Loop 2 Loop 3 11/14

  28. Example: Induction on Natural Loops Tree Function inner Loop 1 inner next Loop 2 Loop 3 11/14

  29. Other implementations of SCoP Detection ◮ Previous graphite SCoP detection based on CFG and DOM (misses the structure of loops) 12/14

  30. Other implementations of SCoP Detection ◮ Previous graphite SCoP detection based on CFG and DOM (misses the structure of loops) ◮ Polly’s SCoP detection based on structure of SESE regions (full function body analysis even without interesting loops) 12/14

  31. Other implementations of SCoP Detection ◮ Previous graphite SCoP detection based on CFG and DOM (misses the structure of loops) ◮ Polly’s SCoP detection based on structure of SESE regions (full function body analysis even without interesting loops) ◮ Pet, Rose, other source-to-source compilers: SCoP detection based on the AST of a specific programming language 12/14

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