Skip to content

Commit

Permalink
don't bother sync-ing a stream with itself (#3007)
Browse files Browse the repository at this point in the history
given two `stream_ref` objects, `stream1.wait(stream2)` should be a no-op if `stream1 == stream2`. don't bother creating an event for it.
  • Loading branch information
ericniebler authored Dec 2, 2024
1 parent b3fe77f commit ba0badf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cudax/include/cuda/experimental/__stream/stream_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ struct stream_ref : ::cuda::stream_ref
// TODO consider an optimization to not create an event every time and instead have one persistent event or one
// per stream
_CCCL_ASSERT(__stream != detail::__invalid_stream, "cuda::experimental::stream_ref::wait invalid stream passed");
event __tmp(__other);
wait(__tmp);
if (*this != __other)
{
event __tmp(__other);
wait(__tmp);
}
}

//! @brief Get the logical device under which this stream was created
Expand Down

0 comments on commit ba0badf

Please sign in to comment.