Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When using streams do you need to sync after cudamalloc

When using streams in cuda, is it necessary to perform any synchronization between memory allocations and usage of this memory by a stream (assuming cudaMallocAsync is not available, which it is not for me).

example:

cudaStream_t stream;
cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
... Other code

int *a;
gpuErrchk(cudaMalloc((void **)&a, sizeof(int)));
foo<<<1, 1, 0, stream>>>(a);
gpuErrchk(cudaStreamSynchronize(stream));
cudafree(a);

Is there a chance that when calling foo in such a situation, that the memory allocation is not completed?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Would I be forced to do a device synchronize after the allocation to be sure?

>Solution :

There is no chance that the memory allocation will not be completed. You don’t need an explicit device synchronization after a memory allocation.

When the cudaMalloc call returns, the memory is allocated and usable.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading