ironaccelerator_core/
device.rs1use 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 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 pub name: String,
39 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
47pub trait Device: Send + Sync {
49 fn descriptor(&self) -> &DeviceDescriptor;
50
51 fn id(&self) -> DeviceId {
52 self.descriptor().id
53 }
54}