Static Loop Parallelization Decision Using Template Metaprogramming
Alexis Pereda, David R.C. Hill, Claude Mazel, Bruno Bachelet · 2018
This article proposes to use C++ template metaprogramming techniques to decide at compile-time which parts of a code sequence in a loop can be parallelized. The approach focuses on characterizing the way a variable is accessed in a loop (reading or writing); first to decide how the loop should be split to enable the analysis for parallelization on each part; and then to decide if the iterations inside each loop are independent so that they can be run in parallel. The conditions that enable the parallelization of a loop are first explained to justify the proposed decision algorithm exposed. Then; a C++ library-based solution is presented that uses expression templates to get the relevant information necessary for the parallelization decision of a loop; and metaprograms to decide whether to parallelize the loop and generate a parallel code.