atomr_accel/kernel.rs
1//! `KernelOp` — marker trait for typed kernel-op envelopes.
2//!
3//! Each backend ships concrete actors (`BlasActor`, `CudnnActor`,
4//! …) whose message enums carry op-specific payloads. The marker
5//! trait here lets portable code parameterize over "any op the
6//! backend supports", without committing to a specific message set.
7//!
8//! Backends that share an op vocabulary (e.g. cuBLAS' SGEMM has a
9//! direct equivalent in hipBLAS, rocBLAS, MPS) are encouraged to
10//! implement `KernelOp` for a shared envelope so portable code can
11//! migrate between vendors without rewriting call sites.
12
13/// Marker for any typed op envelope. The default impl is empty —
14/// the trait exists to enable bound-by-name patterns in generic
15/// pipelines without imposing a specific shape on the op.
16pub trait KernelOp: Send + 'static {
17 /// Display name for telemetry / tracing. Backends that share
18 /// ops across vendors should agree on names (e.g. `"sgemm"`).
19 fn op_name(&self) -> &'static str;
20}
21
22/// Generic GEMM payload. Backends with cuBLAS-equivalent libraries
23/// (cuBLAS, hipBLAS, rocBLAS, MPS) all map this to their underlying
24/// SGEMM. The matrices are referred to by backend-typed handles
25/// (`AccelRef<f32, B>`); storage layout is column-major to match
26/// the BLAS convention.
27#[derive(Debug, Clone, Copy)]
28pub struct GemmShape {
29 pub m: i32,
30 pub n: i32,
31 pub k: i32,
32 pub alpha: f32,
33 pub beta: f32,
34}
35
36/// Generic dense FFT payload. Maps to cuFFT, rocFFT, MPS Graph FFT,
37/// or VkFFT depending on the backend.
38#[derive(Debug, Clone, Copy)]
39pub enum FftKind {
40 Forward1dR2C { n: usize, batch: usize },
41 Inverse1dC2R { n: usize, batch: usize },
42 Forward2dC2C { ny: usize, nx: usize, batch: usize },
43}