gpu_handle_types/device.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use crate::BackendKind;
4
5/// Stable identity of a physical GPU / CPU / accelerator. Used as cache
6/// key in multi-GPU setups and as an equality test for
7/// `Error::DeviceMismatch`.
8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9pub enum DeviceId {
10 /// The host CPU pseudo-device — the target of the CPU fallback
11 /// backend. A single canonical identity (the host has one logical
12 /// CPU compute target from the library's perspective), so it carries
13 /// no payload and all CPU devices compare equal.
14 Cpu,
15 VulkanUuid([u8; 16]),
16 CudaUuid([u8; 16]),
17 DxgiLuid {
18 high: i32,
19 low: u32,
20 },
21 MetalRegistryId(u64),
22 OpenCl {
23 platform: String,
24 device: String,
25 },
26}
27
28#[derive(Debug, Clone)]
29pub struct DeviceInfo {
30 pub backend: BackendKind,
31 pub name: String,
32 pub id: DeviceId,
33 pub vendor_id: Option<u32>,
34 pub device_pci_id: Option<u32>,
35 pub dedicated_memory_bytes: u64,
36 pub is_integrated: bool,
37}