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

Elazarl/feature/cuuuid #303

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
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
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
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ pub mod cudnn;
pub mod curand;
#[cfg(feature = "driver")]
pub mod driver;
#[cfg(feature = "runtime")]
pub mod runtime;
#[cfg(feature = "nccl")]
pub mod nccl;
#[cfg(feature = "nvrtc")]
pub mod nvrtc;
#[cfg(feature = "runtime")]
pub mod runtime;

pub mod types;

Expand Down
Loading