Skip to main content

ironaccelerator_core/
device.rs

1//! Vendor-neutral device descriptors.
2
3use crate::{backend::BackendKind, capability::Capability};
4
5#[cfg(not(feature = "std"))]
6use alloc::string::String;
7#[cfg(feature = "std")]
8use std::string::String;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub struct DeviceId {
13    pub backend: BackendKind,
14    /// Backend-local ordinal (driver enumeration index).
15    pub ordinal: u32,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
19#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
20#[non_exhaustive]
21pub enum Vendor {
22    Nvidia,
23    Amd,
24    Apple,
25    Qualcomm,
26    Intel,
27    Google,
28    Aws,
29    Other,
30}
31
32#[derive(Debug, Clone)]
33#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
34pub struct DeviceDescriptor {
35    pub id: DeviceId,
36    pub vendor: Vendor,
37    /// Marketing name (e.g. "NVIDIA H100 80GB HBM3").
38    pub name: String,
39    /// Vendor architecture string (e.g. "sm_90a", "gfx942", "Apple9", "v75").
40    pub arch: String,
41    pub total_memory_bytes: u64,
42    pub multiprocessor_count: u32,
43    pub clock_khz: u32,
44    pub capability: Capability,
45}
46
47/// Live device handle. Concrete backends extend this trait with launch APIs.
48pub trait Device: Send + Sync {
49    fn descriptor(&self) -> &DeviceDescriptor;
50
51    fn id(&self) -> DeviceId {
52        self.descriptor().id
53    }
54}