|
Celeritas 0.7.0-dev.328+develop.a407567
|
Minimal wrapper around a CUDA/HIP event for synchronization. More...
#include <DeviceEvent.hh>
Classes | |
| struct | Impl |
| Internal implementation holding the native CUDA/HIP event handle. More... | |
Public Types | |
| using | EventT = std::nullptr_t |
| Event implementation is unavailable. | |
Public Member Functions | |
| DeviceEvent (Device const &d) | |
| Construct a device event. | |
| DeviceEvent (std::nullptr_t) | |
| Construct a null device event. | |
| DeviceEvent (DeviceEvent const &)=delete | |
| DeviceEvent & | operator= (DeviceEvent const &)=delete |
| DeviceEvent (DeviceEvent &&)=default | |
| DeviceEvent & | operator= (DeviceEvent &&)=default |
| operator bool () const | |
| Whether the event is valid (not null or moved-from). | |
| EventT | get () const |
| Get the native CUDA/HIP event handle. | |
| void | record (Stream const &s) |
| Record this event on the stream. | |
| bool | ready () const |
| Query event status without blocking. | |
| void | sync () const |
| Wait for the event to complete. | |
Minimal wrapper around a CUDA/HIP event for synchronization.
Events provide a mechanism for querying the status of asynchronous operations on GPU streams and synchronizing between host and device, and synchronizing between streams.
true and manages an event object.moved from, the class instance is false. It does not manage an event. The sync function is a null-op (the event is always ready ), and record cannot be called.If no device is enabled (or Celeritas is compiled without CUDA/HIP support), only the null state is available.
my_kernel.sync() before the kernel launch to wait on the previous kernel launch before going again. | auto celeritas::DeviceEvent::get | ( | ) | const |
Get the native CUDA/HIP event handle.
This provides direct access to the underlying event for advanced use cases.
| bool celeritas::DeviceEvent::ready | ( | ) | const |
Query event status without blocking.
This is a non-blocking query that returns immediately. If an error occurs during the query, the function will throw an exception.
Record this event on the stream.
This captures the state of the stream at the point the event is recorded. All operations enqueued on the stream before this call must complete before the event is considered complete.
| void celeritas::DeviceEvent::sync | ( | ) | const |
Wait for the event to complete.
This blocks the calling thread until all operations recorded before this event have finished executing on the device. Use this to synchronize the host with device operations.
If the event is null, this is a no-op.