Skip to main content

cbtop/bricks/panels/load/
types.rs

1//! Types for the load control panel.
2
3/// Compute backend options
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5pub enum ComputeBackend {
6    #[default]
7    Auto,
8    CpuScalar,
9    CpuSimd,
10    GpuCuda,
11    GpuWgpu,
12}
13
14impl ComputeBackend {
15    /// Display name for the backend
16    pub fn name(&self) -> &'static str {
17        match self {
18            Self::Auto => "Auto",
19            Self::CpuScalar => "CPU (Scalar)",
20            Self::CpuSimd => "CPU (SIMD)",
21            Self::GpuCuda => "GPU (CUDA)",
22            Self::GpuWgpu => "GPU (wgpu)",
23        }
24    }
25
26    /// All available backends
27    pub const ALL: [ComputeBackend; 5] = [
28        Self::Auto,
29        Self::CpuScalar,
30        Self::CpuSimd,
31        Self::GpuCuda,
32        Self::GpuWgpu,
33    ];
34}
35
36/// Workload type for load testing
37#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
38pub enum WorkloadType {
39    #[default]
40    Gemm,
41    Softmax,
42    LayerNorm,
43    Attention,
44    Lz4Compress,
45    Mixed,
46}
47
48impl WorkloadType {
49    /// Display name for the workload
50    pub fn name(&self) -> &'static str {
51        match self {
52            Self::Gemm => "GEMM (Matrix Multiply)",
53            Self::Softmax => "Softmax",
54            Self::LayerNorm => "Layer Normalization",
55            Self::Attention => "Attention",
56            Self::Lz4Compress => "LZ4 Compression",
57            Self::Mixed => "Mixed Workload",
58        }
59    }
60
61    /// Short name for compact display
62    pub fn short_name(&self) -> &'static str {
63        match self {
64            Self::Gemm => "GEMM",
65            Self::Softmax => "Softmax",
66            Self::LayerNorm => "LayerNorm",
67            Self::Attention => "Attention",
68            Self::Lz4Compress => "LZ4",
69            Self::Mixed => "Mixed",
70        }
71    }
72
73    /// All available workloads
74    pub const ALL: [WorkloadType; 6] = [
75        Self::Gemm,
76        Self::Softmax,
77        Self::LayerNorm,
78        Self::Attention,
79        Self::Lz4Compress,
80        Self::Mixed,
81    ];
82}
83
84/// Load test run statistics
85#[derive(Debug, Clone, Default)]
86pub struct LoadStats {
87    /// Iterations completed
88    pub iterations: u64,
89    /// Total elapsed time in milliseconds
90    pub elapsed_ms: u64,
91    /// Operations per second
92    pub ops_per_sec: f64,
93    /// Current throughput in GB/s
94    pub throughput_gbs: f64,
95    /// Average latency in microseconds
96    pub avg_latency_us: f64,
97    /// P99 latency in microseconds
98    pub p99_latency_us: f64,
99}