-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 28919 |
| Version | trunk |
| OS | Linux |
| Attachments | File containing the CUDA kernel, Include surface_indirect_functions.h from __clang_cuda_runtime_wrapper.h, clang generated PTX file |
| Reporter | LLVM Bugzilla Contributor |
| CC | @jlebar,@Artem-B |
Extended Description
Hello,
I wanted to give clang a go on compiling my CUDA kernels. I was able to get the example at bit.ly/llvm-cuda to compile and run properly, but when I tried the attached code, I got the error message "error: use of undeclared identifier 'surf2Dwrite'".
Versions used:
- CUDA: 7.5
- clang: 3.8 and 63240447ac6e ("[analyzer] Try to fix coverity CID 1360469.")
- llvm: 3.8 and 04876e5 ("[X86][XOP] Add support for combining target shuffles to VPERMIL2PD/VPERMIL2PS")
The compilation command as well as the output look as follow (with both previously mentioned versions of clang+LLVM):
% clang++ -std=c++11 --cuda-path=/opt/cuda --cuda-gpu-arch=sm_30 -c surface.cu
surface.cu:15:3: error: use of undeclared identifier 'surf2Dwrite'
surf2Dwrite(make_float4(0.0f, 0.0f, 0.0f, 1.0f), result_surface, index.x * sizeof(float4), index.y);
^
1 error generated
If I include directly surface_indirect_functions.h which defines surf2Dwrite, then the program does compile (well, sort of depending on the clang version, but that looks like a different bug, so different bug report). Playing with the CUDA headers, I added some #error "foo" inside device_functions.h which is included by cuda_runtime.h, and in turns includes surface_indirect_functions.h: so one right after the #define __DEVICE_FUNCTIONS_H__, and another one (with a different message) in an else clause to the #ifdef __DEVICE_FUNCTIONS_H__.
To resume, this is how the modified device_functions.h looks like:
#ifndef __DEVICE_FUNCTIONS_H__
#define __DEVICE_FUNCTIONS_H__
#error "foo"
// [snip] untouched content
#else
#error "bar"
#endif // __DEVICE_FUNCTIONS_H__
And here is the corresponding compilation output with clang:
% clang++ -std=c++11 --cuda-path=/opt/cuda --cuda-gpu-arch=sm_30 -c surface.cu
In file included from <built-in>:1:
In file included from /home/pmoreau/privat/userspace/llvm/bin/../lib/clang/4.0.0/include/__clang_cuda_runtime_wrapper.h:98:
In file included from /opt/cuda/include/cuda_runtime.h:115:
/opt/cuda/include/device_functions.h:4247:2: error: "bar"
#error "bar"
^
In file included from <built-in>:1:
In file included from /home/pmoreau/privat/userspace/llvm/bin/../lib/clang/4.0.0/include/__clang_cuda_runtime_wrapper.h:156:
In file included from /opt/cuda/include/math_functions.hpp:1065:
/opt/cuda/include/device_functions.h:4247:2: error: "bar"
#error "bar"
^
2 errors generated.
Apparently __DEVICE_FUNCTIONS_H__ is getting defined by another file since we do not get an error: "foo".
Thank you in advance!
Pierre