[CUDA] Error when compiling CUDA kernel with new/delete

Hi,

I was compiling some CUDA code, which builds fine with nvcc, but I got the following error when using clang:

/home/acg/llvm/build/bin/clang++ -lcudart -std=c++11 axpy.cu --cuda-gpu-arch=sm_35 -I/usr/local/cuda/samples/common/inc

ptxas fatal : Unresolved extern function ‘_Znam’

clang-4.0: error: ptxas command failed with exit code 255 (use -v to see invocation)

The kernel code is as follows:

global void axpy(float a, float* x, float* y) {

int * _z = new int[16];

_z[ threadIdx.x] = x[threadIdx.x];

y[threadIdx.x] = a * x[threadIdx.x];

__syncthreads();

delete[] _z;

}

new/delete seems to be causing the failure, as the error goes away if we remove the new/delete statements.

Any ideas on how to resolve this?

Thanks!

Yuanfeng Peng