-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,774 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
use std::time::Duration; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use green_kernels::{laplace_3d::Laplace3dKernel, types::GreenKernelEvalType}; | ||
use kifmm::fmm::types::FmmSvdMode; | ||
use kifmm::fmm::types::{BlasFieldTranslationSaRcmp, FftFieldTranslation, SingleNodeBuilder}; | ||
use kifmm::traits::field::{SourceToTargetTranslation, TargetTranslation}; | ||
use kifmm::traits::fmm::{DataAccess, Evaluate}; | ||
use kifmm::traits::tree::{SingleFmmTree, SingleTree}; | ||
use kifmm::tree::helpers::{points_fixture, points_fixture_sphere}; | ||
use rlst::{rlst_dynamic_array2, RawAccess, RawAccessMut}; | ||
|
||
fn laplace_potentials_f32(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("F32 Potentials"); | ||
|
||
group | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(15)); | ||
|
||
let n_sources = 1000000; | ||
let n_targets = 1000000; | ||
let sources = points_fixture_sphere::<f32>(n_sources); | ||
Check warning on line 22 in kifmm/benches/laplace_f32_amd_sphere.rs GitHub Actions / Rust style checks (--features "strict")
|
||
let targets = points_fixture_sphere::<f32>(n_targets); | ||
|
||
|
||
let nvecs = 1; | ||
let tmp = vec![1.0; n_sources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(f32, [n_sources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
|
||
// 3 Digits | ||
{ | ||
// FFT based M2L for a vector of charges | ||
// FMM parameters | ||
let n_crit = None; | ||
let depth = Some(5); | ||
let e = 5; | ||
let expansion_order = vec![e; depth.unwrap() as usize + 1]; | ||
let prune_empty = true; | ||
let block_size = Some(64); | ||
|
||
let mut fmm_fft = SingleNodeBuilder::new(false) | ||
.tree(sources.data(), targets.data(), n_crit, depth, prune_empty) | ||
.unwrap() | ||
.parameters( | ||
charges.data(), | ||
&expansion_order, | ||
Laplace3dKernel::new(), | ||
GreenKernelEvalType::Value, | ||
FftFieldTranslation::new(block_size), | ||
) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
group.bench_function(format!("M2L=FFT digits=3"), |b| { | ||
b.iter(|| fmm_fft.evaluate()) | ||
}); | ||
|
||
group.bench_function(format!("M2L=FFT digits=3, M2L "), |b| { | ||
b.iter(|| { | ||
for level in 2..=fmm_fft.tree().target_tree().depth() { | ||
fmm_fft.m2l(level).unwrap(); | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function(format!("M2L=FFT digits=3, P2P "), |b| { | ||
b.iter(|| fmm_fft.p2p().unwrap()) | ||
}); | ||
|
||
// BLAS based M2L for a vector of charges | ||
// FMM parameters | ||
let n_crit = None; | ||
let depth = Some(4); | ||
let e = 3; | ||
let expansion_order = vec![e; depth.unwrap() as usize + 1]; | ||
let prune_empty = true; | ||
let surface_diff = Some(2); | ||
let svd_mode = crate::FmmSvdMode::new(true, None, None, Some(20), None); | ||
let svd_threshold = None; | ||
|
||
let mut fmm_blas = SingleNodeBuilder::new(false) | ||
.tree(sources.data(), targets.data(), n_crit, depth, prune_empty) | ||
.unwrap() | ||
.parameters( | ||
charges.data(), | ||
&expansion_order, | ||
Laplace3dKernel::new(), | ||
GreenKernelEvalType::Value, | ||
BlasFieldTranslationSaRcmp::new(svd_threshold, surface_diff, svd_mode), | ||
) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3"), |b| { | ||
b.iter(|| fmm_blas.evaluate()) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3, M2L "), |b| { | ||
b.iter(|| { | ||
for level in 2..=fmm_blas.tree().target_tree().depth() { | ||
fmm_blas.m2l(level).unwrap(); | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3, P2P "), |b| { | ||
Check warning on line 109 in kifmm/benches/laplace_f32_amd_sphere.rs GitHub Actions / Rust style checks (--features "strict")
|
||
b.iter(|| fmm_blas.p2p().unwrap()) | ||
}); | ||
|
||
} | ||
|
||
let nvecs = 5; | ||
let tmp = vec![1.0; n_sources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(f32, [n_sources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
|
||
// 3 Digits matrix | ||
{ | ||
// BLAS based M2L for a matrix of charges | ||
// FMM parameters | ||
let n_crit = None; | ||
let depth = Some(4); | ||
let e = 3; | ||
let expansion_order = vec![e; depth.unwrap() as usize + 1]; | ||
let prune_empty = true; | ||
let surface_diff = Some(2); | ||
let svd_mode = crate::FmmSvdMode::new(true, None, None, Some(20), None); | ||
let svd_threshold = None; | ||
|
||
let mut fmm_blas = SingleNodeBuilder::new(false) | ||
.tree(sources.data(), targets.data(), n_crit, depth, prune_empty) | ||
.unwrap() | ||
.parameters( | ||
charges.data(), | ||
&expansion_order, | ||
Laplace3dKernel::new(), | ||
GreenKernelEvalType::Value, | ||
BlasFieldTranslationSaRcmp::new(svd_threshold, surface_diff, svd_mode), | ||
) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3 nvecs=5"), |b| { | ||
b.iter(|| fmm_blas.evaluate()) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3 nvecs=5, M2L "), |b| { | ||
b.iter(|| { | ||
for level in 2..=fmm_blas.tree().target_tree().depth() { | ||
fmm_blas.m2l(level).unwrap(); | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3 nvecs=5, P2P "), |b| { | ||
b.iter(|| fmm_blas.p2p().unwrap()) | ||
}); | ||
} | ||
} | ||
|
||
criterion_group!(laplace_p_f32, laplace_potentials_f32); | ||
criterion_main!(laplace_p_f32); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
use std::time::Duration; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use green_kernels::{laplace_3d::Laplace3dKernel, types::GreenKernelEvalType}; | ||
use kifmm::fmm::types::FmmSvdMode; | ||
use kifmm::fmm::types::{BlasFieldTranslationSaRcmp, FftFieldTranslation, SingleNodeBuilder}; | ||
use kifmm::traits::field::{SourceToTargetTranslation, TargetTranslation}; | ||
use kifmm::traits::fmm::{DataAccess, Evaluate}; | ||
use kifmm::traits::tree::{SingleFmmTree, SingleTree}; | ||
use kifmm::tree::helpers::{points_fixture, points_fixture_oblate_spheroid}; | ||
use rlst::{rlst_dynamic_array2, RawAccess, RawAccessMut}; | ||
|
||
fn laplace_potentials_f32(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("F32 Potentials"); | ||
|
||
group | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(15)); | ||
|
||
let n_sources = 1000000; | ||
let n_targets = 1000000; | ||
let sources = points_fixture_oblate_spheroid::<f32>(n_sources, 1.0, 0.5); | ||
let targets = points_fixture_oblate_spheroid(n_targets, 1.0, 0.5); | ||
|
||
let nvecs = 1; | ||
let tmp = vec![1.0; n_sources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(f32, [n_sources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
|
||
// 3 Digits | ||
{ | ||
// FFT based M2L for a vector of charges | ||
// FMM parameters | ||
let n_crit = None; | ||
let depth = Some(5); | ||
let e = 5; | ||
let expansion_order = vec![e; depth.unwrap() as usize + 1]; | ||
let prune_empty = true; | ||
let block_size = Some(64); | ||
|
||
let mut fmm_fft = SingleNodeBuilder::new(false) | ||
.tree(sources.data(), targets.data(), n_crit, depth, prune_empty) | ||
.unwrap() | ||
.parameters( | ||
charges.data(), | ||
&expansion_order, | ||
Laplace3dKernel::new(), | ||
GreenKernelEvalType::Value, | ||
FftFieldTranslation::new(block_size), | ||
) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
group.bench_function(format!("M2L=FFT digits=3"), |b| { | ||
b.iter(|| fmm_fft.evaluate()) | ||
}); | ||
|
||
group.bench_function(format!("M2L=FFT digits=3, M2L "), |b| { | ||
b.iter(|| { | ||
for level in 2..=fmm_fft.tree().target_tree().depth() { | ||
fmm_fft.m2l(level).unwrap(); | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function(format!("M2L=FFT digits=3, P2P "), |b| { | ||
b.iter(|| fmm_fft.p2p().unwrap()) | ||
}); | ||
|
||
// BLAS based M2L for a vector of charges | ||
// FMM parameters | ||
let n_crit = None; | ||
let depth = Some(4); | ||
let e = 4; | ||
let expansion_order = vec![e; depth.unwrap() as usize + 1]; | ||
let prune_empty = true; | ||
let surface_diff = Some(1); | ||
let svd_mode = crate::FmmSvdMode::new(true, None, None, Some(5), None); | ||
let svd_threshold = None; | ||
|
||
let mut fmm_blas = SingleNodeBuilder::new(false) | ||
.tree(sources.data(), targets.data(), n_crit, depth, prune_empty) | ||
.unwrap() | ||
.parameters( | ||
charges.data(), | ||
&expansion_order, | ||
Laplace3dKernel::new(), | ||
GreenKernelEvalType::Value, | ||
BlasFieldTranslationSaRcmp::new(svd_threshold, surface_diff, svd_mode), | ||
) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3"), |b| { | ||
b.iter(|| fmm_blas.evaluate()) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3, M2L "), |b| { | ||
b.iter(|| { | ||
for level in 2..=fmm_blas.tree().target_tree().depth() { | ||
fmm_blas.m2l(level).unwrap(); | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3, P2P "), |b| { | ||
Check warning on line 108 in kifmm/benches/laplace_f32_amd_spheroid.rs GitHub Actions / Rust style checks (--features "strict")
|
||
b.iter(|| fmm_blas.p2p().unwrap()) | ||
}); | ||
|
||
} | ||
|
||
let nvecs = 5; | ||
let tmp = vec![1.0; n_sources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(f32, [n_sources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
|
||
// 3 Digits matrix | ||
{ | ||
// BLAS based M2L for a matrix of charges | ||
// FMM parameters | ||
let n_crit = None; | ||
let depth = Some(4); | ||
let e = 4; | ||
let expansion_order = vec![e; depth.unwrap() as usize + 1]; | ||
let prune_empty = true; | ||
let surface_diff = Some(1); | ||
let svd_mode = crate::FmmSvdMode::new(true, None, None, Some(5), None); | ||
let svd_threshold = None; | ||
|
||
let mut fmm_blas = SingleNodeBuilder::new(false) | ||
.tree(sources.data(), targets.data(), n_crit, depth, prune_empty) | ||
.unwrap() | ||
.parameters( | ||
charges.data(), | ||
&expansion_order, | ||
Laplace3dKernel::new(), | ||
GreenKernelEvalType::Value, | ||
BlasFieldTranslationSaRcmp::new(svd_threshold, surface_diff, svd_mode), | ||
) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3 nvecs=5"), |b| { | ||
b.iter(|| fmm_blas.evaluate()) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3 nvecs=5, M2L "), |b| { | ||
b.iter(|| { | ||
for level in 2..=fmm_blas.tree().target_tree().depth() { | ||
fmm_blas.m2l(level).unwrap(); | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function(format!("M2L=BLAS digits=3 nvecs=5, P2P "), |b| { | ||
b.iter(|| fmm_blas.p2p().unwrap()) | ||
}); | ||
} | ||
} | ||
|
||
criterion_group!(laplace_p_f32, laplace_potentials_f32); | ||
criterion_main!(laplace_p_f32); |
Oops, something went wrong.