a polynomial spilling heuristic layered allocation
play

A Polynomial Spilling Heuristic: Layered Allocation Boubacar Diouf 1 - PowerPoint PPT Presentation

erieure de Paris . . . . . . . erieure de Lyon Introduction Layered Approach Evaluation Conclusion A Polynomial Spilling Heuristic: Layered Allocation Boubacar Diouf 1 2 , Albert Cohen 1 2 , Fabrice Rastello 1 2 1 INRIA 2 Ecole Normale


  1. erieure de Paris . . . . . . . erieure de Lyon Introduction Layered Approach Evaluation Conclusion A Polynomial Spilling Heuristic: Layered Allocation Boubacar Diouf 1 2 , Albert Cohen 1 2 , Fabrice Rastello 1 2 1 INRIA 2 ´ Ecole Normale Sup ´ 3 ´ Ecole Normale Sup ´ Layered Allocation 1 / 20

  2. . . . . . . . The register allocation problem maps temporary variables to machine registers Introduction Layered Approach Evaluation Conclusion Register Allocation The Allocation/Spilling Problem • The allocation chooses the register residents • It also aims at minimizing the load/store overhead Assignment/Coloring • The coloring decides which register is used by which variable Decoupling • For the moment, let us assume that these two problems can be decoupled Layered Allocation 2 / 20

  3. . . . . . . . The register allocation problem maps temporary variables to machine registers Introduction Layered Approach Evaluation Conclusion Register Allocation The Allocation/Spilling Problem • The allocation chooses the register residents • It also aims at minimizing the load/store overhead Assignment/Coloring • The coloring decides which register is used by which variable Decoupling • For the moment, let us assume that these two problems can be decoupled Layered Allocation 2 / 20

  4. . . . . . . . The register allocation problem maps temporary variables to machine registers Introduction Layered Approach Evaluation Conclusion Register Allocation The Allocation/Spilling Problem • The allocation chooses the register residents • It also aims at minimizing the load/store overhead Assignment/Coloring • The coloring decides which register is used by which variable Decoupling • For the moment, let us assume that these two problems can be decoupled Layered Allocation 2 / 20

  5. . . . . . . . The register allocation problem maps temporary variables to machine registers Introduction Layered Approach Evaluation Conclusion Register Allocation The Allocation/Spilling Problem • The allocation chooses the register residents • It also aims at minimizing the load/store overhead Assignment/Coloring • The coloring decides which register is used by which variable Decoupling • For the moment, let us assume that these two problems can be decoupled Layered Allocation 2 / 20

  6. allocate to a small number of registers . . . . . . . decrease maxlive by a small number Introduction Layered Approach Evaluation Conclusion A bit of Terminology • Maxlive : the maximum number of simultaneously live variables • Given V a set of variables of a program and R a number of available registers Two sub-problems • The lowering problem finds S , a subset of V , of minimum cost to spill in order to • The single layer allocation problem finds A , a subset of V , of maximum cost to Two Approaches to the Allocation Problem • The layered allocation incrementally solves the single layer allocation problem until the sum of the used registers reaches R • The incremental lowering incrementally solves the lowering problem until maxlive reaches R Layered Allocation 3 / 20

  7. allocate to a small number of registers . . . . . . . decrease maxlive by a small number Introduction Layered Approach Evaluation Conclusion A bit of Terminology • Maxlive : the maximum number of simultaneously live variables • Given V a set of variables of a program and R a number of available registers Two sub-problems • The lowering problem finds S , a subset of V , of minimum cost to spill in order to • The single layer allocation problem finds A , a subset of V , of maximum cost to Two Approaches to the Allocation Problem • The layered allocation incrementally solves the single layer allocation problem until the sum of the used registers reaches R • The incremental lowering incrementally solves the lowering problem until maxlive reaches R Layered Allocation 3 / 20

  8. allocate to a small number of registers . . . . . . . decrease maxlive by a small number Introduction Layered Approach Evaluation Conclusion A bit of Terminology • Maxlive : the maximum number of simultaneously live variables • Given V a set of variables of a program and R a number of available registers Two sub-problems • The lowering problem finds S , a subset of V , of minimum cost to spill in order to • The single layer allocation problem finds A , a subset of V , of maximum cost to Two Approaches to the Allocation Problem • The layered allocation incrementally solves the single layer allocation problem until the sum of the used registers reaches R • The incremental lowering incrementally solves the lowering problem until maxlive reaches R Layered Allocation 3 / 20

  9. allocate to a small number of registers . . . . . . . decrease maxlive by a small number Introduction Layered Approach Evaluation Conclusion A bit of Terminology • Maxlive : the maximum number of simultaneously live variables • Given V a set of variables of a program and R a number of available registers Two sub-problems • The lowering problem finds S , a subset of V , of minimum cost to spill in order to • The single layer allocation problem finds A , a subset of V , of maximum cost to Two Approaches to the Allocation Problem • The layered allocation incrementally solves the single layer allocation problem until the sum of the used registers reaches R • The incremental lowering incrementally solves the lowering problem until maxlive reaches R Layered Allocation 3 / 20

  10. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of live variables maxlive 0 Program points Layered Allocation 4 / 20

  11. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of live variables maxlive R 0 Program points Layered Allocation 4 / 20

  12. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of live variables maxlive maxlive - small R 0 Program points Layered Allocation 4 / 20

  13. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of Spilling some variables in order to lower live variables maxlive by small is NP-complete Even if small = 1! maxlive maxlive - small R 0 Program points Layered Allocation 4 / 20

  14. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of live variables maxlive R small 0 Program points Layered Allocation 4 / 20

  15. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of Allocating variables to a small number of registers is polynomial! live variables maxlive R small 0 Program points Layered Allocation 4 / 20

  16. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of Proceeding by layered allocation is still polynomial! live variables maxlive R small 0 Program points Layered Allocation 4 / 20

  17. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of Proceeding by layered allocation is still polynomial! live variables maxlive R small 0 Program points Layered Allocation 4 / 20

  18. . . . . . . . Introduction Layered Approach Evaluation Conclusion Lowering vs. Layering Number of live variables maxlive NP-complete maxlive - small R Polynomial small 0 Program points Layered Allocation 4 / 20

  19. variables to spill to make a coloring possible . . . . . . . [Diouf’10] Introduction Layered Approach Evaluation Conclusion Why should the Layered Allocation be Close to Optimal? • Let us assume that we have a program P • When R + 1 registers are available, let us call SPILL P R +1 the optimal set of • For most programs, SPILL P R +1 ⊂ SPILL P R • Hence, for most programs, ALLOC P R ⊂ ALLOC P R +1 Layered Allocation 5 / 20

  20. Polynomial Quality Close to optimal . Layered Allocation Optimal NP-complete Allocation/Spilling Complexity NP-complete Approach ??? Incremental lowering-heuristic Polynomial Not-optimal . . . . . . Incremental lowering-optimal Introduction Layered Approach Evaluation Conclusion Taxonomy of the Approaches To make it clear! • The Allocation problem is NP-complete • The Layered allocation is a heuristic that is close to optimal allocation • We are not turning an NP-complete problem into a polynomial one Layered Allocation 6 / 20

  21. Polynomial Quality Close to optimal . Layered Allocation Optimal NP-complete Allocation/Spilling Complexity NP-complete Approach ??? Incremental lowering-heuristic Polynomial Not-optimal . . . . . . Incremental lowering-optimal Introduction Layered Approach Evaluation Conclusion Taxonomy of the Approaches To make it clear! • The Allocation problem is NP-complete • The Layered allocation is a heuristic that is close to optimal allocation • We are not turning an NP-complete problem into a polynomial one Layered Allocation 6 / 20

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