Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
nightly = ["pulp/nightly"]
# Treat warnings as a build error.
strict = []
sleef = ["rlst/sleef"]
default = []
mpi = ["dep:mpi", "dep:bempp-distributed-tools", "rlst/mpi"]
mpi = ["dep:mpi", "rlst/mpi"]


[package]
Expand All @@ -28,23 +27,21 @@ crate-type = ["lib", "staticlib", "cdylib"]
paste = "1.*"
libc = "0.2"
approx = { version = "0.5", features = ["num-complex"] }
rayon = "1.9"
rayon = "1.11"
num = "0.4"
num_cpus = "1"
rlst = { git = "https://github.com/linalg-rs/rlst.git" }
# rlst = { path = "../rlst", features = ["mpi"] }
rand = "0.8.5"
itertools = { version = "0.13.0", default-features = false }
rand = "0.9"
itertools = { version = "0.14", default-features = false }
coe-rs = "0.1.2"
pulp = { version = "0.21" }
bytemuck = "1.16.0"
pulp = { version = "0.22" }
bytemuck = "1.24.0"
hexf = "0.2.1"
mpi = { version = "0.8.*", optional = true }
bempp-distributed-tools = { git = "https://github.com/bempp/distributed_tools.git", optional = true }
mpi = { git = "https://github.com/rsmpi/rsmpi.git", optional = true }

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
rand_chacha = "0.3"
criterion = { version = "0.7", features = ["html_reports"] }
rand_chacha = "0.9"

[package.metadata.docs.rs]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
Expand All @@ -53,12 +50,12 @@ cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
wildcard_imports = "forbid"

[target.aarch64-apple-darwin.dev-dependencies]
blas-src = { version = "0.10", features = ["accelerate"]}
lapack-src = { version = "0.10", features = ["accelerate"]}
blas-src = { version = "0.14", features = ["accelerate"]}
lapack-src = { version = "0.13", features = ["accelerate"]}

[target.x86_64-unknown-linux-gnu.dev-dependencies]
blas-src = { version = "0.10", features = ["blis"]}
lapack-src = { version = "0.10", features = ["netlib"]}
blas-src = { version = "0.14", features = ["blis"]}
lapack-src = { version = "0.13", features = ["netlib"]}


[[bench]]
Expand Down
22 changes: 11 additions & 11 deletions benches/helmholtz_c32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ use criterion::{criterion_group, criterion_main, Criterion};
extern crate blas_src;
extern crate lapack_src;

use rlst::prelude::*;

use green_kernels::helmholtz_3d::Helmholtz3dKernel;
use green_kernels::traits::Kernel;
use green_kernels::types::GreenKernelEvalType;

use rand::SeedableRng;
use rlst::c32;
use rlst::rlst_dynamic_array;

const NPOINTS: usize = 1000;

pub fn helmholtz_c32_test_standard(c: &mut Criterion) {
let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0);

let mut sources = rlst_dynamic_array2!(f32, [3, NPOINTS]);
let mut targets = rlst_dynamic_array2!(f32, [3, NPOINTS]);
let mut sources = rlst_dynamic_array!(f32, [3, NPOINTS]);
let mut targets = rlst_dynamic_array!(f32, [3, NPOINTS]);

let mut charges = rlst_dynamic_array1!(c32, [NPOINTS]);
let mut charges = rlst_dynamic_array!(c32, [NPOINTS]);

let mut result = rlst_dynamic_array1!(c32, [NPOINTS]);
let mut result = rlst_dynamic_array!(c32, [NPOINTS]);

sources.fill_from_equally_distributed(&mut rng);
targets.fill_from(sources.r());
targets.fill_from(&sources);

charges.fill_from_standard_normal(&mut rng);

c.bench_function("Helmholtz evaluate c32", |b| {
b.iter(|| {
Helmholtz3dKernel::<c32>::new(1.0).evaluate_st(
GreenKernelEvalType::Value,
sources.data(),
targets.data(),
charges.data(),
result.data_mut(),
sources.data().unwrap(),
targets.data().unwrap(),
charges.data().unwrap(),
result.data_mut().unwrap(),
);
})
});
Expand Down
21 changes: 11 additions & 10 deletions benches/helmholtz_c64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use criterion::{criterion_group, criterion_main, Criterion};
extern crate blas_src;
extern crate lapack_src;

use rlst::prelude::*;
use rlst::c64;
use rlst::rlst_dynamic_array;

use green_kernels::helmholtz_3d::Helmholtz3dKernel;
use green_kernels::traits::Kernel;
Expand All @@ -16,26 +17,26 @@ const NPOINTS: usize = 1000;
pub fn helmholtz_c64_test_standard(c: &mut Criterion) {
let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0);

let mut sources = rlst_dynamic_array2!(f64, [3, NPOINTS]);
let mut targets = rlst_dynamic_array2!(f64, [3, NPOINTS]);
let mut sources = rlst_dynamic_array!(f64, [3, NPOINTS]);
let mut targets = rlst_dynamic_array!(f64, [3, NPOINTS]);

let mut charges = rlst_dynamic_array1!(c64, [NPOINTS]);
let mut charges = rlst_dynamic_array!(c64, [NPOINTS]);

let mut result = rlst_dynamic_array1!(c64, [NPOINTS]);
let mut result = rlst_dynamic_array!(c64, [NPOINTS]);

sources.fill_from_equally_distributed(&mut rng);
targets.fill_from(sources.r());
targets.fill_from(&sources);

charges.fill_from_standard_normal(&mut rng);

c.bench_function("Helmholtz evaluate c64", |b| {
b.iter(|| {
Helmholtz3dKernel::<c64>::new(1.0).evaluate_st(
GreenKernelEvalType::Value,
sources.data(),
targets.data(),
charges.data(),
result.data_mut(),
sources.data().unwrap(),
targets.data().unwrap(),
charges.data().unwrap(),
result.data_mut().unwrap(),
);
})
});
Expand Down
21 changes: 10 additions & 11 deletions benches/laplace_f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,38 @@ use criterion::{criterion_group, criterion_main, Criterion};
extern crate blas_src;
extern crate lapack_src;

use rlst::prelude::*;

use green_kernels::laplace_3d::Laplace3dKernel;
use green_kernels::traits::Kernel;
use green_kernels::types::GreenKernelEvalType;

use rand::SeedableRng;
use rlst::rlst_dynamic_array;

const NPOINTS: usize = 1000;

pub fn laplace_f32_test_standard(c: &mut Criterion) {
let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0);

let mut sources = rlst_dynamic_array2!(f32, [3, NPOINTS]);
let mut targets = rlst_dynamic_array2!(f32, [3, NPOINTS]);
let mut sources = rlst_dynamic_array!(f32, [3, NPOINTS]);
let mut targets = rlst_dynamic_array!(f32, [3, NPOINTS]);

let mut charges = rlst_dynamic_array1!(f32, [NPOINTS]);
let mut charges = rlst_dynamic_array!(f32, [NPOINTS]);

let mut result = rlst_dynamic_array1!(f32, [NPOINTS]);
let mut result = rlst_dynamic_array!(f32, [NPOINTS]);

sources.fill_from_equally_distributed(&mut rng);
targets.fill_from(sources.r());
targets.fill_from(&sources);

charges.fill_from_standard_normal(&mut rng);

c.bench_function("Laplace evaluate f32", |b| {
b.iter(|| {
Laplace3dKernel::<f32>::new().evaluate_st(
GreenKernelEvalType::Value,
sources.data(),
targets.data(),
charges.data(),
result.data_mut(),
sources.data().unwrap(),
targets.data().unwrap(),
charges.data().unwrap(),
result.data_mut().unwrap(),
);
})
});
Expand Down
21 changes: 10 additions & 11 deletions benches/laplace_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,38 @@ use criterion::{criterion_group, criterion_main, Criterion};
extern crate blas_src;
extern crate lapack_src;

use rlst::prelude::*;

use green_kernels::laplace_3d::Laplace3dKernel;
use green_kernels::traits::Kernel;
use green_kernels::types::GreenKernelEvalType;

use rand::SeedableRng;
use rlst::rlst_dynamic_array;

const NPOINTS: usize = 1000;

pub fn laplace_f64_test_standard(c: &mut Criterion) {
let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0);

let mut sources = rlst_dynamic_array2!(f64, [3, NPOINTS]);
let mut targets = rlst_dynamic_array2!(f64, [3, NPOINTS]);
let mut sources = rlst_dynamic_array!(f64, [3, NPOINTS]);
let mut targets = rlst_dynamic_array!(f64, [3, NPOINTS]);

let mut charges = rlst_dynamic_array1!(f64, [NPOINTS]);
let mut charges = rlst_dynamic_array!(f64, [NPOINTS]);

let mut result = rlst_dynamic_array1!(f64, [NPOINTS]);
let mut result = rlst_dynamic_array!(f64, [NPOINTS]);

sources.fill_from_equally_distributed(&mut rng);
targets.fill_from(sources.r());
targets.fill_from(&sources);

charges.fill_from_standard_normal(&mut rng);

c.bench_function("Laplace f64 evaluate", |b| {
b.iter(|| {
Laplace3dKernel::<f64>::new().evaluate_st(
GreenKernelEvalType::Value,
sources.data(),
targets.data(),
charges.data(),
result.data_mut(),
sources.data().unwrap(),
targets.data().unwrap(),
charges.data().unwrap(),
result.data_mut().unwrap(),
);
})
});
Expand Down
60 changes: 31 additions & 29 deletions examples/evaluate_distributed.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Distributed evaluation of sources and targets.

use green_kernels::traits::*;
use green_kernels::{laplace_3d::Laplace3dKernel, types::GreenKernelEvalType};
use green_kernels::{
laplace_3d::Laplace3dKernel,
traits::{DistributedKernelEvaluator, Kernel},
types::GreenKernelEvalType,
};
use mpi::traits::{Communicator, Root};
use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
use rlst::prelude::*;
use rlst::{assert_array_relative_eq, rlst_dynamic_array1, RawAccess, RawAccessMut};
use rlst::{assert_array_relative_eq, rlst_dynamic_array};

fn main() {
// Create the MPI communicator
Expand All @@ -24,23 +26,23 @@ fn main() {
// Create a Laplace kernel.
let kernel = Laplace3dKernel::<f64>::default();

let mut sources = rlst_dynamic_array1!(f64, [3 * n_sources]);
let mut targets = rlst_dynamic_array1!(f64, [3 * n_targets]);
let mut charges = rlst_dynamic_array1!(f64, [n_sources]);
let mut sources = rlst_dynamic_array!(f64, [3 * n_sources]);
let mut targets = rlst_dynamic_array!(f64, [3 * n_targets]);
let mut charges = rlst_dynamic_array!(f64, [n_sources]);

sources.fill_from_equally_distributed(&mut rng);
targets.fill_from_equally_distributed(&mut rng);
charges.fill_from_equally_distributed(&mut rng);

// Create the result vector.
let mut result = rlst_dynamic_array1!(f64, [n_targets]);
let mut result = rlst_dynamic_array!(f64, [n_targets]);

kernel.evaluate_distributed(
GreenKernelEvalType::Value,
sources.data(),
targets.data(),
charges.data(),
result.data_mut(),
sources.data().unwrap(),
targets.data().unwrap(),
charges.data().unwrap(),
result.data_mut().unwrap(),
false,
&world,
);
Expand All @@ -50,51 +52,51 @@ fn main() {
if world.rank() != 0 {
let root_process = world.process_at_rank(0);

root_process.gather_into(sources.data());
root_process.gather_into(targets.data());
root_process.gather_into(charges.data());
root_process.gather_into(result.data());
root_process.gather_into(sources.data().unwrap());
root_process.gather_into(targets.data().unwrap());
root_process.gather_into(charges.data().unwrap());
root_process.gather_into(result.data().unwrap());
} else {
let sources = {
let mut tmp = rlst_dynamic_array1!(f64, [3 * n_sources * world.size() as usize]);
let mut tmp = rlst_dynamic_array!(f64, [3 * n_sources * world.size() as usize]);
world
.this_process()
.gather_into_root(sources.data(), tmp.data_mut());
.gather_into_root(sources.data().unwrap(), tmp.data_mut().unwrap());
tmp
};

let targets = {
let mut tmp = rlst_dynamic_array1!(f64, [3 * n_targets * world.size() as usize]);
let mut tmp = rlst_dynamic_array!(f64, [3 * n_targets * world.size() as usize]);
world
.this_process()
.gather_into_root(targets.data(), tmp.data_mut());
.gather_into_root(targets.data().unwrap(), tmp.data_mut().unwrap());
tmp
};

let charges = {
let mut tmp = rlst_dynamic_array1!(f64, [n_sources * world.size() as usize]);
let mut tmp = rlst_dynamic_array!(f64, [n_sources * world.size() as usize]);
world
.this_process()
.gather_into_root(charges.data(), tmp.data_mut());
.gather_into_root(charges.data().unwrap(), tmp.data_mut().unwrap());
tmp
};

let result = {
let mut tmp = rlst_dynamic_array1!(f64, [n_targets * world.size() as usize]);
let mut tmp = rlst_dynamic_array!(f64, [n_targets * world.size() as usize]);
world
.this_process()
.gather_into_root(result.data(), tmp.data_mut());
.gather_into_root(result.data().unwrap(), tmp.data_mut().unwrap());
tmp
};

let mut expected = rlst_dynamic_array1!(f64, [n_targets * world.size() as usize]);
let mut expected = rlst_dynamic_array!(f64, [n_targets * world.size() as usize]);

kernel.evaluate_mt(
GreenKernelEvalType::Value,
sources.data(),
targets.data(),
charges.data(),
expected.data_mut(),
sources.data().unwrap(),
targets.data().unwrap(),
charges.data().unwrap(),
expected.data_mut().unwrap(),
);

assert_array_relative_eq!(result, expected, 1e-13);
Expand Down
Loading