Seems like the __syncthreads is missing from the clang/lib/Headers/__clang_cuda_device_functions.h file. To be honest, I don't know much about CUDA. This issue was noticed by a YouCompleteMe user who then made a pull request:
https://github.com/ycm-core/ycmd/pull/1438
I did not create any tests, because a similar patch did not include tests:
This doesn't seem to actually compile:
In file included from <built-in>:1: In file included from /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang/llvm-project/clang/test/Headers/../../lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h:29: /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang/llvm-project/build/lib/clang/11.0.0/include/__clang_cuda_device_functions.h:522:16: error: static declaration of '__syncthreads' follows non-static declaration __DEVICE__ int __syncthreads(void) { return __nvvm_bar0(); } ^ /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang/llvm-project/build/lib/clang/11.0.0/include/__clang_cuda_device_functions.h:522:16: note: previous implicit declaration is here /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang/llvm-project/build/lib/clang/11.0.0/include/__clang_cuda_device_functions.h:522:45: error: use of undeclared identifier '__nvvm_bar0' __DEVICE__ int __syncthreads(void) { return __nvvm_bar0(); } ^Looks like __nvvm_bar0 is not declared/defined anywhere. When grepping, compared to __nvvm_bar0_and(int), these two are missing:
Should I add BUILTIN(__nvvm_bar0, "v", "") to BuiltinsNVPTX.def and whatever needs to be added to the IntrinsicsNVVM.td?