With the power of rayon
and mpi
, internode and intranode parallelism is achieved for simple tasks.
See examples/simple.rs
.
```rust
use std::sync::Arc;
use balancer::Balancer; use mpi::environment::Universe;
fn main() { let universe = Arc::new(mpi::initialize().unwrap()); experiment(universe.clone()); experiment(universe.clone()); }
fn experiment(universe: Arc
// Define task
let work = |x: &f64| x * x;
// Initialize balancer, work and collect
let verbose = false;
let balancer = Balancer::new(universe, verbose);
balancer.work_local(&data, work);
let output = balancer.collect();
// That's it!
// Let's do some verification
if balancer.rank == 0 {
for (expected, actual) in data.iter().map(work).zip(output.as_ref().unwrap()) {
assert_eq!(expected, *actual);
}
}
} ```