From 1d12ddce99d18059458a52de66c68dc6eba5fcc2 Mon Sep 17 00:00:00 2001 From: Elazar Leibovich Date: Sat, 21 Dec 2024 22:47:13 +0000 Subject: [PATCH 1/2] cargo fmt --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bc6cf20..06482e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; From b146e9d5fd8eca94963d17cb5301d5f575350cf5 Mon Sep 17 00:00:00 2001 From: Elazar Leibovich Date: Sat, 21 Dec 2024 22:48:32 +0000 Subject: [PATCH 2/2] Add cuDeviceGetUuid support --- src/driver/result.rs | 10 ++++++++++ src/driver/safe/core.rs | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/driver/result.rs b/src/driver/result.rs index 1f37367..d20ed67 100644 --- a/src/driver/result.rs +++ b/src/driver/result.rs @@ -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 { + 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 { diff --git a/src/driver/safe/core.rs b/src/driver/safe/core.rs index 23d5920..6865567 100644 --- a/src/driver/safe/core.rs +++ b/src/driver/safe/core.rs @@ -134,6 +134,11 @@ impl CudaDevice { result::device::get_name(self.cu_device) } + /// Get the UUID of this device. + pub fn uuid(&self) -> Result { + result::device::get_uuid(self.cu_device) + } + /// Get the underlying [sys::CUdevice] of this [CudaDevice]. /// /// # Safety