diff --git a/crates/coremem/src/sim/spirv/mod.rs b/crates/coremem/src/sim/spirv/mod.rs index 950998f..0da736b 100644 --- a/crates/coremem/src/sim/spirv/mod.rs +++ b/crates/coremem/src/sim/spirv/mod.rs @@ -705,8 +705,8 @@ mod test { ) { use rand::{Rng as _, SeedableRng as _}; let mut rng = rand::rngs::StdRng::seed_from_u64(seed); - let mut ref_state = SpirvSim::new_with_backend(size, 1e-3, CpuBackend::default()); - let mut dut_state = SpirvSim::new_with_backend(size, 1e-3, WgpuBackend::default()); + let mut cpu_state = SpirvSim::new_with_backend(size, 1e-3, CpuBackend::default()); + let mut wgpu_state = SpirvSim::new_with_backend(size, 1e-3, WgpuBackend::default()); for z in 0..size.z() { for y in 0..size.y() { @@ -716,17 +716,17 @@ mod test { rng.gen_range(0.0..1e6), rng.gen_range(0.0..1e6), ); - ref_state.put_material(Index::new(x, y, z), AnisomorphicConductor::new(cond.cast())); - dut_state.put_material(Index::new(x, y, z), AnisomorphicConductor::new(cond.cast())); + cpu_state.put_material(Index::new(x, y, z), AnisomorphicConductor::new(cond.cast())); + wgpu_state.put_material(Index::new(x, y, z), AnisomorphicConductor::new(cond.cast())); } } } // TODO: we should apply this on every frame? - ref_state.apply_stimulus(&RngStimulus::new(seed)); - dut_state.apply_stimulus(&RngStimulus::new(seed)); + cpu_state.apply_stimulus(&RngStimulus::new(seed)); + wgpu_state.apply_stimulus(&RngStimulus::new(seed)); - test_same_explicit(ref_state, dut_state, step_iters, steps_per_iter); + test_same_explicit(cpu_state, wgpu_state, step_iters, steps_per_iter); } #[test] @@ -744,8 +744,8 @@ mod test { ) { use rand::{Rng as _, SeedableRng as _}; let mut rng = rand::rngs::StdRng::seed_from_u64(seed); - let mut ref_state = SpirvSim::new_with_backend(size, 1e-3, CpuBackend::default()); - let mut dut_state = SpirvSim::new_with_backend(size, 1e-3, WgpuBackend::default()); + let mut cpu_state = SpirvSim::new_with_backend(size, 1e-3, CpuBackend::default()); + let mut wgpu_state = SpirvSim::new_with_backend(size, 1e-3, WgpuBackend::default()); for z in 0..size.z() { for y in 0..size.y() { @@ -760,21 +760,19 @@ mod test { let slope = rng.gen_range(0.0..0.9*f32::mu0_inv()); let b_end = b_start + b_range; let m_max = b_range * slope; - ref_state.put_material(Index::new(x, y, z), coremem_cross::mat::MBPgram::new( + let mat = coremem_cross::mat::MBPgram::new( b_start.cast(), b_end.cast(), m_max.cast() - )); - dut_state.put_material(Index::new(x, y, z), coremem_cross::mat::MBPgram::new( - b_start.cast(), b_end.cast(), m_max.cast() - )); + ); + cpu_state.put_material(Index::new(x, y, z), mat.clone()); + wgpu_state.put_material(Index::new(x, y, z), mat.clone()); } } } - // TODO: use new (not new_e) - ref_state.apply_stimulus(&RngStimulus::new_e(seed)); - dut_state.apply_stimulus(&RngStimulus::new_e(seed)); + cpu_state.apply_stimulus(&RngStimulus::new(seed)); + wgpu_state.apply_stimulus(&RngStimulus::new(seed)); - test_same_explicit(ref_state, dut_state, step_iters, steps_per_iter); + test_same_explicit(cpu_state, wgpu_state, step_iters, steps_per_iter); } #[test] @@ -783,22 +781,22 @@ mod test { } #[test] - fn mb_ferromagnet_100_steps_larger() { - test_same_mb_ferromagnet(0x1234, 10, 10, Index::new(96, 16, 8)); + fn mb_ferromagnet_50_steps_larger() { + test_same_mb_ferromagnet(0x1234, 10, 5, Index::new(96, 16, 8)); } #[test] fn step_multiple_with_stim() { let size = Index::new(4, 12, 8); - let mut ref_state: SpirvSim, CpuBackend> = + let mut cpu_state: SpirvSim, CpuBackend> = SpirvSim::new(size, 1e-3); - let mut dut_state: SpirvSim, WgpuBackend> = + let mut wgpu_state: SpirvSim, WgpuBackend> = SpirvSim::new(size, 1e-3); let stim = stim::Fields::new_e(Vec3::new(1.0e15, 2.0e15, -3.0e15).cast::()); for _ in 0..5 { - ref_state.step_multiple(100, &stim); - dut_state.step_multiple(100, &stim); - assert_simstate_eq(&dut_state, &ref_state); + cpu_state.step_multiple(100, &stim); + wgpu_state.step_multiple(100, &stim); + assert_simstate_eq(&wgpu_state, &cpu_state); } } }