[4.0] fails when freeing memory after kernel execution error
I have found weird behavior of CUDA. After I got segfault in my kernel, I was trying to free prior allocated memory and it fails. Does CUDA do it automatically? I mean, does CUDA free memory after segfault during kernel executions?

Here is code to reproduce my situation. I have tested that on CUDA 4.0, 4.0rc2 and 3.2

[code]
#include <cassert>

__global__ void segfault(){
int* null = NULL;
*null = 0;
}

int main() {
int* i;
assert (cudaSuccess == cudaHostAlloc(&i, sizeof(int)*100, cudaHostAllocMapped));
segfault<<<1,100>>>();
assert (cudaErrorLaunchFailure == cudaThreadSynchronize());
assert (cudaErrorLaunchFailure == cudaGetLastError());
assert (cudaSuccess == cudaGetLastError());
assert (cudaSuccess == cudaFreeHost(i));
return 0;
}
[/code]

PS: I have posted that question also on stackoverflow: http://stackoverflow.com/questions/6153035/cuda-fails-when-freeing-memory-after-kernel-execution-error
I have found weird behavior of CUDA. After I got segfault in my kernel, I was trying to free prior allocated memory and it fails. Does CUDA do it automatically? I mean, does CUDA free memory after segfault during kernel executions?



Here is code to reproduce my situation. I have tested that on CUDA 4.0, 4.0rc2 and 3.2





#include <cassert>



__global__ void segfault(){

int* null = NULL;

*null = 0;

}



int main() {

int* i;

assert (cudaSuccess == cudaHostAlloc(&i, sizeof(int)*100, cudaHostAllocMapped));

segfault<<<1,100>>>();

assert (cudaErrorLaunchFailure == cudaThreadSynchronize());

assert (cudaErrorLaunchFailure == cudaGetLastError());

assert (cudaSuccess == cudaGetLastError());

assert (cudaSuccess == cudaFreeHost(i));

return 0;

}




PS: I have posted that question also on stackoverflow: http://stackoverflow.com/questions/6153035/cuda-fails-when-freeing-memory-after-kernel-execution-error

#1
Posted 05/27/2011 01:44 PM   
Scroll To Top