Skip to content
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
4 changes: 3 additions & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
1.81.0
[toolchain]
channel = "1.81.0"
components = ["clippy", "rustfmt"]
7 changes: 7 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -180,6 +182,8 @@ pub enum Vendor {
Intel,
/// GPU by NVIDIA.
Nvidia,
/// GPU by Apple.
Apple,
}

impl TryFrom<&str> for Vendor {
Expand All @@ -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())),
}
}
Expand All @@ -205,6 +210,7 @@ impl TryFrom<u32> 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))),
}
}
Expand All @@ -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)
}
Expand Down
7 changes: 7 additions & 0 deletions src/opencl/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ fn get_pci_id(device: &opencl3::device::Device) -> GPUResult<PciId> {
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())
}
Expand Down