Skip to content

Commit 183877b

Browse files
brandonrosemberian
authored andcommitted
Extend support for Apple Silicon
1 parent bbbefbf commit 183877b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/device.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const AMD_DEVICE_ON_APPLE_VENDOR_STRING: &str = "AMD";
2828
const AMD_DEVICE_ON_APPLE_VENDOR_ID: u32 = 0x1021d00;
2929
const NVIDIA_DEVICE_VENDOR_STRING: &str = "NVIDIA Corporation";
3030
const NVIDIA_DEVICE_VENDOR_ID: u32 = 0x10de;
31+
const APPLE_DEVICE_VENDOR_ID: u32 = 0x1027F00;
32+
const APPLE_DEVICE_VENDOR_STRING: &str = "Apple";
3133

3234
// The owned CUDA contexts are stored globally. Each devives contains an unowned reference, so
3335
// that devices can be cloned.
@@ -180,6 +182,8 @@ pub enum Vendor {
180182
Intel,
181183
/// GPU by NVIDIA.
182184
Nvidia,
185+
/// GPU by Apple.
186+
Apple,
183187
}
184188

185189
impl TryFrom<&str> for Vendor {
@@ -191,6 +195,7 @@ impl TryFrom<&str> for Vendor {
191195
AMD_DEVICE_ON_APPLE_VENDOR_STRING => Ok(Self::Amd),
192196
INTEL_DEVICE_VENDOR_STRING => Ok(Self::Intel),
193197
NVIDIA_DEVICE_VENDOR_STRING => Ok(Self::Nvidia),
198+
APPLE_DEVICE_VENDOR_STRING => Ok(Self::Apple),
194199
_ => Err(GPUError::UnsupportedVendor(vendor.to_string())),
195200
}
196201
}
@@ -205,6 +210,7 @@ impl TryFrom<u32> for Vendor {
205210
AMD_DEVICE_ON_APPLE_VENDOR_ID => Ok(Self::Amd),
206211
INTEL_DEVICE_VENDOR_ID => Ok(Self::Intel),
207212
NVIDIA_DEVICE_VENDOR_ID => Ok(Self::Nvidia),
213+
APPLE_DEVICE_VENDOR_ID => Ok(Self::Apple),
208214
_ => Err(GPUError::UnsupportedVendor(format!("0x{:x}", vendor))),
209215
}
210216
}
@@ -216,6 +222,7 @@ impl fmt::Display for Vendor {
216222
Self::Amd => AMD_DEVICE_VENDOR_STRING,
217223
Self::Intel => INTEL_DEVICE_VENDOR_STRING,
218224
Self::Nvidia => NVIDIA_DEVICE_VENDOR_STRING,
225+
Self::Apple => APPLE_DEVICE_VENDOR_STRING,
219226
};
220227
write!(f, "{}", vendor)
221228
}

0 commit comments

Comments
 (0)