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: free - CUDA fails when freeing memory after kernel execution error - Stack Overflow