Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

c++ - Using OpenMP with clang

I have problems compiling OpenMP code using clang (both 3.6 and 3.8 ToT).

I followed this blog post http://blog.llvm.org/2015/05/openmp-support_22.html , but the problem is that the compiled program is executed on a one thread only. I'm using ubuntu 15.04 x64, I have both libgomp and libiopmp installed and I compile my code with the following command:

clang test.c -o test -fopenmp -L/usr/lib/gcc/x86_64-linux-gnu/5.1.1

When I use gcc instead, everything works fine: gcc test.c -o test -fopenmp

I also tried running export LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5.1.1:$LD_LIBRARY_PATH but it didn't help. `

Any suggestions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Some additional comments:

1) You need to use -fopenmp=libomp to enable OpenMP in clang. -fopenmp just links libgomp but ignores all the pragmas. Weird, I know -- and will be changed in the trunk soon.

2) 3.7 is the first version that supports OpenMP. 3.6 doesn't.

3) clang is only able to work with libomp. Don't put libgomp (headers or the library) in the way of libomp! clang uses Intel API, not supported by libgomp. -fopenmp=libomp should link correct library.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...