Hi, I’m having a problem of not wanting a destructor called when I pass a struct by value to a CUDA kernel. Ideally I’d declare it as a const reference, so that no copy is made, but CUDA currently insists that you pass by value or as a pointer (I don’t want to pass by pointer because I will need to allocate extra memory for the copy and could be slower from extra indirection)
Here are the approaches I’ve tried so far without success:
mark the destructor as a host only function
surround the destructor code with #ifdef CUDACC
doesn’t work probably because the copy isn’t made in device code, but rather
in a stub generated by NVCC
Override the default copy constructor, so that it sets a bit marking the copy as
a reference not to be freed
This successfully prevents the destructor from being called for CUDA, but causes leaks whenever I use STL code since functions like vector::push_back() call the copy constructor.
Can anyone help me do what I want?