Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skailasa committed Dec 15, 2023
1 parent 8924c2e commit 7b2f5f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
3 changes: 1 addition & 2 deletions fmm/src/field_translation/source_to_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ where

for (i, kernel_f) in kernel_data_f.iter().enumerate().take(26) {
let frequency_offset = 64 * freq;
let k_f =
&kernel_f[frequency_offset..(frequency_offset + 64)].to_vec();
let k_f = &kernel_f[frequency_offset..(frequency_offset + 64)].to_vec();

// Lookup signals
let displacements = &all_displacements[i][chunk_start..chunk_end];
Expand Down
49 changes: 16 additions & 33 deletions fmm/src/fmm/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ mod test {
use crate::charge::build_charge_dict;

#[test]
fn test_fmm_data_linear() {
fn test_fmm_data() {
let npoints = 10000;
let points = points_fixture::<f64>(npoints, None, None);
let global_idxs = (0..npoints).collect_vec();
Expand Down Expand Up @@ -678,19 +678,19 @@ mod test {
}

#[test]
fn test_fmm_linear_fft_f64() {
let npoints = 1000000;
fn test_fmm_fft_f64() {
let npoints = 10000;
let points = points_fixture::<f64>(npoints, None, None);
let global_idxs = (0..npoints).collect_vec();
let charges = vec![1.0; npoints];

let order = 9;
let order = 6;
let alpha_inner = 1.05;
let alpha_outer = 2.95;
let adaptive = false;
let ncrit = 150;

let depth = 4;
let depth = 3;
let kernel = Laplace3dKernel::default();

let tree = SingleNodeTree::new(
Expand All @@ -711,9 +711,7 @@ mod test {

let datatree = FmmDataLinear::new(fmm, &charge_dict).unwrap();

let s = Instant::now();
let times = datatree.run(true);
println!("runtime {:?}, operator times {:?}", s.elapsed(), times);
datatree.run(false);

// Test that direct computation is close to the FMM.
let leaf = &datatree.fmm.tree.get_all_leaves().unwrap()[0];
Expand Down Expand Up @@ -754,28 +752,24 @@ mod test {
.map(|(a, b)| (a - b).abs())
.sum();
let rel_error: f64 = abs_error / (direct.iter().sum::<f64>());
// println!("potentials {:?}", potentials);
// println!("direct {:?}", direct);
println!("rel error {:?}", rel_error);

assert!(rel_error <= 1e-6);
assert!(false);
}

#[test]
fn test_fmm_linear_fft_f32() {
let npoints = 1000000;
fn test_fmm_fft_f32() {
let npoints = 10000;
let points = points_fixture::<f32>(npoints, None, None);
let global_idxs = (0..npoints).collect_vec();
let charges = vec![1.0; npoints];

let order = 5;
let order = 6;
let alpha_inner = 1.05;
let alpha_outer = 2.95;
let adaptive = false;
let ncrit = 150;

let depth = 4;
let depth = 3;
let kernel = Laplace3dKernel::default();

let tree = SingleNodeTree::new(
Expand All @@ -796,9 +790,7 @@ mod test {

let datatree = FmmDataLinear::new(fmm, &charge_dict).unwrap();

let s = Instant::now();
let times = datatree.run(true);
println!("runtime {:?}, operator times {:?}", s.elapsed(), times);
datatree.run(false);

// Test that direct computation is close to the FMM.
let leaf = &datatree.fmm.tree.get_all_leaves().unwrap()[0];
Expand Down Expand Up @@ -839,17 +831,13 @@ mod test {
.map(|(a, b)| (a - b).abs())
.sum();
let rel_error: f32 = abs_error / (direct.iter().sum::<f32>());
// println!("potentials {:?}", potentials);
// println!("direct {:?}", direct);
println!("rel error {:?}", rel_error);

assert!(rel_error <= 1e-6);
assert!(false);
assert!(rel_error <= 1e-5);
}

#[test]
fn test_fmm_linear_svd_f64() {
let npoints = 1000000;
fn test_fmm_svd_f64() {
let npoints = 10000;
let points = points_fixture::<f64>(npoints, None, None);
let global_idxs = (0..npoints).collect_vec();
let charges = vec![1.0; npoints];
Expand All @@ -860,7 +848,7 @@ mod test {
let adaptive = false;
let ncrit = 150;

let depth = 4;
let depth = 3;
let kernel = Laplace3dKernel::default();

let tree = SingleNodeTree::new(
Expand All @@ -886,9 +874,7 @@ mod test {

let datatree = FmmDataLinear::new(fmm, &charge_dict).unwrap();

let s = Instant::now();
let times = datatree.run(true);
println!("runtime {:?} operators {:?}", s.elapsed(), times);
datatree.run(false);

// Test that direct computation is close to the FMM.
let leaf = &datatree.fmm.tree.get_all_leaves().unwrap()[0];
Expand Down Expand Up @@ -930,9 +916,6 @@ mod test {
.sum();
let rel_error: f64 = abs_error / (direct.iter().sum::<f64>());

println!("rel_error {:?}", rel_error);

assert!(rel_error <= 1e-6);
assert!(false);
}
}

0 comments on commit 7b2f5f8

Please sign in to comment.