Kernel error

Hi,

I know that my kernel crash for the moment. I’d like to detect when my kernel crash to preperly free the memory. For example, the cudaMalloc returns a value indicating if the allocation is OK or not.
Is there a way to detect this for kernels?

Another question. Just after the kernel call, I free the memory. If my kernel crash, do you think that the memory has been freed?

Thanks,
Vincent

Call cudaThreadSynchronize() to ensure that the kernel call is complete, then call cudaGetLastError().

Memory is not freed immediately after a kernel crash. If your host application exits (or crashes), the memory will be freed then.