rmm icon indicating copy to clipboard operation
rmm copied to clipboard

[REVIEW] Add cuda_event type

Open achirkin opened this issue 4 years ago • 13 comments
trafficstars

  1. Add new cuda_event and cuda_event_view wrappers, similar to cuda_stream and cuda_stream_view.
  2. Add extra functionality to cuda_stream and cuda_stream_view to interact with the added event types.

achirkin avatar Sep 15 '21 08:09 achirkin

A few days ago @jrhemstad mentioned you'd welcome this wrapper. I tried to follow cuda_stream approach as close as possible, so some copy-pasting is there.

achirkin avatar Sep 15 '21 08:09 achirkin

Thanks, @jrhemstad ! I wouldn't mind moving the wait and record, but then we need to make a choice: shall I add another event_view, or better just make duplicate methods for rmm::cuda_event and cudaEvent_t? And there is also wait without arguments, which synchronises with the host (cudaEventSynchronize), which I cannot move to stream_view.

On the other hand, I can just change the wording to something like... synchronize/wait_by and push/record_in?

achirkin avatar Sep 15 '21 14:09 achirkin

Yes, I think we will need an event_view type.

And there is also wait without arguments, which synchronises with the host (cudaEventSynchronize), which I cannot move to stream_view.

Good point. We should keep that as a wait function in the event type.

jrhemstad avatar Sep 15 '21 15:09 jrhemstad

There would also be some inconvenience in having to explicitly convert stream types to the stream_view to access its member functions if we move wait and record there, right? Still better than having them in cuda_event? :)

achirkin avatar Sep 15 '21 15:09 achirkin

We should design for a world where cudaStream_t isn't used directly anymore.

Eventually these types will all exist in libcu++.

jrhemstad avatar Sep 15 '21 15:09 jrhemstad

Done. Sorry I don't have the rights to set github labels here.

achirkin avatar Sep 16 '21 12:09 achirkin

Also note, I added a function that doesn't strictly belong to the PR (I hope it's ok). I need it in cuml to decide if I need one worker stream or two (if I cannot use the default). I thought it would be useful for others too: https://github.com/rapidsai/rmm/blob/b55088b3a1433b0248dddab319d10771cb8d97ba/include/rmm/cuda_stream_view.hpp#L96-L118

achirkin avatar Sep 16 '21 12:09 achirkin

I think this still requires a bit of design work, and we are in burn down for 21.10 so I'm moving this to the next release. @achirkin please change the target branch.

harrism avatar Sep 16 '21 22:09 harrism

Ok, though I hoped to push it in 21.10, cause I need events in https://github.com/rapidsai/cuml/pull/4201 .

achirkin avatar Sep 17 '21 09:09 achirkin

@achirkin you can use CUDA events now without a wrapper class. We already use events in RMM. I think we should take our time and get this right, and perhaps it should just live in libcu++ from the beginning.

harrism avatar Sep 20 '21 22:09 harrism

Removing ops-codeowners from the required reviews since it doesn't seem there are any file changes that we're responsible for. Feel free to add us back if necessary.

ajschmidt8 avatar Sep 30 '21 13:09 ajschmidt8

This PR has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this PR if it is no longer required. Otherwise, please respond with a comment indicating any updates. This PR will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] avatar Nov 18 '21 18:11 github-actions[bot]

This PR has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this PR if it is no longer required. Otherwise, please respond with a comment indicating any updates.

github-actions[bot] avatar Feb 16 '22 19:02 github-actions[bot]