Index: docs/HowToManuallyUseTheIndividualPiecesOfPolly.rst =================================================================== --- docs/HowToManuallyUseTheIndividualPiecesOfPolly.rst +++ docs/HowToManuallyUseTheIndividualPiecesOfPolly.rst @@ -7,11 +7,17 @@ .. sectionauthor:: Singapuram Sanjay Srivallabh -This example presents the individual passes that are involved when optimizing code with Polly. We show how to execute them individually and explain for each which analysis is performed or what transformation is applied. In this example the polyhedral transformation is user-provided to show how much performance improvement can be expected by an optimal automatic optimizer. +This example presents the individual passes that are involved when optimizing +code with Polly. We show how to execute them individually and explain for +each which analysis is performed or what transformation is applied. In this +example the polyhedral transformation is user-provided to show how much +performance improvement can be expected by an optimal automatic optimizer. 1. **Create LLVM-IR from the C code** ------------------------------------- - Polly works on LLVM-IR. Hence it is necessary to translate the source files into LLVM-IR. If more than on file should be optimized the files can be combined into a single file with llvm-link. + Polly works on LLVM-IR. Hence it is necessary to translate the source + files into LLVM-IR. If more than one file should be optimized the + files can be combined into a single file with llvm-link. .. code-block:: console @@ -21,7 +27,10 @@ 2. **Prepare the LLVM-IR for Polly** ------------------------------------ - Polly is only able to work with code that matches a canonical form. To translate the LLVM-IR into this form we use a set of canonicalication passes. They are scheduled by using '-polly-canonicalize'. + Polly is only able to work with code that matches a canonical form. + To translate the LLVM-IR into this form we use a set of + canonicalication passes. They are scheduled by using + '-polly-canonicalize'. .. code-block:: console @@ -30,7 +39,9 @@ 3. **Show the SCoPs detected by Polly (optional)** -------------------------------------------------- - To understand if Polly was able to detect SCoPs, we print the structure of the detected SCoPs. In our example two SCoPs were detected. One in 'init_array' the other in 'main'. + To understand if Polly was able to detect SCoPs, we print the structure + of the detected SCoPs. In our example two SCoPs are detected. One in + 'init_array' the other in 'main'. .. code-block:: console @@ -66,7 +77,9 @@ 4. **Highlight the detected SCoPs in the CFGs of the program (requires graphviz/dotty)** ---------------------------------------------------------------------------------------- - Polly can use graphviz to graphically show a CFG in which the detected SCoPs are highlighted. It can also create '.dot' files that can be translated by the 'dot' utility into various graphic formats. + Polly can use graphviz to graphically show a CFG in which the detected + SCoPs are highlighted. It can also create '.dot' files that can be + translated by the 'dot' utility into various graphic formats. .. code-block:: console @@ -76,15 +89,15 @@ The output for the different functions: - - view-scops : main_ , init_array_ , print_array_ - - view-scops-only : main-scopsonly_ , init_array-scopsonly_ , print_array-scopsonly_ + - view-scops : main_, init_array_, print_array_ + - view-scops-only : main-scopsonly_, init_array-scopsonly_, print_array-scopsonly_ -.. _main: experiments/matmul/scops.main.dot.png -.. _init_array: experiments/matmul/scops.init_array.dot.png -.. _print_array: experiments/matmul/scops.print_array.dot.png -.. _main-scopsonly: experiments/matmul/scopsonly.main.dot.png -.. _init_array-scopsonly: experiments/matmul/scopsonly.init_array.dot.png -.. _print_array-scopsonly: experiments/matmul/scopsonly.print_array.dot.png +.. _main: http://polly.llvm.org/experiments/matmul/scops.main.dot.png +.. _init_array: http://polly.llvm.org/experiments/matmul/scops.init_array.dot.png +.. _print_array: http://polly.llvm.org/experiments/matmul/scops.print_array.dot.png +.. _main-scopsonly: http://polly.llvm.org/experiments/matmul/scopsonly.main.dot.png +.. _init_array-scopsonly: http://polly.llvm.org/experiments/matmul/scopsonly.init_array.dot.png +.. _print_array-scopsonly: http://polly.llvm.org/experiments/matmul/scopsonly.print_array.dot.png 5. **View the polyhedral representation of the SCoPs** ------------------------------------------------------ @@ -226,9 +239,14 @@ 8. **Import the changed jscop files and print the updated SCoP structure (optional)** ------------------------------------------------------------------------------------- - Polly can reimport jscop files, in which the schedules of the statements are changed. These changed schedules are used to descripe transformations. It is possible to import different jscop files by providing the postfix of the jscop file that is imported. + Polly can reimport jscop files, in which the schedules of the statements + are changed. These changed schedules are used to descripe + transformations. It is possible to import different jscop files by + providing the postfix of the jscop file that is imported. - We apply three different transformations on the SCoP in the main function. The jscop files describing these transformations are hand written (and available in docs/experiments/matmul). + We apply three different transformations on the SCoP in the main + function. The jscop files describing these transformations are + hand written (and available in docs/experiments/matmul). **No Polly** @@ -322,7 +340,9 @@ **Interchange + Tiling + Strip-mining to prepare vectorization** - To later allow vectorization we create a so called trivially parallelizable loop. It is innermost, parallel and has only four iterations. It can be replaced by 4-element SIMD instructions. + To later allow vectorization we create a so called trivially + parallelizable loop. It is innermost, parallel and has only four + iterations. It can be replaced by 4-element SIMD instructions. .. code-block:: console @@ -356,7 +376,9 @@ 9. **Codegenerate the SCoPs** ----------------------------- - This generates new code for the SCoPs detected by polly. If -polly-import-jscop is present, transformations specified in the imported jscop files will be applied. + This generates new code for the SCoPs detected by polly. If + -polly-import-jscop is present, transformations specified in the + imported jscop files will be applied. .. code-block:: console @@ -418,7 +440,10 @@ 11. **Compare the runtime of the executables** ---------------------------------------------- - By comparing the runtimes of the different code snippets we see that a simple loop interchange gives here the largest performance boost. However in this case, adding vectorization and using OpenMP degrades the performance. + By comparing the runtimes of the different code snippets we see that a + simple loop interchange gives here the largest performance boost. + However in this case, adding vectorization and using OpenMP degrades + the performance. .. code-block:: console