-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
use std::time::Duration; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use green_kernels::traits::Kernel; | ||
use green_kernels::{helmholtz_3d::Helmholtz3dKernel, types::GreenKernelEvalType}; | ||
use kifmm::tree::helpers::points_fixture; | ||
use num::{Complex, One}; | ||
Check warning on line 7 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Rust style checks (--features "strict")
Check warning on line 7 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Rust style checks
|
||
use rlst::{c32, c64, rlst_dynamic_array2, RawAccess, RawAccessMut}; | ||
Check failure on line 8 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Run Rust tests (stable, mpich, --features "strict")
Check failure on line 8 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Run Rust tests (stable, openmpi, --features "strict")
Check failure on line 8 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Run Rust tests (stable, mpich, --features "strict")
|
||
|
||
|
||
fn multithreaded_direct_f64(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Multi Threaded Direct f64"); | ||
|
||
group | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(15)); | ||
|
||
{ | ||
let nsources = 20000; | ||
let ntargets = 20000; | ||
let sources = points_fixture::<f32>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f32>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f32; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_mt( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
|
||
{ | ||
let nsources = 100000; | ||
let ntargets = 100000; | ||
let sources = points_fixture::<f32>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f32>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
Check warning on line 56 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Rust style checks (--features "strict")
Check warning on line 56 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Rust style checks
|
||
let mut charges = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber =1f32; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_mt( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
|
||
{ | ||
let nsources = 500000; | ||
let ntargets = 500000; | ||
let sources = points_fixture::<f32>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f32>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f32; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_mt( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
fn singlethreaded_direct_f64(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Single Threaded Direct f64"); | ||
|
||
group | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(15)); | ||
|
||
{ | ||
let nsources = 5000; | ||
let ntargets = 5000; | ||
let sources = points_fixture::<f32>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f32>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f32; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_st( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
|
||
{ | ||
let nsources = 20000; | ||
let ntargets = 20000; | ||
let sources = points_fixture::<f32>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f32>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f32; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c32, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_st( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
criterion_group!(d_f64, multithreaded_direct_f64, singlethreaded_direct_f64); | ||
Check warning on line 177 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Rust style checks (--features "strict")
Check warning on line 177 in kifmm/benches/helmholtz_direct_f32.rs GitHub Actions / Rust style checks
|
||
|
||
criterion_main!(d_f64); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
use std::time::Duration; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use green_kernels::traits::Kernel; | ||
use green_kernels::{helmholtz_3d::Helmholtz3dKernel, types::GreenKernelEvalType}; | ||
use kifmm::tree::helpers::points_fixture; | ||
use num::{Complex, One}; | ||
Check warning on line 7 in kifmm/benches/helmholtz_direct_f64.rs GitHub Actions / Rust style checks (--features "strict")
Check warning on line 7 in kifmm/benches/helmholtz_direct_f64.rs GitHub Actions / Rust style checks
|
||
use rlst::{c64, rlst_dynamic_array2, RawAccess, RawAccessMut}; | ||
|
||
|
||
fn multithreaded_direct_f64(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Multi Threaded Direct f64"); | ||
|
||
group | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(15)); | ||
|
||
{ | ||
let nsources = 20000; | ||
let ntargets = 20000; | ||
let sources = points_fixture::<f64>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f64>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f64; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_mt( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
|
||
{ | ||
let nsources = 100000; | ||
let ntargets = 100000; | ||
let sources = points_fixture::<f64>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f64>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
Check warning on line 56 in kifmm/benches/helmholtz_direct_f64.rs GitHub Actions / Rust style checks (--features "strict")
Check warning on line 56 in kifmm/benches/helmholtz_direct_f64.rs GitHub Actions / Rust style checks
|
||
let mut charges = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber =1f64; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_mt( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
|
||
{ | ||
let nsources = 500000; | ||
let ntargets = 500000; | ||
let sources = points_fixture::<f64>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f64>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f64; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_mt( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
fn singlethreaded_direct_f64(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Single Threaded Direct f64"); | ||
|
||
group | ||
.sample_size(10) | ||
.measurement_time(Duration::from_secs(15)); | ||
|
||
{ | ||
let nsources = 5000; | ||
let ntargets = 5000; | ||
let sources = points_fixture::<f64>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f64>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f64; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_st( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
|
||
{ | ||
let nsources = 20000; | ||
let ntargets = 20000; | ||
let sources = points_fixture::<f64>(nsources, None, None, Some(0)); | ||
let targets = points_fixture::<f64>(ntargets, None, None, Some(1)); | ||
|
||
// FFT based M2L for a vector of charges | ||
let nvecs = 1; | ||
let tmp = vec![Complex::one(); nsources * nvecs]; | ||
let mut charges = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
charges.data_mut().copy_from_slice(&tmp); | ||
let wavenumber = 1f64; | ||
|
||
let kernel = Helmholtz3dKernel::new(wavenumber); | ||
|
||
let mut result = rlst_dynamic_array2!(c64, [nsources, nvecs]); | ||
|
||
group.bench_function(format!("N={nsources}"), |b| { | ||
b.iter(|| { | ||
kernel.evaluate_st( | ||
GreenKernelEvalType::Value, | ||
sources.data(), | ||
targets.data(), | ||
charges.data(), | ||
result.data_mut(), | ||
) | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
criterion_group!(d_f64, multithreaded_direct_f64, singlethreaded_direct_f64); | ||
Check warning on line 177 in kifmm/benches/helmholtz_direct_f64.rs GitHub Actions / Rust style checks (--features "strict")
Check warning on line 177 in kifmm/benches/helmholtz_direct_f64.rs GitHub Actions / Rust style checks
|
||
|
||
criterion_main!(d_f64); |