use crate::{backend::BackendKind, capability::Capability};
#[cfg(not(feature = "std"))]
use alloc::string::String;
#[cfg(feature = "std")]
use std::string::String;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DeviceId {
pub backend: BackendKind,
pub ordinal: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum Vendor {
Nvidia,
Amd,
Apple,
Qualcomm,
Intel,
Google,
Aws,
Other,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DeviceDescriptor {
pub id: DeviceId,
pub vendor: Vendor,
pub name: String,
pub arch: String,
pub total_memory_bytes: u64,
pub multiprocessor_count: u32,
pub clock_khz: u32,
pub capability: Capability,
}
pub trait Device: Send + Sync {
fn descriptor(&self) -> &DeviceDescriptor;
fn id(&self) -> DeviceId {
self.descriptor().id
}
}