Skip to content

Extend support for Apple Silicon #75

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

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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";

#[cfg(feature = "cuda")]
lazy_static! {
Expand Down Expand Up @@ -178,6 +180,8 @@ pub enum Vendor {
Amd,
/// GPU by NVIDIA.
Nvidia,
/// GPU by Apple.
Apple,
}

impl TryFrom<&str> for Vendor {
Expand All @@ -188,6 +192,7 @@ impl TryFrom<&str> for Vendor {
AMD_DEVICE_VENDOR_STRING => Ok(Self::Amd),
AMD_DEVICE_ON_APPLE_VENDOR_STRING => Ok(Self::Amd),
NVIDIA_DEVICE_VENDOR_STRING => Ok(Self::Nvidia),
APPLE_DEVICE_VENDOR_STRING => Ok(Self::Apple),
_ => Err(GPUError::UnsupportedVendor(vendor.to_string())),
}
}
Expand All @@ -201,6 +206,7 @@ impl TryFrom<u32> for Vendor {
AMD_DEVICE_VENDOR_ID => Ok(Self::Amd),
AMD_DEVICE_ON_APPLE_VENDOR_ID => Ok(Self::Amd),
NVIDIA_DEVICE_VENDOR_ID => Ok(Self::Nvidia),
APPLE_DEVICE_VENDOR_ID => Ok(Self::Apple),
_ => Err(GPUError::UnsupportedVendor(format!("0x{:x}", vendor))),
}
}
Expand All @@ -211,6 +217,7 @@ impl fmt::Display for Vendor {
let vendor = match self {
Self::Amd => AMD_DEVICE_VENDOR_STRING,
Self::Nvidia => NVIDIA_DEVICE_VENDOR_STRING,
Self::Apple => APPLE_DEVICE_VENDOR_STRING,
};
write!(f, "{}", vendor)
}
Expand Down