Friday, 23 August 2013

Is device memory allocated using CudaMalloc inaccessible on the device with free?

Is device memory allocated using CudaMalloc inaccessible on the device
with free?

I cannot deallocate memory on the host that I've allocated on the device
or deallocate memory on the device that I allocated on the host. I'm using
CUDA 5.5 with VS2012 and Nsight. Is it because the heap that's on the host
is not transferred to the heap that's on the device or the other way
around, so dynamic allocations are unknown between host and device?
If this is in the documentation, it is not easy to find. It's also
important to note, an error wasn't thrown until I ran the program with
CUDA debugging and with Memory Checker enabled. The problem did not cause
a crash outside of CUDA debugging, but would've cause problems later if I
hadn't checked for memory issues retroactively. If there's a handy way to
copy the heap/stack from host to device, that'd be fantastic... hopes and
dreams.
Here's an example for my question:
__global__ void kernel(char *ptr)
{
free(ptr);
}
void main(void)
{
char *ptr;
cudaMalloc((void **)&ptr, sizeof(char *), cudaMemcpyHostToDevice);
kernel<<<1, 1>>>(ptr);
}

No comments:

Post a Comment