Files
fdtd-coremem/crates/coremem/benches/driver.rs
colin 5b99d30cda restructure this multi-crate project to use Cargo's "workspace" feature
this solves an issue in the Nix build, where managing multiple
Cargo.lock files is otherwise tricky. it causes (or fails to fix?) an adjacent issue where
the spirv builder doesn't seem to have everything it needs vendored.
2022-07-05 17:34:21 -07:00

72 lines
2.8 KiB
Rust

use coremem::{Driver, SimState, SpirvDriver};
use coremem::geom::Index;
use coremem::mat::{Ferroxcube3R1MH, GenericMaterial, GenericMaterialNoPml, GenericMaterialOneField};
use coremem::real::R32;
use coremem::sim::spirv::{self, SpirvSim};
use criterion::{BenchmarkId, criterion_group, criterion_main, Criterion};
type DefaultDriver = Driver::<SimState<R32, GenericMaterial<R32>>>;
pub fn bench_step(c: &mut Criterion) {
for size in &[10, 20, 40, 80, 160] {
let sim = SimState::<R32, GenericMaterial<R32>>::new(Index::new(*size, *size, *size), 1e-5);
c.bench_with_input(BenchmarkId::new("Driver::step", size), &sim, |b, sim| {
let mut driver = Driver::new_with_state(sim.clone());
b.iter(|| driver.step())
});
}
}
pub fn bench_step_spirv(c: &mut Criterion) {
for size in &[10, 20, 40, 80, 160] {
let sim: SpirvSim = SpirvSim::new(Index::new(*size, *size, *size), 1e-5);
c.bench_with_input(BenchmarkId::new("Driver::step_spirv", size), &sim, |b, sim| {
let mut driver = Driver::new_with_state(sim.clone());
b.iter(|| driver.step())
});
}
}
pub fn bench_step_spirv_iso_3r1(c: &mut Criterion) {
type Mat = spirv::IsoConductorOr<Ferroxcube3R1MH>;
for size in &[10, 20, 40, 80, 160] {
let sim: SpirvSim<Mat> = SpirvSim::new(Index::new(*size, *size, *size), 1e-5);
c.bench_with_input(BenchmarkId::new("Driver::spirv_ISO3R1", size), &sim, |b, sim| {
let mut driver: SpirvDriver<Mat> = Driver::new_with_state(sim.clone());
b.iter(|| driver.step())
});
}
}
// pub fn bench_step_no_pml(c: &mut Criterion) {
// for size in &[10, 20, 40, 80, 160] {
// c.bench_with_input(BenchmarkId::new("Driver::step_no_pml", size), size, |b, &size| {
// let mut driver = DefaultDriver::new(Index::new(size, size, size), 1e-5);
// b.iter(|| driver.step())
// });
// }
// }
//
// pub fn bench_step_one_vec(c: &mut Criterion) {
// for size in &[10, 20, 40, 80, 160] {
// c.bench_with_input(BenchmarkId::new("Driver::step_one_vec", size), size, |b, &size| {
// let mut driver = DefaultDriver::new(Index::new(size, size, size), 1e-5);
// b.iter(|| driver.step())
// });
// }
// }
//
// pub fn bench_step_with_pml(c: &mut Criterion) {
// let size = 40;
// for thickness in &[0, 1, 2, 4, 8, 16] {
// c.bench_with_input(BenchmarkId::new("Driver::step_with_pml", thickness), thickness, |b, &thickness| {
// let mut driver = DefaultDriver::new(Index::new(size, size, size), 1e-5);
// driver.add_pml_boundary(Index::new(thickness, thickness, thickness));
// b.iter(|| driver.step())
// });
// }
// }
criterion_group!(benches, /*bench_step,*/ bench_step_spirv, bench_step_spirv_iso_3r1);
criterion_main!(benches);