[LLVMdev] multi-threading in llvm

Jimborean Alexandra xinfinity_a at yahoo.com
Mon Sep 12 09:28:03 PDT 2011

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.

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. 

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? My 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.


From: Tobias Grosser <tobias at grosser.es>
To: Sebastian Pop <sebpop at gmail.com>
Cc: Jimborean Alexandra <xinfinity_a at yahoo.com>; "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu>; polly-dev at googlegroups.com
Sent: Monday, September 12, 2011 5:44 PM
Subject: Re: [LLVMdev] multi-threading in llvm

On 09/12/2011 04:28 PM, Sebastian Pop wrote:
> Hi Alexandra,
> On Thu, Sep 8, 2011 at 13:53, Jimborean Alexandra<xinfinity_a at yahoo.com>  wrote:
>> 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?
> Yes.  If you don't want to use the autopar of Polly and just rely on
> the pragmas inserted by the programmer, you don't need SCoPs.
> You can have the parallel code generation part of Polly working as
> a LoopPass.
Are you sure about this? In CodeGeneration we basically translate a CLooG AST into LLVM-IR. Without a CLooG AST this does not work.

> If you want to use the auto-parallelization part of Polly, you have to
> to restrict the form of the code on which data dependences can be
> computed: this is done by using SCoPs (Static Control Parts).

In Polly we just generate OpenMP calls, if we need them. We do not provide a generic OpenMP infrastructure (Something nice to have in LLVM and where I would love to contribute). However, such a generic infrastructure has a broader SCoP than the single specific OpenMP pattern we implemented in Polly.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110912/3ed4a2c8/attachment.html>

More information about the llvm-dev mailing list