1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Root of the `perf` integration-test binary: a collection of `#[ignore]`d throughput
//! benchmarks, not correctness gates, meant to be run and read by hand
//!
//! * **Native cross-library benches** (`bandwidth`, `batched`, `dtypes`, `prepack`,
//! `sgemm`, `small_mn`) compare gemmkit against the `gemm` crate and/or
//! `matrixmultiply`. Those are dev-dependencies under
//! `cfg(all(not(miri), not(target_family = "wasm")))` in `Cargo.toml`, so any bench that
//! calls into them is itself gated `cfg(not(target_family = "wasm"))`.
//! * **The wasm bench** (`simd128`, `perf_simd128`) has no external crate to compare
//! against on that target, so it instead measures gemmkit's `simd128` token against its
//! own scalar token, the same `NativeTok`-vs-baseline shape `bench_native_equal_isa`
//! uses natively. `harness.rs` (`fill`/`measure`/`gflops`/`Stat`) needs only `std`, so it
//! compiles for both worlds unmodified. Correctness of the simd128 kernel itself is
//! proven separately by `isa_simd128` in `tests/correctness/isa.rs`; what runs here is
//! only the throughput comparison
//!
//! This whole file is `cfg(not(miri))`: Miri cannot execute the target-feature-gated SIMD
//! intrinsics these benches drive, so there is nothing for it to run. Every bench here
//! saturates all available cores, so 2 of them running at once would corrupt each other's
//! numbers; each takes the shared `BENCH_GUARD` lock as its first line, which serializes
//! them even under the harness's default multi-threaded test runner (no need to also pass
//! `--test-threads=1`). Run them with:
//! cargo test -p gemmkit --release --test perf -- --ignored --nocapture
//! Run the wasm benchmark (compile-time `+simd128`) under a wasm runtime:
//! RUSTFLAGS="-C target-feature=+simd128" CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime \
//! cargo test -p gemmkit --release --target wasm32-wasip1 \
//! --no-default-features --features std --test perf -- --ignored --nocapture
// Shared harness (BENCH_GUARD, fill, measure/measure_gbps, Stat, the native-ISA token)
// Bandwidth-bound shapes: STREAM Triad/Copy ceilings, gemv (axpy/dot/mixed), gevv, small-k
// Batched GEMM (gemm_batched) vs naive gemm() loops, serial and parallel
// f16 / bf16 / i8 / c32 element-type throughput, each vs its available external baseline
// Prepacked-RHS/LHS reuse, prepack buffer setup cost, shared-LHS gate sweep
// f32 sgemm vs gemm crate / matrixmultiply, thread-scaling, per-call latency
// wasm simd128 vs the scalar token, single-threaded
// Small-m,n horizontal (inner-product) route benches