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

Add query and synchronize event function wrappers #320

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading