1use std::path::PathBuf;
6
7#[derive(Debug, Clone)]
9pub struct Config {
10 pub refresh_ms: u64,
12 pub device_index: u32,
14 pub backend: ComputeBackend,
16 pub load_profile: LoadProfile,
18 pub workload: WorkloadType,
20 pub problem_size: usize,
22 pub threads: usize,
24 pub deterministic: bool,
26 pub show_fps: bool,
28 pub config_path: Option<PathBuf>,
30}
31
32impl Default for Config {
33 fn default() -> Self {
34 Self {
35 refresh_ms: 100,
36 device_index: 0,
37 backend: ComputeBackend::All,
38 load_profile: LoadProfile::Idle,
39 workload: WorkloadType::Gemm,
40 problem_size: 1_048_576,
41 threads: num_cpus::get(),
42 deterministic: false,
43 show_fps: false,
44 config_path: None,
45 }
46 }
47}
48
49#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
51pub enum ComputeBackend {
52 Simd,
54 Wgpu,
56 Cuda,
58 #[default]
60 All,
61}
62
63#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
65pub enum LoadProfile {
66 #[default]
68 Idle,
69 Light,
71 Medium,
73 Heavy,
75 Stress,
77}
78
79impl LoadProfile {
80 pub fn intensity(&self) -> f64 {
82 match self {
83 Self::Idle => 0.0,
84 Self::Light => 0.25,
85 Self::Medium => 0.50,
86 Self::Heavy => 0.75,
87 Self::Stress => 1.0,
88 }
89 }
90}
91
92#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
94pub enum WorkloadType {
95 #[default]
97 Gemm,
98 Conv2d,
100 Attention,
102 Bandwidth,
104 Elementwise,
106 Reduction,
108 All,
110}
111
112fn num_cpus() -> usize {
113 std::thread::available_parallelism()
114 .map(|n| n.get())
115 .unwrap_or(1)
116}
117
118mod num_cpus {
119 pub fn get() -> usize {
120 std::thread::available_parallelism()
121 .map(|n| n.get())
122 .unwrap_or(1)
123 }
124}