diff --git a/rust-toolchain b/rust-toolchain index dbd4126..251f956 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1,3 @@ -1.81.0 +[toolchain] +channel = "1.81.0" +components = ["clippy", "rustfmt"] diff --git a/src/device.rs b/src/device.rs index b5c5abe..5412cc2 100644 --- a/src/device.rs +++ b/src/device.rs @@ -28,6 +28,8 @@ const AMD_DEVICE_ON_APPLE_VENDOR_STRING: &str = "AMD"; const AMD_DEVICE_ON_APPLE_VENDOR_ID: u32 = 0x1021d00; const NVIDIA_DEVICE_VENDOR_STRING: &str = "NVIDIA Corporation"; const NVIDIA_DEVICE_VENDOR_ID: u32 = 0x10de; +const APPLE_DEVICE_VENDOR_ID: u32 = 0x1027F00; +const APPLE_DEVICE_VENDOR_STRING: &str = "Apple"; // The owned CUDA contexts are stored globally. Each devives contains an unowned reference, so // that devices can be cloned. @@ -180,6 +182,8 @@ pub enum Vendor { Intel, /// GPU by NVIDIA. Nvidia, + /// GPU by Apple. + Apple, } impl TryFrom<&str> for Vendor { @@ -191,6 +195,7 @@ impl TryFrom<&str> for Vendor { AMD_DEVICE_ON_APPLE_VENDOR_STRING => Ok(Self::Amd), INTEL_DEVICE_VENDOR_STRING => Ok(Self::Intel), NVIDIA_DEVICE_VENDOR_STRING => Ok(Self::Nvidia), + APPLE_DEVICE_VENDOR_STRING => Ok(Self::Apple), _ => Err(GPUError::UnsupportedVendor(vendor.to_string())), } } @@ -205,6 +210,7 @@ impl TryFrom for Vendor { AMD_DEVICE_ON_APPLE_VENDOR_ID => Ok(Self::Amd), INTEL_DEVICE_VENDOR_ID => Ok(Self::Intel), NVIDIA_DEVICE_VENDOR_ID => Ok(Self::Nvidia), + APPLE_DEVICE_VENDOR_ID => Ok(Self::Apple), _ => Err(GPUError::UnsupportedVendor(format!("0x{:x}", vendor))), } } @@ -216,6 +222,7 @@ impl fmt::Display for Vendor { Self::Amd => AMD_DEVICE_VENDOR_STRING, Self::Intel => INTEL_DEVICE_VENDOR_STRING, Self::Nvidia => NVIDIA_DEVICE_VENDOR_STRING, + Self::Apple => APPLE_DEVICE_VENDOR_STRING, }; write!(f, "{}", vendor) } diff --git a/src/opencl/utils.rs b/src/opencl/utils.rs index eab3b3a..1a38524 100644 --- a/src/opencl/utils.rs +++ b/src/opencl/utils.rs @@ -37,6 +37,13 @@ fn get_pci_id(device: &opencl3::device::Device) -> GPUResult { let device_id = device.pci_slot_id_nv()? as u16; (bus_id << 8) | device_id } + Vendor::Apple => { + // Apple Silicon GPUs are integrated into the SoC and don't use PCI bus + // Return an error to trigger synthetic PCI-ID assignment + return Err(GPUError::Generic( + "Apple GPUs don't have PCI bus information".to_string(), + )); + } }; Ok(id.into()) }