From 1dd164a4f31255db25830a49d1d047901963fe4c Mon Sep 17 00:00:00 2001
From: Aaron Councilman <aaronjc4@illinois.edu>
Date: Sat, 1 Mar 2025 13:47:58 -0600
Subject: [PATCH] Fix cfd bench

---
 juno_samples/rodinia/cfd/benches/cfd_bench.rs | 122 +++++++++++-------
 1 file changed, 76 insertions(+), 46 deletions(-)

diff --git a/juno_samples/rodinia/cfd/benches/cfd_bench.rs b/juno_samples/rodinia/cfd/benches/cfd_bench.rs
index fd614b42..5fc73db9 100644
--- a/juno_samples/rodinia/cfd/benches/cfd_bench.rs
+++ b/juno_samples/rodinia/cfd/benches/cfd_bench.rs
@@ -28,40 +28,55 @@ fn cfd_bench(c: &mut Criterion) {
         elements_surrounding_elements,
         normals,
     } = read_domain_geometry(data_file, block_size);
-    let mut variables = initialize_variables(nelr, ff_variable.as_slice());
-    let mut variables = HerculesMutBox::from(variables.as_mut_slice());
+    let mut variables = initialize_variables(nelr, &ff_variable);
+
+    let mut v_density = HerculesMutBox::from(variables.density.as_mut_slice());
+    let mut v_momentum_x = HerculesMutBox::from(variables.momentum.x.as_mut_slice());
+    let mut v_momentum_y = HerculesMutBox::from(variables.momentum.y.as_mut_slice());
+    let mut v_momentum_z = HerculesMutBox::from(variables.momentum.z.as_mut_slice());
+    let mut v_energy = HerculesMutBox::from(variables.energy.as_mut_slice());
+
     let areas = HerculesImmBox::from(areas.as_slice());
     let elements_surrounding_elements =
         HerculesImmBox::from(elements_surrounding_elements.as_slice());
-    let normals = HerculesImmBox::from(normals.as_slice());
-    let ff_variable = HerculesImmBox::from(ff_variable.as_slice());
-    let ff_fc_density_energy = vec![
-        ff_fc_density_energy.x,
-        ff_fc_density_energy.y,
-        ff_fc_density_energy.z,
-    ];
-    let ff_fc_density_energy = HerculesImmBox::from(ff_fc_density_energy.as_slice());
-    let ff_fc_momentum_x = vec![ff_fc_momentum_x.x, ff_fc_momentum_x.y, ff_fc_momentum_x.z];
-    let ff_fc_momentum_x = HerculesImmBox::from(ff_fc_momentum_x.as_slice());
-    let ff_fc_momentum_y = vec![ff_fc_momentum_y.x, ff_fc_momentum_y.y, ff_fc_momentum_y.z];
-    let ff_fc_momentum_y = HerculesImmBox::from(ff_fc_momentum_y.as_slice());
-    let ff_fc_momentum_z = vec![ff_fc_momentum_z.x, ff_fc_momentum_z.y, ff_fc_momentum_z.z];
-    let ff_fc_momentum_z = HerculesImmBox::from(ff_fc_momentum_z.as_slice());
+
+    let normals_x = HerculesImmBox::from(normals.x.as_slice());
+    let normals_y = HerculesImmBox::from(normals.y.as_slice());
+    let normals_z = HerculesImmBox::from(normals.z.as_slice());
+
     group.bench_function("cfd bench euler", |b| {
         b.iter(|| {
             async_std::task::block_on(async {
                 r.run(
                     nelr as u64,
                     iterations as u64,
-                    variables.to(),
+                    v_density.to(),
+                    v_momentum_x.to(),
+                    v_momentum_y.to(),
+                    v_momentum_z.to(),
+                    v_energy.to(),
                     areas.to(),
                     elements_surrounding_elements.to(),
-                    normals.to(),
-                    ff_variable.to(),
-                    ff_fc_density_energy.to(),
-                    ff_fc_momentum_x.to(),
-                    ff_fc_momentum_y.to(),
-                    ff_fc_momentum_z.to(),
+                    normals_x.to(),
+                    normals_y.to(),
+                    normals_z.to(),
+                    ff_variable.density,
+                    ff_variable.momentum.x,
+                    ff_variable.momentum.y,
+                    ff_variable.momentum.z,
+                    ff_variable.energy,
+                    ff_fc_density_energy.x,
+                    ff_fc_density_energy.y,
+                    ff_fc_density_energy.z,
+                    ff_fc_momentum_x.x,
+                    ff_fc_momentum_x.y,
+                    ff_fc_momentum_x.z,
+                    ff_fc_momentum_y.x,
+                    ff_fc_momentum_y.y,
+                    ff_fc_momentum_y.z,
+                    ff_fc_momentum_z.x,
+                    ff_fc_momentum_z.y,
+                    ff_fc_momentum_z.z,
                 )
                 .await
             });
@@ -85,40 +100,55 @@ fn cfd_bench(c: &mut Criterion) {
         elements_surrounding_elements,
         normals,
     } = read_domain_geometry(data_file, block_size);
-    let mut variables = initialize_variables(nelr, ff_variable.as_slice());
-    let mut variables = HerculesMutBox::from(variables.as_mut_slice());
+    let mut variables = initialize_variables(nelr, &ff_variable);
+
+    let mut v_density = HerculesMutBox::from(variables.density.as_mut_slice());
+    let mut v_momentum_x = HerculesMutBox::from(variables.momentum.x.as_mut_slice());
+    let mut v_momentum_y = HerculesMutBox::from(variables.momentum.y.as_mut_slice());
+    let mut v_momentum_z = HerculesMutBox::from(variables.momentum.z.as_mut_slice());
+    let mut v_energy = HerculesMutBox::from(variables.energy.as_mut_slice());
+
     let areas = HerculesImmBox::from(areas.as_slice());
     let elements_surrounding_elements =
         HerculesImmBox::from(elements_surrounding_elements.as_slice());
-    let normals = HerculesImmBox::from(normals.as_slice());
-    let ff_variable = HerculesImmBox::from(ff_variable.as_slice());
-    let ff_fc_density_energy = vec![
-        ff_fc_density_energy.x,
-        ff_fc_density_energy.y,
-        ff_fc_density_energy.z,
-    ];
-    let ff_fc_density_energy = HerculesImmBox::from(ff_fc_density_energy.as_slice());
-    let ff_fc_momentum_x = vec![ff_fc_momentum_x.x, ff_fc_momentum_x.y, ff_fc_momentum_x.z];
-    let ff_fc_momentum_x = HerculesImmBox::from(ff_fc_momentum_x.as_slice());
-    let ff_fc_momentum_y = vec![ff_fc_momentum_y.x, ff_fc_momentum_y.y, ff_fc_momentum_y.z];
-    let ff_fc_momentum_y = HerculesImmBox::from(ff_fc_momentum_y.as_slice());
-    let ff_fc_momentum_z = vec![ff_fc_momentum_z.x, ff_fc_momentum_z.y, ff_fc_momentum_z.z];
-    let ff_fc_momentum_z = HerculesImmBox::from(ff_fc_momentum_z.as_slice());
+
+    let normals_x = HerculesImmBox::from(normals.x.as_slice());
+    let normals_y = HerculesImmBox::from(normals.y.as_slice());
+    let normals_z = HerculesImmBox::from(normals.z.as_slice());
+
     group.bench_function("cfd bench pre-euler", |b| {
         b.iter(|| {
             async_std::task::block_on(async {
                 r.run(
                     nelr as u64,
                     iterations as u64,
-                    variables.to(),
+                    v_density.to(),
+                    v_momentum_x.to(),
+                    v_momentum_y.to(),
+                    v_momentum_z.to(),
+                    v_energy.to(),
                     areas.to(),
                     elements_surrounding_elements.to(),
-                    normals.to(),
-                    ff_variable.to(),
-                    ff_fc_density_energy.to(),
-                    ff_fc_momentum_x.to(),
-                    ff_fc_momentum_y.to(),
-                    ff_fc_momentum_z.to(),
+                    normals_x.to(),
+                    normals_y.to(),
+                    normals_z.to(),
+                    ff_variable.density,
+                    ff_variable.momentum.x,
+                    ff_variable.momentum.y,
+                    ff_variable.momentum.z,
+                    ff_variable.energy,
+                    ff_fc_density_energy.x,
+                    ff_fc_density_energy.y,
+                    ff_fc_density_energy.z,
+                    ff_fc_momentum_x.x,
+                    ff_fc_momentum_x.y,
+                    ff_fc_momentum_x.z,
+                    ff_fc_momentum_y.x,
+                    ff_fc_momentum_y.y,
+                    ff_fc_momentum_y.z,
+                    ff_fc_momentum_z.x,
+                    ff_fc_momentum_z.y,
+                    ff_fc_momentum_z.z,
                 )
                 .await
             });
-- 
GitLab