clang-omp / clang

clang with OpenMP 3.1 and some elements of OpenMP 4.0 support
clang-omp.github.com
Other
91 stars 15 forks source link

Not setting _OPENMP? #43

Closed ghost closed 9 years ago

ghost commented 9 years ago

clang-omp doesn't seem to be defining _OPENMP with -fopenmp on the command line. Is this expected?

Source code used to produce, "chokes" with -fopenmp, but does not choke if -D_OPENMP is also given on the command line:

ifndef _OPENMP

choke me

endif

include

int main () { return omp_get_num_threads (); }

Example:

/usr/local/bin/clang-3.5omp -fopenmp -I/usr/local/include/openmp -o conftest ./conf_omp_test.c ./conf_omp_test.c:2:4: error: unknown type name 'choke' choke me ^ ./conf_omp_test.c:2:12: error: expected ';' after top level declarator choke me ^ ; 2 errors generated. /usr/local/bin/clang-3.5omp -fopenmp -I/usr/local/include/openmp -D_OPENMP -o conftest ./conf_omp_test.c

alexey-bataev commented 9 years ago

Hello, that's very strange, because actually it must be defined. And I could not reproduce this problem. Could provide some more details about your system and build settings for clang/LLVM?

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

28.09.2014 23:23, justsomeone1001 пишет:

clang-omp doesn't seem to be defining _OPENMP with -fopenmp on the command line. Is this expected?

Source code used to produce, "chokes" with -fopenmp, but does not choke if -D_OPENMP is also given on the command line:

ifndef _OPENMP

choke me

endif

include

int main () { return omp_get_num_threads (); }

Example:

/usr/local/bin/clang-3.5omp -fopenmp -I/usr/local/include/openmp
-o conftest ./conf_omp_test.c
./conf_omp_test.c:2:4: error: unknown type name 'choke'
choke me
^
./conf_omp_test.c:2:12: error: expected ';' after top level declarator
choke me
^
;
2 errors generated.
/usr/local/bin/clang-3.5omp -fopenmp -I/usr/local/include/openmp
-D_OPENMP -o conftest ./conf_omp_test.c

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43.

ghost commented 9 years ago

What detail are you looking for in particular?

alexey-bataev commented 9 years ago

Your OS and build settings for clang/LLVM

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

29.09.2014 8:47, justsomeone1001 пишет:

What detail are you looking for in particular?

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43#issuecomment-57116569.

ghost commented 9 years ago

Its Mac OS X 10.9.4 (Darwin 13.4). Regarding build settings, I need you to be more specific - are you asking for the content of a specific file, for the output of a command, for a log...?

alexey-bataev commented 9 years ago

I just need you command line for configure script or cmake

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

29.09.2014 9:34, justsomeone1001 пишет:

Its Mac OS X 10.9.4 (Darwin 13.4). Regarding build settings, I need you to be more specific - are you asking for the content of a specific file, for the output of a command, for a log...?

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43#issuecomment-57118582.

ghost commented 9 years ago

I'm afraid that's no longer possible; I've been trying to rebuild llvm to have polly built-in, so the contents of the build directory have changed. I can try to recreate the error and send you the configuration then, once (if) the new build succeeds, which so far it has not.

alexey-bataev commented 9 years ago

Ok

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

29.09.2014 10:28, justsomeone1001 пишет:

I'm afraid that's no longer possible; I've been trying to rebuild llvm to have polly built-in, so the contents of the build directory have changed. I can try to recreate the error and send you the configuration then, once (if) the new build succeeds, which so far it has not.

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43#issuecomment-57121341.

rmjarvis commented 8 years ago

Was this closed because it was thought to be fixed? Or because Alexey never replied with more information? I'm still getting this on OSX 10.9.5 with clang 3.6. I'm using the fink version of clang36:

$ uname -a
Darwin Fife 13.4.0 Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64 x86_64
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.9.5
BuildVersion:   13F1096
$ clang-3.6 --version
clang version 3.6.2 (tags/RELEASE_362/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
$ which clang-3.6
/sw/bin/clang-3.6
$ fink list clang36
Information about 12162 packages read in 2 seconds.
 i   clang36              3.6.2-2         Executables and runtime for clang compiler
     clang36-dev          3.6.2-2         Development headers for clang API
     clang36-docs         3.6.2-2         Documenation for clang and related tools
 i   clang36-shlibs       3.6.2-2         Shared libraries for clang compiler
     clang36-tools        3.6.2-2         Extra tools for clang, such as formatting
$ cat junk.c
#ifndef _OPENMP
choke me
#endif
#include "omp.h"
int main () { return omp_get_num_threads (); }
$ clang-3.6 -fopenmp junk.c -v
clang version 3.6.2 (tags/RELEASE_362/final)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
 "/sw/opt/llvm-3.6/bin/clang-3.6" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name junk.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -dwarf-column-info -resource-dir /sw/opt/llvm-3.6/bin/../lib/clang/3.6.2 -fdebug-compilation-dir /Users/Mike/TreeCorr -ferror-limit 19 -fmessage-length 100 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/h8/0h3_h20d4jdg8pk8fzwxmr380000gn/T/junk-0f98cf.o -x c junk.c
clang -cc1 version 3.6.2 based upon LLVM 3.6.2 default target x86_64-apple-darwin13.4.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /sw/opt/llvm-3.6/bin/../lib/clang/3.6.2/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
junk.c:2:1: error: unknown type name 'choke'
choke me
^
junk.c:4:10: fatal error: 'omp.h' file not found
#include "omp.h"
         ^
2 errors generated.

I looked at the fink output when it built clang-3.6, and I couldn't find any configure command. The only semi-relevant thing I could find in the output was

# projects/test-suite expects built llvm/clang to have been configured
# but sadly, we used cmake; don't include $llvmobjdir/Makefile.config
# TODO: replace cmake build with autoconf'd build

That doesn't seem helpful though.

Also, it doesn't seem like clang has the omp.h file installed anywhere useful. Is this supposed to be installed somewhere in the /sw/ directory tree? It looks like it's just relying on /usr/include to have all the relevant include files, which doesn't seem right to me. (Especially since there is no omp.h there.)

Please let me know if there is any more information you need to help diagnose this problem. And thanks in advance for your help. I'd really like to start being able to use OpenMP with clang. I've been waiting patiently for this feature for several years, and now that it's supposedly here, I'm frustrated to not be able to get it to work.

alexey-bataev commented 8 years ago

Clang 3.6.2 does not support OpenMP. Moreover, even 3.7.0, that supports OpenMP 3.1 and some elements of OpenMP 4.0, uses -fopenmp=libomp option to turn on OpenMP support, not -fopenmp.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

28.09.2015 8:00, Mike Jarvis пишет:

Was this closed because it was thought to be fixed? Or because Alexey never replied with more information? I'm still getting this on OSX 10.9.5 with clang 3.6. I'm using the fink version of clang36:

|$ uname -a Darwin Fife 13.4.0 Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64 x86_64 $ sw_vers ProductName: Mac OS X ProductVersion: 10.9.5 BuildVersion: 13F1096 $ clang-3.6 --version clang version 3.6.2 (tags/RELEASE_362/final) Target: x86_64-apple-darwin13.4.0 Thread model: posix $ which clang-3.6 /sw/bin/clang-3.6 $ fink list clang36 Information about 12162 packages read in 2 seconds. i clang36 3.6.2-2 Executables and runtime for clang compiler clang36-dev 3.6.2-2 Development headers for clang API clang36-docs 3.6.2-2 Documenation for clang and related tools i clang36-shlibs 3.6.2-2 Shared libraries for clang compiler clang36-tools 3.6.2-2 Extra tools for clang, such as formatting $ cat junk.c #ifndef _OPENMP choke me #endif #include "omp.h" int main () { return omp_get_num_threads (); } $ clang-3.6 -fopenmp junk.c -v clang version 3.6.2 (tags/RELEASE_362/final) Target: x86_64-apple-darwin13.4.0 Thread model: posix "/sw/opt/llvm-3.6/bin/clang-3.6" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name junk.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -dwarf-column-info -resource-dir /sw/opt/llvm-3.6/bin/../lib/clang/3.6.2 -fdebug-compilation-dir /Users/Mike/TreeCorr -ferror-limit 19 -fmessage-length 100 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/h8/0h3_h20d4jdg8pk8fzwxmr380000gn/T/junk-0f98cf.o -x c junk.c clang -cc1 version 3.6.2 based upon LLVM 3.6.2 default target x86_64-apple-darwin13.4.0 #include "..." search starts here: #include <...> search starts here: /usr/local/include /sw/opt/llvm-3.6/bin/../lib/clang/3.6.2/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. junk.c:2:1: error: unknown type name 'choke' choke me ^ junk.c:4:10: fatal error: 'omp.h' file not found #include "omp.h" ^ 2 errors generated. |

I looked at the fink output when it built clang-3.6, and I couldn't find any configure command. The only semi-relevant thing I could find in the output was

|# projects/test-suite expects built llvm/clang to have been configured

but sadly, we used cmake; don't include $llvmobjdir/Makefile.config

TODO: replace cmake build with autoconf'd build |

That doesn't seem helpful though.

Also, it doesn't seem like clang has the omp.h file installed anywhere useful. Is this supposed to be installed somewhere in the /sw/ directory tree? It looks like it's just relying on /usr/include to have all the relevant include files, which doesn't seem right to me. (Especially since there is no omp.h there.)

Please let me know if there is any more information you need to help diagnose this problem. And thanks in advance for your help. I'd really like to start being able to use OpenMP with clang. I've been waiting patiently for this feature for several years, and not that it's supposedly here, I'm frustrated to not be able to get it to work.

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43#issuecomment-143641682.

rmjarvis commented 8 years ago

I see. Thanks very much for the clarification. One of the top links when I search for "clang openmp" is this talk which seemed to imply that OpenMP support is already mostly in 3.5 and full OpenMP3.1 was supposed to be in 3.6.

But I see that the 3.6 release notes do indeed say that it didn't support it and I also see that fink has clang37, so I will check that out. Thanks! And my apologies for the bother.

alexey-bataev commented 8 years ago

No problems, glad could help you with your troubles.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

28.09.2015 8:49, Mike Jarvis пишет:

I see. Thanks very much for the clarification. One of the top links when I search for "clang openmp" is this talk http://llvm.org/devmtg/2014-10/Slides/Bataev-OpenMP.pdf which seemed to imply that OpenMP support is already mostly in 3.5 and full OpenMP3.1 was supposed to be in 3.6.

But I see that the 3.6 release notes http://llvm.org/releases/3.6.0/tools/clang/docs/ReleaseNotes.html do indeed say that it didn't support it and I also see that fink has clang37, so I will check that out. Thanks! And my apologies for the bother.

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43#issuecomment-143645716.

rmjarvis commented 8 years ago

Just a follow up to report that it does work with 3.7. (I didn't doubt you, but figured it was worth closing the loop on this thread.) Thanks again!

I just have one further question. It seems to work equivalently whether I use -fopenmp=libomp as you suggested (also here) or simply -fopenmp (as suggested here). So is there a difference between these two forms? Are there perhaps going to be other fopenmp options down the road?

alexey-bataev commented 8 years ago

Currently -fopenmp is disabled by default in clang. You need to use -fopenmp=libomp to be sure that you're using OpenMP. -fopenmp works only if you configured clang/LLVM with additional cmake option -DCLANG_DEFAULT_OPENMP_RUNTIME="libomp". In this case -fopenmp works the same way just like -fopenmp=libomp. You can also use -fopenmp=libiomp5, but in this case you must link Intel-supplied libiomp5.[so|dll|dyld] library (shipped with Intel compilers). This is done just in case if somebody would like to implement codegen with support of other OpenMP runtime libraries, like libgomp. Actually, currently -fopenmp is equal to -fopenmp=libgomp, but it does not produce OpenMP code, because there is no codegen for libgomp runtime. -fopenmp will be aliased to -fopenmp=libomp very-very soon, when the testing for libomp library will be set up.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

28.09.2015 17:20, Mike Jarvis пишет:

Just a follow up to report that it does work with 3.7. (I didn't doubt you, but figured it was worth closing the loop on this thread.) Thanks again!

I just have one further question. It seems to work equivalently whether I use |-fopenmp=libomp| as you suggested (also here http://llvm.org/releases/3.7.0/tools/clang/docs/ReleaseNotes.html#openmp-support) or simply |-fopenmp| (as suggested here http://blog.llvm.org/2015/05/openmp-support_22.html). So is there a difference between these two forms? Are there perhaps going to be other fopenmp options down the road?

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/43#issuecomment-143757030.

rmjarvis commented 8 years ago

I see. Thanks very much for this info. This is very helpful. Cheers.