[LLVMdev] OpenMP support for LLVM

Sanjoy Das sanjoy at playingwithpointers.com
Wed Jan 18 02:15:09 PST 2012


Hi all,

I'd like to put in some effort into this too -- perhaps I can write an
backend for libgomp while someone else works on a libmpc one.

As far as the architecture is concerned, I concur with what has
already been discussed: mapping OpenMP constructs to LLVM intrinsics.
I think it would make sense to leave out intrinsics for things like
"parallel for", "parallel sections", which are essentially syntactic
sugar.

One way to denote a structured block could be by nesting it within two
intrinsics like

llvm.openmp.parallel_begin (llvm.openmp.clause_if(%1) <and so forth>)
  body
llvm.openmp.parallel_end()

or we could pass in an end label to parallel_begin (we can then call
it parallel instead of parallel_begin).  I'm not sure which one is the
better idea.  There will have to be restrictions on the body, of
course.  We can't allow control to jump outside body without
encountering the barrier, for instance.

The more difficult problem would be, I think, to lift the structured
block and create a function out of it that takes a closure.

I also think there is potential for optimizing things like the
reduction clause and the atomic construct by lowering them directly
into CAS or other machine instructions.  But I'll stop here before I
get ahead of myself. :)

Thanks!
-- 
Sanjoy Das
http://playingwithpointers.com



More information about the llvm-dev mailing list