Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cudax::stream::wait() blocks the caller, while cudax::stream::wait(event_ref) does not #4134

Open
brycelelbach opened this issue Mar 13, 2025 · 1 comment

Comments

@brycelelbach
Copy link
Contributor

cudax::stream A, B;

auto e = A.record_event();

A.wait();
// Block the calling host thread.
// Equivalent to: `cudaStreamSynchronize`.  

B.wait(e);
// Does NOT block the calling host thread.
// Equivalent to: `cudaStreamWaitEvent`.

cudax::stream::wait has three overloads:

  • wait(), which blocks the caller until the stream's work is complete.
  • wait(event_ref), which makes the stream wait for the event before completing any other work. This does not block.
  • wait(stream_ref), which makes the stream wait for the stream before completing any other work. This does not block.

All the functions in well-designed function overload set should:

  • Perform the same fundamental operation, perhaps with different configurations, kinds of inputs, and
  • Provide the same contract.
    • Identical parameters should have the same constness and mutability.
    • Any semantics that can have subtle and hazardous implications should be identical: allocation, algorithmic complexity, and synchronization.

The wait(event_ref) and wait(stream_ref) functions need a different name. In Thrust's unique_stream I believe I called these depend_on.

@leofang
Copy link
Member

leofang commented Mar 13, 2025

This is really a bad name for people who have some basic knowledge in CUDA:

A.wait();

Can we just call it A.synchronize(); or A.sync(); (matching cuda.core)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants