[LLVMdev] multi-threading in llvm

Vlad Krylov krvladislav at gmail.com
Sun Jan 15 18:04:55 PST 2012


I am interested. I would be grateful for your hints.

So OpenMP has various constructs such as parallel, barrier, single,
for, etc. And there is at least two libraries to generate OpenMP code:
libgomp and mpc. We want to be independent of specific library.

We should create an interface with methods which present manual
inserting of OpenMP pragmas in C or Fortran code. These sounds like
"this code block should be run with #parallel" or "this for loop
should be run with #parallel for loop". Constructs like barrier,
atomic can be simply presented by methods 'barrier' and 'atomic'. But
parallel or for constructs allows many modifiers (schedule, private,
shared, etc). Сan not devise a good solution for these cases.

Guess this interface is close to IRBuilder. You suggested it will be
OpenMPBuilder. This mean IR will be created from scratch. Other way is
to provide methods to modify existing IR, like user says "I want this
loop to be parallel, do it for me". What you think about this?

Implementation is calls of OpenMP library functions in a way provided
by the library abi. For example, in mpc:

   pragma omp for schedule(runtime)
   for ( i=lb ; i COND b ; i+=incr ) { A ; }
   ->
   if ( __mpcomp_runtime_loop_begin( ... ) ) {
     do {
       for ( ... ) {
         A ;
       }
     } while ( __mpcomp_runtime_loop_next( ... ) ) ;
   }
   __mpcomp_runtime_loop_end() ;


I think this work is not simple for me, so any comments are welcomed.


2012/1/7 Tobias Grosser <tobias at grosser.es>:
> On 01/07/2012 12:38 AM, Vlad Krylov wrote:
>>
>> Hi,
>>
>> It was proposed to implement OpenMP framework.
>> Is there any progress in this area? Was the question raised at the
>> Euro-LLVM? Does anybody work on implementation?
>
>
> I am not aware of any work that was done or is planned to be done in public.
>
> At Euro-LLVM I had a short discussion with Alexandra about targeting the
> OpenMP run time. We would both be interested in code that can translate
> normal LLVM-IR loops in OpenMP parallel loops. I am not sure,
> if Alexandra has some code that she can share. I for myself looked into
> the problem. I believe the loop extractor is a good start to implement such
> functionality. Yet, I do not have any written code ready.
>
> Do you happen to be interested to work on this? ;-) I can definitely give
> you some hints.
>
> Cheers
> Tobi




More information about the llvm-dev mailing list