I have the following global kernel:
__global__ void pdegpu(PDE_ParabolicD1_Num_GPU **pdes)
{
PDE_ParabolicD1_Num_GPU *loc;
loc = new PDE_ParabolicD1_Num_GPU();
loc->Setup();
delete loc;
//above code was just an example to show that new and delete work fine
*pdes = new PDE_ParabolicD1_Num_GPU(); //error occurs here
(*pdes)->Setup();
}
which I call to create an object of type PDE_ParabolicD1_Num_GPU and setup it. In main(), I will be using the same object that is why I am using double pointer in the function argument. In main(), I do the following:
PDE_ParabolicD1_Num_GPU pdes_host;
PDE_ParabolicD1_Num_GPU *pdes_dev=0;
pdegpu<<<1,1>>>(&pdes_dev);
cudaStatus = cudaMemcpy(&pdes_host, pdes_dev, sizeof(PDE_ParabolicD1_Num_GPU), cudaMemcpyDeviceToHost);
...
delete [] pdes_dev;
However, I get an error shown in the code, and CUDA Memory Checker output for the error is as follows:
Memory Checker detected 1 access violations.
error = access violation on store (global memory)
gridid = 16
blockIdx = {0,0,0}
threadIdx = {0,0,0}
address = 0x0018f420
accessSize = 4
error MemoryChecker: #misaligned=0 #invalidAddress=1
As far as I understood the error is caused due to invalidAddress.
Could anyone help me to resolve the problem?
Thank you