diff --git a/sycl/plugins/cuda/pi_cuda.hpp b/sycl/plugins/cuda/pi_cuda.hpp index 4b679e58d9230..f6baeab0a4445 100644 --- a/sycl/plugins/cuda/pi_cuda.hpp +++ b/sycl/plugins/cuda/pi_cuda.hpp @@ -476,7 +476,7 @@ struct _pi_queue { if (stream_token == std::numeric_limits::max()) { return false; } - return last_sync_compute_streams_ >= stream_token; + return last_sync_compute_streams_ > stream_token; } bool can_reuse_stream(pi_uint32 stream_token) { @@ -567,9 +567,6 @@ struct _pi_queue { unsigned int end = num_compute_streams_ < size ? num_compute_streams_ : compute_stream_idx_.load(); - if (ResetUsed) { - last_sync_compute_streams_ = end; - } if (end - start >= size) { sync_compute(0, size); } else { @@ -582,6 +579,9 @@ struct _pi_queue { sync_compute(0, end); } } + if (ResetUsed) { + last_sync_compute_streams_ = end; + } } { unsigned int size = static_cast(transfer_streams_.size()); @@ -591,9 +591,6 @@ struct _pi_queue { unsigned int end = num_transfer_streams_ < size ? num_transfer_streams_ : transfer_stream_idx_.load(); - if (ResetUsed) { - last_sync_transfer_streams_ = end; - } if (end - start >= size) { sync_transfer(0, size); } else { @@ -606,6 +603,9 @@ struct _pi_queue { sync_transfer(0, end); } } + if (ResetUsed) { + last_sync_transfer_streams_ = end; + } } } } diff --git a/sycl/plugins/hip/pi_hip.hpp b/sycl/plugins/hip/pi_hip.hpp index 02e96570d5d88..7778f1d07be96 100644 --- a/sycl/plugins/hip/pi_hip.hpp +++ b/sycl/plugins/hip/pi_hip.hpp @@ -457,7 +457,7 @@ struct _pi_queue { if (stream_token == std::numeric_limits::max()) { return false; } - return last_sync_compute_streams_ >= stream_token; + return last_sync_compute_streams_ > stream_token; } bool can_reuse_stream(pi_uint32 stream_token) { @@ -548,9 +548,6 @@ struct _pi_queue { unsigned int end = num_compute_streams_ < size ? num_compute_streams_ : compute_stream_idx_.load(); - if (ResetUsed) { - last_sync_compute_streams_ = end; - } if (end - start >= size) { sync_compute(0, size); } else { @@ -563,6 +560,9 @@ struct _pi_queue { sync_compute(0, end); } } + if (ResetUsed) { + last_sync_compute_streams_ = end; + } } { unsigned int size = static_cast(transfer_streams_.size()); @@ -572,9 +572,6 @@ struct _pi_queue { unsigned int end = num_transfer_streams_ < size ? num_transfer_streams_ : transfer_stream_idx_.load(); - if (ResetUsed) { - last_sync_transfer_streams_ = end; - } if (end - start >= size) { sync_transfer(0, size); } else { @@ -587,6 +584,9 @@ struct _pi_queue { sync_transfer(0, end); } } + if (ResetUsed) { + last_sync_transfer_streams_ = end; + } } } }