3
votes

Will a call to a synchronous cuda function (e.g. cudaMalloc(), cudaBindTextureToArray(), etc.) block the host until all preceding requested tasks on the device have completed? Or will it block only until the call to that synchronous function has completed?

In other words does a call to a synchronous cuda function have the same effect as cudaDeviceSynchronize()?

1

1 Answers

3
votes

Yes, it should block until all preceding tasks have completed.

You can test this by timing execution of statements on the CPU side:

Put one asynchronous task like kernel execution and then after it a synchronous one like cudaMemcpy() and time execution of both separately. If you put cudaDeviceSynchronize() right after the kernel, the timing will be correct for both calls. But if you delete the cudaDeviceSynchronize() call, you will see that the time for executing the kernel seems to be attached to the cudaMemcpy() call.