From 6b51fcea02e46632ce649249804dfc05ec11d3ae Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 27 Jul 2022 12:42:44 -0700 Subject: [PATCH] spirv: cpu: inline most of this step logic --- crates/coremem/src/sim/spirv/cpu.rs | 59 +++++------------------------ 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/crates/coremem/src/sim/spirv/cpu.rs b/crates/coremem/src/sim/spirv/cpu.rs index ef4236c..f633f7d 100644 --- a/crates/coremem/src/sim/spirv/cpu.rs +++ b/crates/coremem/src/sim/spirv/cpu.rs @@ -23,60 +23,19 @@ impl> SimBackend for CpuBackend { m: &mut [Vec3], ) { for _ in 0..num_steps { - step_e(meta, stim_e, mat, e, h, m); - step_h(meta, stim_h, mat, e, h, m); + // step E field + apply_all_cells(meta.dim, |idx| { + StepEContext::step_flat_view(meta, mat, stim_e, e, h, idx); + }); + + // step H field + apply_all_cells(meta.dim, |idx| { + StepHContext::step_flat_view(meta, mat, stim_h, e, h, m, idx); + }); } } } -fn step_e>( - meta: SimMeta, - stim_e: &[Vec3], - mat: &[M], - e: &mut [Vec3], - h: &[Vec3], - m: &[Vec3], -) { - apply_all_cells(meta.dim, |idx| { - step_e_cell(idx, meta, stim_e, mat, e, h, m); - }); -} -fn step_h>( - meta: SimMeta, - stim_h: &[Vec3], - mat: &[M], - e: &[Vec3], - h: &mut [Vec3], - m: &mut [Vec3], -) { - apply_all_cells(meta.dim, |idx| { - step_h_cell(idx, meta, stim_h, mat, e, h, m); - }); -} - -fn step_e_cell>( - idx: Vec3u, - meta: SimMeta, - stim_e: &[Vec3], - mat: &[M], - e: &mut [Vec3], - h: &[Vec3], - m: &[Vec3], -) { - StepEContext::step_flat_view(meta, mat, stim_e, e, h, idx); -} -fn step_h_cell>( - idx: Vec3u, - meta: SimMeta, - stim_h: &[Vec3], - mat: &[M], - e: &[Vec3], - h: &mut [Vec3], - m: &mut [Vec3], -) { - StepHContext::step_flat_view(meta, mat, stim_h, e, h, m, idx); -} - fn apply_all_cells(dim: Vec3u, mut f: F) { for z in 0..dim.z() { for y in 0..dim.y() {