[llvm-dev] [RFC] Abstract Parallel IR Optimizations
Roger Ferrer Ibáñez via llvm-dev
llvm-dev at lists.llvm.org
Tue Jun 12 04:56:52 PDT 2018
apologies in advance if the questions following are silly or don't
make sense. I lack a bit of context here and I'm not sure to fully
understand your proposal.
Currently clang (and flang) are lowering OpenMP when building LLVM IR
(this is because LLVM IR can't express the parallel/concurrent
concepts of OpenMP so they have to be lowered first). So, can I assume
that your proposal starts off in a context where that lowering is not
happening anymore in the front end but it'd happen later in a LLVM IR
pass? If so, then you'd be assuming that there is already a way of
representing OpenMP constructs in the LLVM IR, is my understanding
correct here? I think that the Intel proposal  could be one way
(not necessarily the one) to do this (disregarding the fact that it is
tailored for OpenMP), does this still make sense?
If this is the case, and given that you explicitly state that this is
not a Parallel IR of any sort, is your suggestion to improve
optimisation of OpenMP code, based on a "side-car"/ancillary
representation built on top of the existing IR, which as I understand
should already be able to represent OpenMP? But then this looks a bit
redundant to me. So I'm pretty sure one of my assumptions is
incorrect. Unless your auxiliar representation is more an alternative
to the W-regions .
Or, maybe I am completely wrong here: you didn't say anything about
the FE lowering, which would still happen, and then your proposal
builds on top of that. I don't think you meant that, given that your
proposal mentions KMP and GOMP (and the current lowering done by clang
targets only KMP).
Thank you very much,
2018-06-07 12:25 GMT+02:00 Johannes Doerfert via llvm-dev
<llvm-dev at lists.llvm.org>:
> This is an RFC to add analyses and transformation passes into LLVM to
> optimize programs based on an abstract notion of a parallel region.
> == this is _not_ a proposal to add a new encoding of parallelism ==
> We currently perform poorly when it comes to optimizations for parallel
> codes. In fact, parallelizing your loops might actually prevent various
> optimizations that would have been applied otherwise. One solution to
> this problem is to teach the compiler about the semantics of the used
> parallel representation. While this sounds tedious at first, it turns
> out that we can perform key optimizations with reasonable implementation
> effort (and thereby also reasonable maintenance costs). However, we have
> various parallel representations that are already in use (KMPC,
> GOMP, CILK runtime, ...) or proposed (Tapir, IntelPIR, ...).
> Our proposal seeks to introduce parallelism specific optimizations for
> multiple representations while minimizing the implementation overhead.
> This is done through an abstract notion of a parallel region which hides
> the actual representation from the analysis and optimization passes. In
> the schemata below, our current five optimizations (described in detail
> here ) are shown on the left, the abstract parallel IR interface is
> is in the middle, and the representation specific implementations is on
> the right.
> Optimization (A)nalysis/(T)ransformation Impl.
> CodePlacementOpt \ /---> ParallelRegionInfo (A) ---------|-> KMPCImpl (A)
> RegionExpander -\ | | GOMPImpl (A)
> AttributeAnnotator -|-|---> ParallelCommunicationInfo (A) --/ ...
> BarrierElimination -/ |
> VariablePrivatization / \---> ParallelIR/Builder (T) -----------> KMPCImpl (T)
> In our setting, a parallel region can be an outlined function called
> through a runtime library but also a fork-join/attach-reattach region
> embedded in an otherwise sequential code. The new optimizations will
> provide parallelism specific optimizations to all of them (if
> applicable). There are various reasons why we believe this is a
> worthwhile effort that belongs into the LLVM codebase, including:
> 1) We improve the performance of parallel programs, today.
> 2) It serves as a meaningful baseline for future discussions on
> (optimized) parallel representations.
> 3) It allows to determine the pros and cons of the different schemes
> when it comes to actual optimizations and inputs.
> 4) It helps to identify problems that might arise once we start to
> transform parallel programs but _before_ we commit to a specific
> Our prototypes for the OpenMP KMPC library (used by clang) already shows
> significant speedups for various benchmarks . It also exposed a (to
> me) prior unknown problem between restrict/noalias pointers and
> (potential) barriers (see Section 3 in ).
> We are currently in the process of cleaning the code, extending the
> support for OpenMP constructs and adding a second implementation for a
> embedded parallel regions. Though, a first horizontal prototype
> implementation is already available for review .
> Inputs of any kind are welcome and reviewers are needed!
>  http://compilers.cs.uni-saarland.de/people/doerfert/par_opt18.pdf
>  https://reviews.llvm.org/D47300
> Sorry if you received this message multiple times!
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
Roger Ferrer Ibáñez
More information about the llvm-dev