I am trying to use cudaMemcpy in a multithreaded environment. Consider the case where there is two executing threads, with no shared resources:
two different arrays allocated on GPU with cudaMalloc (no shared memory): gpuPtr1, gpuPtr2
two different arrays allocated on CPU with same size (no shared memory): cpuPtr1, cpuPtr2.
Is the below code thread safe:?
if (threadId == 0)
ASSERT_CUDA_API_SUCCESS(cudaMemcpy(cpuPtr1, gpuPtr1, size, cudaMemcpyDeviceToHost));
else if (threadId == 1)
ASSERT_CUDA_API_SUCCESS(cudaMemcpy(cpuPtr2, gpuPtr2, size, cudaMemcpyDeviceToHost));