cudaMemcpy after error in kernel


I have a CUDA program in which I’m calling a kernel after which I’m transferring some results back to CPU memory. My host side code looks like the following:

insertionTest<<<grid, block>>>(in, n, hashTable.getPtr(), numKeysGPU.getPtr(), iterations.getPtr());



        cudaError_t res = cudaGetLastError();

	std::cout << cudaGetErrorString(res) << std::endl;


        int itersCPU[2];


	std::cout << itersCPU[0] << " " << itersCPU[1] << std::endl;

When the kernel errors out (I’m getting an “unknown error”), itersCPU seems to only have zeros. However, things work fine when there is no error in the kernel. Is this expected behaviour? I expected to get back the last value written into “iterations” before the kernel failed.

Any help is much appreciated. Thanks in advance!