[LLVMdev] multi-threading in llvm
tobias at grosser.es
Mon Sep 12 09:41:06 PDT 2011
On 09/12/2011 05:28 PM, Jimborean Alexandra wrote:
> Thanks for your ideas.
> Polly looked interesting as it seems it has already introduced the basic
> support for OpenMP that I need. But indeed, it seems difficult to apply
> the same code on a regular LLVM loop, instead of a SCoP.
> What I am working on is speculative parallelism, so I cannot provide the
> SCoPs required by Polly. I analyze the loops and try to parallelize them
> speculatively at the LLVM IR level. So I am searching for the easiest
> (and possibly fastest) way to create parallel code. I was not planning
> to reimplement the OpenMP support you provide, as I was hoping to reuse
> it. Maybe we can further discuss which solution is better and how
> difficult it is to adapt the parallel code generation from Polly for
> regular loops.
Sure, let's do this. We can also have a chat this Friday on Euro-LLVM.
> What I am looking for is a pass that can automatically build the
> structure of parameters required for the thread creation and execution,
> and modify the loop code accordingly. Namely, to load the parameters
> necessary for the thread into a structure and replace the use of these
> values inside the loop with the corresponding field in the structure.
> Similarly, once the threads finish the execution to update the values of
> the variables with the correct values from the structure. Also, the loop
> code has to be modified to execute only the slice allocated to the
> thread. I did not go yet into further details on the private and shared
> variables between the threads and other OpenMP features.
I would also like to have such a pass. It is more complicated as the
code in Polly right now, but most probably worth the effort.
> As far as I know this code is not yet available in LLVM. Do you think
> the parallel code generation of Polly can be adapted to perform this?
Yes and No. I think we should be able to extract the generic functions
to build the new OpenMP loop structure, the parameter structures and the
function calls. With those we could create an OpenMPBuilder as we today
have an LLVM-IR builder.
Based on this, building a pass that translates a regular LLVM-IR loop
into a OpenMP parallelized one should not be too difficult. (Especially,
as you perform speculative parallelization and you do not need any
> work is not focused on adding OpenMP support in LLVM, but I was looking
> for codes that already enable parallelism in the LLVM IR. Surely, if
> necessary I will work on building the code and inserting calls to the
> gomp library, to parallelize regular loops. In that case, we can discuss
> the best approach to stay general and to meet all our requirements.
Yes, I assume there is no finished solution available. Though, I am
interested in work to get one.
More information about the llvm-dev