Skip to content

Commit

Permalink
Add cuDeviceGetUuid support
Browse files Browse the repository at this point in the history
  • Loading branch information
elazarl committed Dec 22, 2024
1 parent 1d12ddc commit b146e9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/driver/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ pub mod device {
let name = CStr::from_bytes_until_nul(&buf).expect("No null byte was present");
Ok(String::from_utf8_lossy(name.to_bytes()).into())
}

pub fn get_uuid(dev: sys::CUdevice) -> Result<sys::CUuuid, DriverError> {
let id: sys::CUuuid;
unsafe {
let mut uuid = MaybeUninit::uninit();
lib().cuDeviceGetUuid(uuid.as_mut_ptr(), dev).result()?;
id = uuid.assume_init();
}
Ok(id)
}
}

pub mod function {
Expand Down
5 changes: 5 additions & 0 deletions src/driver/safe/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ impl CudaDevice {
result::device::get_name(self.cu_device)
}

/// Get the UUID of this device.
pub fn uuid(&self) -> Result<sys::CUuuid, result::DriverError> {
result::device::get_uuid(self.cu_device)
}

/// Get the underlying [sys::CUdevice] of this [CudaDevice].
///
/// # Safety
Expand Down

0 comments on commit b146e9d

Please sign in to comment.