use criterion::{criterion_group, criterion_main, Criterion}; use faer_core::{ c32, c64, is_vectorizable, mul::matmul_with_conj_gemm_dispatch as matmul_with_conj, ComplexField, Conj, Mat, Parallelism, }; use std::time::Duration; pub fn matmul(criterion: &mut Criterion) { let name = core::any::type_name::(); for n in [2, 3, 4, 5, 6, 8, 32, 64, 128, 256, 512, 1024] { let mut acc = Mat::::zeros(n, n); let a = Mat::::zeros(n, n); let b = Mat::::zeros(n, n); criterion.bench_function(&format!("matmul-{name}-st-{n}"), |bencher| { bencher.iter(|| { matmul_with_conj( acc.as_mut(), a.as_ref(), Conj::No, b.as_ref(), Conj::No, None, E::faer_one(), Parallelism::None, false, ); }); }); criterion.bench_function(&format!("matmul-{name}-mt-{n}"), |bencher| { bencher.iter(|| { matmul_with_conj( acc.as_mut(), a.as_ref(), Conj::No, b.as_ref(), Conj::No, None, E::faer_one(), Parallelism::Rayon(0), false, ); }); }); if is_vectorizable::() { criterion.bench_function(&format!("gemm-{name}-mt-{n}"), |bencher| { bencher.iter(|| { matmul_with_conj( acc.as_mut(), a.as_ref(), Conj::No, b.as_ref(), Conj::No, None, E::faer_one(), Parallelism::Rayon(0), true, ); }); }); criterion.bench_function(&format!("gemm-{name}-st-{n}"), |bencher| { bencher.iter(|| { matmul_with_conj( acc.as_mut(), a.as_ref(), Conj::No, b.as_ref(), Conj::No, None, E::faer_one(), Parallelism::None, true, ); }); }); } } } criterion_group!( name = benches; config = Criterion::default() .warm_up_time(Duration::from_secs(1)) .measurement_time(Duration::from_secs(1)) .sample_size(10); targets = matmul::, matmul::, matmul::, matmul::, matmul::, matmul::, ); criterion_main!(benches);