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

Yuanfeng Peng via llvm-dev llvm-dev at lists.llvm.org
Sat Jun 10 07:22:52 PDT 2017


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];
  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?


Yuanfeng Peng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170610/27b36c1a/attachment.html>

More information about the llvm-dev mailing list