I am currently performing asynchronous operations using five streams in CUDA.
I want to complete the code in a specific order: Memcpy - cudaMemcpy (Host to Device) - Kernel - cudaMemcpy (Device to Host) - Memcpy. I am encountering an issue where the cudaMemcpy (Device to Host) needs to be completed before I can access the destination address in the last Memcpy. I tried using stream synchronization, but encountered a problem where it breaks after one cycle.
Is there a way to stop each stream while maintaining asynchronous behavior, ensuring that cudaMemcpy (Device to Host) is completed before accessing Memcpy on the CPU?
The following is the result of monitoring the code with errors using Nsight.
