Skip to content
Snippets Groups Projects
Commit 8c47ad93 authored by Aaron Councilman's avatar Aaron Councilman
Browse files

Add explicit clone to cfd and allow gpu float error

parent 9142e255
No related branches found
No related tags found
1 merge request!186Rodinia
Pipeline #201728 passed
......@@ -249,6 +249,20 @@ fn time_step<nelr: usize>(
return variables;
}
fn copy_vars<nelr: usize>(variables: Variables::<nelr>) -> Variables::<nelr> {
let result : Variables::<nelr>;
for i = 0 to nelr {
result.density[i] = variables.density[i];
result.momentum.x[i] = variables.momentum.x[i];
result.momentum.y[i] = variables.momentum.y[i];
result.momentum.z[i] = variables.momentum.z[i];
result.energy[i] = variables.energy[i];
}
return result;
}
#[entry]
fn euler<nelr: usize>(
iterations: usize,
......@@ -263,7 +277,7 @@ fn euler<nelr: usize>(
ff_flux_contribution_momentum_z: float3,
) -> Variables::<nelr> {
for i = 0 to iterations {
let old_variables = variables;
let old_variables = copy_vars::<nelr>(variables);
let step_factors = compute_step_factor::<nelr>(variables, areas);
for j = 0 to RK {
......
......@@ -34,7 +34,7 @@ fn run_euler(
ff_fc_momentum_y: &Float3,
ff_fc_momentum_z: &Float3,
) -> Vec<f32> {
let mut variables = HerculesMutBox::from(variables);
let variables = HerculesImmBox::from(variables.as_slice());
let areas = HerculesImmBox::from(areas);
let elements_surrounding_elements = HerculesImmBox::from(elements_surrounding_elements);
let normals = HerculesImmBox::from(normals);
......@@ -87,7 +87,7 @@ fn run_pre_euler(
ff_fc_momentum_y: &Float3,
ff_fc_momentum_z: &Float3,
) -> Vec<f32> {
let mut variables = HerculesMutBox::from(variables);
let variables = HerculesImmBox::from(variables.as_slice());
let areas = HerculesImmBox::from(areas);
let elements_surrounding_elements = HerculesImmBox::from(elements_surrounding_elements);
let normals = HerculesImmBox::from(normals);
......@@ -127,6 +127,15 @@ fn run_pre_euler(
.to_vec()
}
fn compare_float(x: f32, y: f32) -> bool {
(x - y).abs() < 1e-5
}
fn compare_floats(xs: &[f32], ys: &[f32]) -> bool {
xs.len() == ys.len()
&& xs.iter().zip(ys.iter()).all(|(x, y)| compare_float(*x, *y))
}
fn cfd_harness(args: CFDInputs) {
let CFDInputs {
data_file,
......@@ -213,15 +222,7 @@ fn cfd_harness(args: CFDInputs) {
)
};
if res_juno != res_rust {
let len = res_juno.len();
let diff =
res_juno.into_iter()
.zip(res_rust.into_iter())
.enumerate()
.filter(|(_, (x, y))| x != y)
.collect::<Vec<_>>();
println!("Mismatch at {} locations of {}", diff.len(), len);
if !compare_floats(&res_juno, &res_rust) {
panic!("Mismatch in results");
}
}
......
......@@ -328,6 +328,20 @@ fn time_step<nelr: usize>(
return variables;
}
fn copy_vars<nelr: usize>(variables: Variables::<nelr>) -> Variables::<nelr> {
let result : Variables::<nelr>;
for i = 0 to nelr {
result.density[i] = variables.density[i];
result.momentum.x[i] = variables.momentum.x[i];
result.momentum.y[i] = variables.momentum.y[i];
result.momentum.z[i] = variables.momentum.z[i];
result.energy[i] = variables.energy[i];
}
return result;
}
#[entry]
fn pre_euler<nelr: usize>(
iterations: usize,
......@@ -342,7 +356,7 @@ fn pre_euler<nelr: usize>(
ff_fc_momentum_z: float3,
) -> Variables::<nelr> {
for i = 0 to iterations {
let old_variables = variables;
let old_variables = copy_vars::<nelr>(variables);
let step_factors = compute_step_factor::<nelr>(variables, areas);
for j = 0 to RK {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment