Skip to content

Commit

Permalink
Add query and synchronize event function wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierDehaene committed Jan 21, 2025
1 parent e768643 commit 7502da8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/driver/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,28 @@ pub mod event {
Ok(ms)
}

/// Queries an event's status.
/// Returns `Ok` if all captured work has been completed, or `Err`: `CUDA_ERROR_NOT_READY` if
/// any captured work is incomplete.
///
/// See [cuda docs](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g6f0704d755066b0ee705749ae911deef)
///
/// # Safety
/// This function is unsafe because event can be a null event, in which case
pub unsafe fn query(event: sys::CUevent) -> Result<(), DriverError> {
unsafe { lib().cuEventQuery(event).result() }
}

/// Waits for an event to complete.
///
/// See [cuda docs](https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g9e520d34e51af7f5375610bca4add99c)
///
/// # Safety
/// This function is unsafe because event can be a null event, in which case
pub unsafe fn synchronize(event: sys::CUevent) -> Result<(), DriverError> {
unsafe { lib().cuEventSynchronize(event).result() }
}

/// Destroys an event.
///
/// > An event may be destroyed before it is complete (i.e., while cuEventQuery() would return CUDA_ERROR_NOT_READY).
Expand Down

0 comments on commit 7502da8

Please sign in to comment.