[LLVMdev] multi-threading in llvm

Jimborean Alexandra xinfinity_a at yahoo.com
Thu Sep 8 11:53:32 PDT 2011


Hi,


I want to execute the iterations of a loop in parallel, by inserting calls either to pthreads or to the gomp library at the LLVM IR level. As a first step, I inserted an omp pragma in a C file and compiled it with llvm-gcc to check the generated LLVM code. If I understand correctly, to parallelize the loop in LLVM IR, I have to separate the loop in a new function, put all required parameters in a structure, make the call to the gomp library, and restore all values from the structure in the original variables.
Also, I have to compute the number of iterations allocated to each thread and insert in the loop body a new condition, such that each thread executes only its slice.

Is that correct?

As far as I know, both llvm-gcc and Polly already offer support for OpenMP, by inserting calls to the gomp library. Can this code be reused? Is there a pass that I can call to do all these code transformations? 


I had a look at the CodeGeneration from Polly. Is it possible to use it without creating the Scops, by transforming it into a LoopPass?
Could you indicate how is this handled in llvm-gcc?

Thank you for your help.

Alexandra.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110908/a29ab04f/attachment.html>


More information about the llvm-dev mailing list