[LLVMdev] Modifying LoopUnrollingPass

Renato Golin renato.golin at linaro.org
Fri May 8 13:08:04 PDT 2015


On 8 May 2015 at 19:12, yaduveer singh <yaduveer99 at gmail.com> wrote:
> 1) Use all cores, dividing the loop into multiple cores, one block at
> a time. But I don't want to use "OpenMP" for this.

Right, that is *exactly* what OpenMP does, I'm not sure why you don't
want to use it.

Just unrolling the loops will not get you multi-threaded behaviour,
nor will vectorizing the loops. You need a thread library and OpenMP
provides you one. You could also use pthreads or MPI, but not without
changing the source code a lot more than OpenMP, and with the same
amount work to get the libraries working.


> I don't want the user to mention OpenMP command in the program but I want to
> implement OpenMP logic by writing a new pass along with loop unrolling.

This doesn't make sense. Implementing OpenMP logic in the loop
unroller to avoid users knowing about OpenMP will never be accepted
upstream, and honestly, it's the wrong place for doing this, as you
*will* need run-time libraries as well as heavy IR transformations
that are already implemented.


> Could you please suggest how can I proceed with this? Is this possible to do
> so ?

Why not hide OpenMP command line options and pragmas from the user by
doing source-to-source transformation in Clang?

First, get Clang's AST for a loop with and without OpenMP information,
then detect the loops you want to split and add the metadata to the
AST before lowering to IR.

This way, the whole work will be done by the already existing OpenMP
implementation and run-time libraries, and the validation will be done
by the compiler in the same way, so unless you don't use SIMD pragmas
in the wrong way, you should be ok. No user will need to define OpenMP
when they use your front-end wrapper.

cheers,
--renato



More information about the llvm-dev mailing list