[llvm-bugs] [Bug 34360] New: Linking error when calling operator new in CUDA kernel

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 29 06:05:32 PDT 2017


            Bug ID: 34360
           Summary: Linking error when calling operator new in CUDA kernel
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ralph_kube at gmx.net
                CC: llvm-bugs at lists.llvm.org

clang 4.0 fails linking programs which call ::operator new() from CUDA kernels.

This is described in the CUDA documentation here:

Below is a minimal program that reproduces the error as well as the error
message and the version information.

#include <iostream>
#include <cuda_runtime_api.h>

class myclass
   __host__ __device__ myclass(const double _data) : data(_data) {}
   __host__ __device__ ~myclass() 
       printf("Deleting myclass\n");
   __host__ __device__ double get_data() const {return(data);}

   const double data;

void init_myclass(myclass** mycs_ptr)
   (*mycs_ptr) = new myclass(14.0);

void access_myclass(myclass** mycs_ptr)
   printf("I am using data with value = %f\n", (*mycs_ptr) -> get_data());

void delete_myclass(myclass** mycs_ptr)
   delete (*mycs_ptr);

int main(void)
   myclass** myclass_ptr{nullptr};

   init_myclass<<<1, 1>>>(myclass_ptr);

   access_myclass<<<1, 1>>>(myclass_ptr);

   delete_myclass<<<1, 1>>>(myclass_ptr);


[1] % clang++ -std=c++14 -o test_new_device test_new_device.cu
-L/Developer/NVIDIA/CUDA-8.0/lib -lcudart
ptxas fatal   : Unresolved extern function '_Znwm'
clang-4.0: error: ptxas command failed with exit code 255 (use -v to see

I’m on osx 10.12.5, using
% clang++ --version
clang version 4.0.0 (tags/RELEASE_400/final 297808)
Target: x86_64-apple-darwin16.6.0
Thread model: posix

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170829/8c41f1bc/attachment.html>

More information about the llvm-bugs mailing list