Problem in setting number of threads while using clang with openmp


I am using the clang provided by polly(which is version 3.7) in association with openmp shared library(

Ultimately, I have to run clang with polly on multiple threads. So, I tried to compile a simple program with #pragma parallel. But I could not create more than one thread. This was because libgomp was getting linked instead of libomp.

So, as suggested on, I downloaded the clang-omp version and following the directions as in

…/build/bin/clang-3.5 -fopenmp -L/home/rajat/lulesh/openmp/runtime/exports/lin_32e/lib/ -I/home/rajat/lulesh/openmp/runtime/exports/common/include try.c

But, this gives segmentation fault with #pragma omp parallel.

Can you help me out in this.


Hi Rajat,

OpenMP 3.1 is fully upstreamed to clang / llvm trunk, so it is better
to use trunk version (unless you have a really good reason to prefer
one hosted on clang-omp.github).

Instructions are posted on llvm blog:
OpenMP Support - The LLVM Project Blog. The only
difference is that instead of "-fopenmp" you should use
"-fopenmp=libomp" (this is temporary and will be fixed, but here we

As for the segmentation fault you got, please try trunk version of the
compiler and if problem won't go away, provide more details: HW and OS
you use, how exactly you built clang, what's inside try.c, etc.

Andrey Bokhanko


Thanks a lot for mentioning “-fopenmp=libomp”. This works perfectly fine. Maybe you should should mention this on I have been dealing with this for last two days.




Glad this helped.

As for mentioning "-fopenmp=libomp", today we got one step closer for
making libomp the default value. So maybe it will go for good soon?


Hi Andrey,

This helped but this is not working with polly. If I don’t include the “-fopenmp=libomp”, then polly is able to do its specified optimizations, but if I include this flag, I cannot use polly anymore.

I found something-: which mentions using clang-omp with polly. But, I am not sure.

Can you guys help in this?



Hi Rajat,

for obvious reasons it would be best if you could provide a minimal test case.

Here at least a first guess: if you enable -fopenmp, clang will already outline the parts marked 'omp parallel' into openmp runtime calls. Polly does currently not see of look into such calls and consequently is not able to modify/transform this code.

There is however some recent work that uses Polly to further optimize OpenMP parallel programs:

This is a first workshop version, but there may also be a conference version of this paper be published.