Accessing cuda device memory when the cuda kernel is running

后端 未结 4 1672
独厮守ぢ
独厮守ぢ 2021-01-22 19:32

I have allocated memory on device using cudaMalloc and have passed it to a kernel function. Is it possible to access that memory from host before the kernel finishes its executi

4条回答
  •  Happy的楠姐
    2021-01-22 20:12

    When you launch the Kernel it is an asynchronous (non blocking) call. Calling cudaMemcpy next will block until the Kernel has finished.

    If you want to have the result for Debug purposes maybe it is possible for you to use cudaDebugging where you can step through the kernel and inspect the memory.

    For small result checks you could also use printf() in the Kernel code.

    Or run only a threadblock of size (1,1) if you are interested in that specific result.

提交回复
热议问题