pub trait BackendCostModel: Send + Sync {
// Required methods
fn device(&self) -> Device;
fn sgemm_gflops(&self, m: usize, k: usize, n: usize) -> f64;
fn dispatch_overhead_ns(&self) -> f64;
fn roundtrip_overhead_ns(&self) -> f64;
fn memory_bw(&self) -> f64;
fn num_threads(&self) -> usize;
}Expand description
Hardware-aware cost characteristics for a backend on the current machine.
Required Methods§
Sourcefn sgemm_gflops(&self, m: usize, k: usize, n: usize) -> f64
fn sgemm_gflops(&self, m: usize, k: usize, n: usize) -> f64
Effective f32 sgemm throughput in GFLOP/s for the most-used kernel path at the given dimensions. Backends should return their best sustained rate (not peak).
Sourcefn dispatch_overhead_ns(&self) -> f64
fn dispatch_overhead_ns(&self) -> f64
Cost to dispatch one kernel (function call, BLAS setup, etc.) in ns.
Sourcefn roundtrip_overhead_ns(&self) -> f64
fn roundtrip_overhead_ns(&self) -> f64
Cost to commit + wait for a command buffer / forward pass in ns. Roughly amortized per-forward overhead independent of kernel count.
Sourcefn num_threads(&self) -> usize
fn num_threads(&self) -> usize
Number of compute threads available.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl BackendCostModel for CpuCostModel
Available on crate feature
cpu only.