[llvm-dev] [CUDA] Error when compiling CUDA kernel with new/delete

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] [CUDA] Error when compiling CUDA kernel with new/delete

Alex Bradbury via llvm-dev
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


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev