I’m using cudart API from different threads. I’ve noticed that when allocating memory with a thread (cudaMalloc) I can use the allocated memory with cudaMempcy (copying from and to that segment) in another thread BUT I cannot use that memory with cudaMemset.
Is it a bug or am I missing something?
Thanks in advance,
Francesco
Are you checking for error codes returned by either call? Both cudaMemcpy and cudaMemset are probably returning “invalid device pointer”. Device memory allocated by cudaMalloc is only valid in the context in which it is allocated and the CUDA runtime API automatically creates one context for each host thread. Check the Programming Guide for more details.
Thanks for the answer.
Yes, I’m verifying error codes on both the call. I attach the test case code.
Francesco
[attachment=9525:CudaThre…pyMemset.cpp]
CudaThreadMemcpyMemset.cpp (2.02 KB)