[llvm-bugs] [Bug 31239] New: _OPENMP is not defined when compiling for CUDA
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Dec 2 11:24:05 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31239
Bug ID: 31239
Summary: _OPENMP is not defined when compiling for CUDA
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: CUDA
Assignee: unassignedclangbugs at nondot.org
Reporter: crtrott at sandia.gov
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
This occurs in a similar situation as reported in bug 23492.
Basically when compiling with CUDA support the _OPENMP macro is only set in the
host compilation phase but not when __CUDA_ARCH__ is defined.
This leads to incomplete type issues in our code. We are NOT trying to use
OpenMP in any device or host device function. We are also not using any OpenMP
target stuff. This is just trying to use OpenMP3 and Cuda in the same object
file.
NVCC has _OPENMP defined in both compilation phases.
Small reproducer:
<<<<
#include<cstdio>
int main() {
#ifdef _OPENMP
#ifdef __CUDA_ARCH__
#warning "OPENMP CUDA_ARCH"
#else
#warning "OPENMP"
#endif
#else
#ifdef __CUDA_ARCH__
#warning "DOH CUDA_ARCH"
#else
#warning "DOH"
#endif
#endif
}
<<<
Output with NVCC:
nvcc -Xcompiler -fopenmp -x cu -c main.cpp
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are
deprecated, and may be removed in a future release (Use
-Wno-deprecated-gpu-targets to suppress warning).
main.cpp:6:4: warning: #warning "OPENMP CUDA_ARCH" [-Wcpp]
#warning "OPENMP CUDA_ARCH"
^
main.cpp:8:4: warning: #warning "OPENMP" [-Wcpp]
#warning "OPENMP"
^
[crtrott at apollo BugOMPClang]$ nvcc -Xcompiler -fopenmp -x cu -c main.cpp
-arch=sm_35
main.cpp:6:4: warning: #warning "OPENMP CUDA_ARCH" [-Wcpp]
#warning "OPENMP CUDA_ARCH"
^
main.cpp:8:4: warning: #warning "OPENMP" [-Wcpp]
#warning "OPENMP"
^
Output with Clang:
/home/projects/x86-64/clang/head/bin/clang++ -x cuda --cuda-gpu-arch=sm_35
-fopenmp=libomp
--gcc-toolchain=/projects/sems/install/rhel6-x86_64/sems/compiler/gcc/5.3.0/base
-c main.cpp
main.cpp:12:4: warning: "DOH CUDA_ARCH" [-W#warnings]
#warning "DOH CUDA_ARCH"
^
1 warning generated.
main.cpp:8:4: warning: "OPENMP" [-W#warnings]
#warning "OPENMP"
^
1 warning generated.
This was with
Clang: 61a39e4b5bf70f40db70d51f71948a66e567c559
LLVM: 6f185f662a9dc692c12417784c9756bc3212cde8
checked out from github.com/llvm-mirror
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161202/6d66b388/attachment.html>
More information about the llvm-bugs
mailing list