benchmark #
VTL Backend Benchmark
This benchmark compares matrix multiplication (matmul) across:
- CPU (
vtl.la.matmul) - Vulkan backend (
-d vulkan) - OpenCL/VCL backend (
-d vcl)
What it runs
benchmark/main.v executes matmul over square matrices for sizes:
64 x 64128 x 128256 x 256
Each size is repeated 3 times and averaged.
Run commands
##v run benchmark/main.v
##v -d vcl run benchmark/main.v
##v -d vulkan run benchmark/main.v
##v -d vulkan -d vcl run benchmark/main.v
Output format
Each line prints timing and speedup against CPU:
matmul [128x128]: CPU=8.12ms | Vulkan=1.20ms (6.77x) | VCL=1.55ms (5.24x)
If a backend is not enabled, it is omitted.
Notes
- Benchmarks are sensitive to GPU model, thermal state, and driver/runtime.
- First run can include setup overhead (shader/kernel setup, memory init).
- Use repeated runs for stable comparisons.
fn timeit #
fn timeit(f fn () !) i64
timeit runs fn and returns elapsed nanoseconds.
struct BenchResult #
struct BenchResult {
pub:
name string
size string
cpu_ns i64
vulkan_ns i64 // -1 if not available
vcl_ns i64 // -1 if not available
}
BenchResult holds timing results for a single operation across backends.
fn (BenchResult) str #
fn (r &BenchResult) str() string
str returns a human-readable summary line for a BenchResult.