I would like to know the best practice concerning the following type of warning:
ptxas warning : Stack size for entry function '_Z11cuda_kernelv' cannot be statically determined
It appears adding the virtual
keyword to the destructor of Internal
, i.e. moving from __device__ ~Internal();
to __device__ virtual ~Internal();
in the following programme:
template<typename T>
class Internal {
T val;
public:
__device__ Internal();
__device__ virtual ~Internal();
__device__ const T& get() const;
};
template<typename T>
__device__ Internal<T>::Internal(): val() {}
template<typename T>
__device__ Internal<T>::~Internal() {}
template<typename T>
__device__ const T& Internal<T>::get() const { return val; }
template<typename T>
class Wrapper {
Internal<T> *arr;
public:
__device__ Wrapper(size_t);
__device__ virtual ~Wrapper();
};
template<typename T>
__device__ Wrapper<T>::Wrapper(size_t len): arr(nullptr) {
printf("%s\n", __PRETTY_FUNCTION__);
arr = new Internal<T>[len];
}
template<typename T>
__device__ Wrapper<T>::~Wrapper() {
delete[] arr;
}
__global__ void cuda_kernel() {
Wrapper<double> *wp = new Wrapper<double>(10);
delete wp;
}
int main() {
cuda_kernel<<<1,1>>>();
cudaDeviceSynchronize();
return 0;
}
Having faced with the warning shown above, I wonder what I should do in this case?
The very short answer is that there is nothing you can do about this particular warning.
In more detail: