cuda-samples
cuda-samples copied to clipboard
Unable to build OpenMP examples with Clang 13
While using clang 13.0.0 (here AOCC, but it was confirmed that clang 13 in general produces this bug) as Host-Compiler for the samples, the build process terminates with the following error in any OpenMP related example:
/opt/AMD/aocc-compiler-3.2.0/lib/clang/13.0.0/include/omp.h(488): error: function "omp_is_initial_device" has already been defined
Affected Samples:
- Samples/0_Introduction/cudaOpenMP
- Samples/0_Introduction/UnifiedMemoryStreams
Solution: The Bug is present, when using OpenMP 5.0 in clang (which is the default in 13.0.0). When the OpenMP version is lowered to 4.5 (e.g. with -Xcompliler -fopenmp-version=45) the examples are compiled as expected.
I am currently working on incorporating the changes to the corresponding Makefiles and will create a PR soon.
I'm running into this issue when compiling magma 2.6.2
with cuda 11.7
and icx/icpx
compilers
after a quick investigation, it's the way this function is declared for version of openmp >=5
a simple fix is to add in the omp.h file a condition to not declare this function again, something like that for me:
- first to a copy of your omp.h file before you destroy it :)
- use
sed -i '492s/$/ \&\& !defined(__NVCC__)/' /opt/intel/oneapi/compiler/2023.0.0/linux/bin-llvm/../compiler/include/omp.h
for me I add the condition at the line 492, the error was at line 497, so it looks to be always 5 before, if you had the error at 488 use sed -i '483s/$/ \&\& !defined(__NVCC__)/' /path/to/your/omp.h
and so on