[cfe-dev] Error while running libtooling based tool on CUDA code

Justin Lebar via cfe-dev cfe-dev at lists.llvm.org
Mon Jun 3 22:38:40 PDT 2019


I suspect that the tools are not invoking clang correctly, but I don't know
more, there is not enough information given here to say, and I am not
familiar with these tools.

Since this is not a bug in clang, I would recommend speaking with the tool
developers.  If you want to debug yourself I'd try getting a working CUDA
compilation with regular clang and running that with -v.  You will see the
flags passed to clang -cc1.  Then you can compare those flags to what the
tool is doing.

On Mon, Jun 3, 2019 at 10:34 PM Pradeep Kumar <pradeepisro49 at gmail.com>
wrote:

> Now I get different error for each of the flags
> *1. --cuda-host-only*
>
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:53:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_tid_x'
>   __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_tid_x());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:54:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_tid_y'
>   __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_tid_y());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:55:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_tid_z'
>   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_tid_z());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:64:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_ctaid_x'
>   __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_ctaid_x());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:65:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_ctaid_y'
>   __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_ctaid_y());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:66:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_ctaid_z'
>   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ctaid_z());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:75:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_ntid_x'
>   __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_ntid_x());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:76:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_ntid_y'
>   __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_ntid_y());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:77:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_ntid_z'
>   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ntid_z());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:86:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_nctaid_x'
>   __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_nctaid_x());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:87:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_nctaid_y'
>   __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_nctaid_y());
>                           ^
> /usr/include/clang/9.0.0/include/__clang_cuda_builtin_vars.h:88:27: error:
> use of undeclared identifier '__nvvm_read_ptx_sreg_nctaid_z'
>   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_nctaid_z());
>                           ^
> In file included from <built-in>:1:
> In file included from
> /usr/include/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:148:
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:49:40:
> error: use of undeclared identifier '__nvvm_vote_all'
> __DEVICE__ int __all(int __a) { return __nvvm_vote_all(__a); }
>                                        ^
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:50:40:
> error: use of undeclared identifier '__nvvm_vote_any'
> __DEVICE__ int __any(int __a) { return __nvvm_vote_any(__a); }
>                                        ^
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:51:52:
> error: use of undeclared identifier '__nvvm_vote_ballot'
> __DEVICE__ unsigned int __ballot(int __a) { return
> __nvvm_vote_ballot(__a); }
>                                                    ^
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:71:10:
> error: use of undeclared identifier '__nvvm_atom_add_gen_d'
>   return __nvvm_atom_add_gen_d(__p, __v);
>          ^
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:74:10:
> error: use of undeclared identifier '__nvvm_atom_cta_add_gen_d'
>   return __nvvm_atom_cta_add_gen_d(__p, __v);
>          ^
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:77:10:
> error: use of undeclared identifier '__nvvm_atom_sys_add_gen_d'
>   return __nvvm_atom_sys_add_gen_d(__p, __v);
>          ^
> /usr/include/clang/9.0.0/include/__clang_cuda_device_functions.h:195:10:
> error: use of undeclared identifier '__nvvm_atom_add_gen_f'
>   return __nvvm_atom_add_gen_f(__p, __v);
>
> *2. --cuda-device-only*
>
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:845:35:
> error: use of undeclared identifier 'FP_NAN'
>       return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
>                                   ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:845:43:
> error: use of undeclared identifier 'FP_INFINITE'
>       return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
>                                           ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:845:56:
> error: use of undeclared identifier 'FP_NORMAL'
>       return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
>                                                        ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:846:7:
> error: use of undeclared identifier 'FP_SUBNORMAL'
>                                   FP_SUBNORMAL, FP_ZERO, __type(__f));
>                                   ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cmath:846:21:
> error: use of undeclared identifier 'FP_ZERO'
>                                   FP_SUBNORMAL, FP_ZERO, __type(__f));
>                                                 ^
> In file included from <built-in>:1:
> In file included from
> /usr/include/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:37:
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:200:11:
> error: no member named 'lldiv_t' in the global namespace; did you mean
> 'ldiv_t'?
>   using ::lldiv_t;
>         ~~^
> /usr/include/stdlib.h:109:5: note: 'ldiv_t' declared here
>   } ldiv_t;
>     ^
> In file included from <built-in>:1:
> In file included from
> /usr/include/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:37:
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:206:11:
> error: no member named '_Exit' in the global namespace
>   using ::_Exit;
>         ~~^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:212:10:
> error: unknown type name 'lldiv_t'; did you mean 'ldiv_t'?
>   inline lldiv_t
>          ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:200:11:
> note: 'ldiv_t' declared here
>   using ::lldiv_t;
>           ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:214:5:
> error: unknown type name 'lldiv_t'; did you mean 'ldiv_t'?
>   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
>     ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:200:11:
> note: 'ldiv_t' declared here
>   using ::lldiv_t;
>           ^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:216:11:
> error: no member named 'lldiv' in the global namespace; did you mean 'ldiv'?
>   using ::lldiv;
>         ~~^
> /usr/include/stdlib.h:790:15: note: 'ldiv' declared here
> extern ldiv_t ldiv (long int __numer, long int __denom)
>               ^
> In file included from <built-in>:1:
> In file included from
> /usr/include/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:37:
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:227:11:
> error: no member named 'atoll' in the global namespace; did you mean 'atol'?
>   using ::atoll;
>         ~~^
> /usr/include/stdlib.h:150:17: note: 'atol' declared here
> extern long int atol (const char *__nptr)
>                 ^
> In file included from <built-in>:1:
> In file included from
> /usr/include/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:37:
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:228:11:
> error: no member named 'strtoll' in the global namespace
>   using ::strtoll;
>         ~~^
> /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdlib:229:11:
> error: no member named 'strtoull' in the global namespace; did you mean
> 'strtoul'?
>   using ::strtoull;
>
>
> can you please let me know why it is happening.
>
> Regards,
> Pradeep
>
> On Tue, Jun 4, 2019 at 10:52 AM Justin Lebar <jlebar at google.com> wrote:
>
>> > But the unable to handle compilation, expected exactly one compiler job
>> still exists.
>>
>> This is a new error that I don't see in the original email.  Luckily I
>> know the error you're referring to.  You will need --cuda-device-only or
>> --cuda-host-only.
>>
>> On Mon, Jun 3, 2019 at 10:04 PM Pradeep Kumar <pradeepisro49 at gmail.com>
>> wrote:
>>
>>> Dear Justin,
>>>     clang-query also results in the same error. I removed the one with
>>> no sm_20 by passing cuda-gpu-arch=sm_50 flag. But the unable to handle
>>> compilation, expected exactly one compiler job still exists. I think it is
>>> because of the dual mode compilation in clang. There are more than two
>>> commands in the error string.
>>>
>>> Regards,
>>> Pradeep
>>>
>>> On Mon, Jun 3, 2019 at 9:22 PM Justin Lebar <jlebar at google.com> wrote:
>>>
>>>> > GPU arch sm_20 is supported by CUDA versions between 7.0 and 8.0
>>>> (inclusive), but installation at /usr/local/cuda is 9.0.  Use --cuda-path
>>>> to specify a different CUDA install, pass a different GPU arch with
>>>> --cuda-gpu-arch, or pass --no-cuda-version-check.
>>>>
>>>> The error seems pretty clear to me?
>>>>
>>>> You will need to figure out how to get the tool to pass these flags to
>>>> clang.  That's a question for the tool's author, not for this mailing list.
>>>>
>>>> On Mon, Jun 3, 2019 at 1:22 AM Pradeep Kumar via cfe-dev <
>>>> cfe-dev at lists.llvm.org> wrote:
>>>>
>>>>> Dear clang-developer-community,
>>>>>    I get the following error while running libtooling based tool on
>>>>> CUDA code but I didn't get the message when running libclang based tool.
>>>>> Please refer the following link for the error.
>>>>>
>>>>> https://gist.github.com/pradeepisro/57e3ff3dab609a8bcc4f66d029e15a8f
>>>>>
>>>>> I used the following repo to test
>>>>> https://github.com/peter-can-talk/cppnow-2017
>>>>>
>>>>> the example code is
>>>>> 1. cppgrep - libclang tool
>>>>> 2. virtual-destructor - libtooling tool
>>>>>
>>>>> With Regards,
>>>>> Pradeep Kumar S.
>>>>> _______________________________________________
>>>>> cfe-dev mailing list
>>>>> cfe-dev at lists.llvm.org
>>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190603/645f6e13/attachment.html>


More information about the cfe-dev mailing list