Skip to content

Commit

Permalink
Implement nvmlDeviceGetCudaComputeCapability.
Browse files Browse the repository at this point in the history
  • Loading branch information
lshqqytiger committed Apr 20, 2024
1 parent 12c2da4 commit cf262c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions zluda_ml/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub(crate) fn error_string(result: nvmlReturn_t) -> *const ::std::os::raw::c_cha
// https://docs.nvidia.com/deploy/cuda-compatibility/index.html#minor-version-compatibility
const VERSION: &'static [u8] = b"511.09.01"; // minimum required by Arnold
const NVML_VERSION: &'static [u8] = b"11.511.09.01"; // // minimum required by Arnold
const NVML_COMPUTE_CAPABILITY_MAJOR: i32 = 8;
const NVML_COMPUTE_CAPABILITY_MINOR: i32 = 8;

impl From<Result<(), nvmlReturn_t>> for nvmlReturn_t {
fn from(result: Result<(), nvmlReturn_t>) -> Self {
Expand Down Expand Up @@ -158,3 +160,13 @@ pub(crate) unsafe fn parse_pci_address(address: *const i8) -> Result<(i32, i32,
i32::from_str_radix(bus, 16).map_err(|_| nvmlReturn_t::NVML_ERROR_INVALID_ARGUMENT)?;
Ok((bus, device, function))
}

pub(crate) unsafe fn device_get_cuda_compute_capability(
_device: *mut crate::nvml::nvmlDevice_st,
major: *mut i32,
minor: *mut i32,
) -> nvmlReturn_t {
*major = NVML_COMPUTE_CAPABILITY_MAJOR;
*minor = NVML_COMPUTE_CAPABILITY_MINOR;
nvmlReturn_t::NVML_SUCCESS
}
2 changes: 1 addition & 1 deletion zluda_ml/src/nvml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2868,7 +2868,7 @@ pub extern "C" fn nvmlDeviceGetCudaComputeCapability(
major: *mut ::std::os::raw::c_int,
minor: *mut ::std::os::raw::c_int,
) -> nvmlReturn_t {
crate::common::unimplemented()
unsafe { crate::common::device_get_cuda_compute_capability(device, major, minor) }
}

#[no_mangle]
Expand Down

0 comments on commit cf262c6

Please sign in to comment.