[LLVMdev] LLVM Parallel IR
tgrosser at inf.ethz.ch
Mon Mar 9 10:30:16 PDT 2015
On 09.03.2015 16:58, William Moses wrote:
> I'm part of a research group at MIT looking to create an extension of
> LLVM that inherently allows one to nicely code a parallel loop.
> Most parallel frameworks tend to take the body of a parallel loop and
> stick it inside of a function for the parallel runtime to call when
> appropriate. However, this makes optimizations significantly more
> difficult as most compiler optimizations tend to be intraprocedural. The
> goal of this parallel IR is to allow LLVM to more easily optimize
> parallel code -- which often gets the short end of the optimization stick.
> Long story short: I was wondering if anyone in the LLVM community has
> already begun a similar project or knows of something that begins to
> accomplish this.
> Additionally, does anyone who has worked with parallelism in LLVM have
> any specific comments or suggestions regarding this project.
this sounds like a very interesting idea, but it also is not an easy
You may probably want to have a look into how LLVM models parallel loops
using the loop.parallel metadata. At the time when this metadata was
introduced (see archives), we had a longer debate on how to model
parallelism. First ideas suggested to just add metadata flag to the loop
header to indicate that the loop is parallel. However, the problem with
such an approach is that scalar transformations might introduce memory
operations that destroy parallelism. As they have commonly no idea about
loop level metadata, the metadata needs to be designed in a way that
newly introduced scalar dependences automatically invalidate the loop
There were also relevant discussions at the time when LLVM's OpenMP
support was introduced. People considered to use some kind of
parallelism metadata and to only, at IR level, introduce the openmp
runtime calls. The hope was to be able to perform useful optimizations
at IR level. If my memories are right, one of the critical issues
(besides other engineering considerations) was that parallelism metadata
in LLVM is optional and can always be dropped. However, for
OpenMP it sometimes is incorrect to execute a loop sequential that has
been marked parallel in the source code.
More information about the llvm-dev