[CUDA] CUDA device code does not support variadic functions in clang

Im using clangd with my editor and I’ve already set it up to work with cuda reasonably till I tried to edit cuda example provided with the sdk simpleAWBarrier.

Whenever we include <cuda/barrier>, it gives out an error

CUDA device code does not support variadic functions

I could see the same error if I try to build the example with clang as well.

Does not clang support variadic device functions yet? Or is there some flag to enable this feature?

The command I’m using to build the example is

clang++ -I/opt/cuda-11.5/samples/common/inc --cuda-gpu-arch=sm_80 -o simpleAWBarrier.o -c simpleAWBarrier.cu --cuda-path=/opt/cuda/cuda-11.5/

clang version:

clang++ --version
clang version 14.0.0 (524758d1a75e21a9133b597ea649237d75a46abb)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Early versions of PTX (up until CUDA-9.0/ PTX 6.0) did not support variadic functions on GPU.

Clang did impelment special case handling for printf, but I don’t think we’ve implemented general support for variadic functions.

In general, I would not expect CUDA’s standard c++ library (which is what cuda/barrier actually uses) to compile with clang. It will likely need both changes to clang and portability fixes to the library headers.

Currently compilation fails even if we relax checks for varargs functions: Compiler Explorer

1 Like