Skip to main content

hataori/
lib.rs

1//! Hataori: local data parallelism and an optional long-lived distributed runtime.
2
3mod domain;
4#[cfg(feature = "rayon")]
5mod local;
6mod map;
7#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
8mod mpi_check;
9#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
10mod placement;
11#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
12mod pmap;
13#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
14mod scheduler;
15#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
16mod wire;
17
18pub use domain::{
19    Domain, DomainAdmission, DomainBusy, DomainId, LocalMode, NegativeRank, Place,
20    UnsupportedDomainId,
21};
22#[cfg(feature = "rayon")]
23pub use domain::{DomainBuildError, PlacementStatus, PoolOwnership};
24#[cfg(feature = "runtime")]
25pub use hataori_algorithms as algorithms;
26#[cfg(feature = "runtime")]
27pub use hataori_algorithms::{
28    pmap, pmap_at, pmap_colocated, pmap_preferred_colocated, AlgorithmError, AlgorithmRegistryExt,
29    BatchActionToken, CollectiveRegistryExt, CollectiveToken, ControllerStats, PmapFuture,
30    PmapOptions,
31};
32#[cfg(feature = "runtime")]
33pub use hataori_runtime as runtime;
34
35#[cfg(feature = "runtime")]
36pub mod blocking {
37    use super::{algorithms, runtime};
38
39    pub fn pmap<A: runtime::Action>(
40        runtime: &mut runtime::Runtime,
41        options: algorithms::PmapOptions,
42        items: Vec<A>,
43        token: algorithms::BatchActionToken<A>,
44    ) -> Result<(Vec<A::Output>, algorithms::ControllerStats), algorithms::AlgorithmError> {
45        let future = algorithms::pmap(runtime, options, items, token)?;
46        runtime.block_on(future)
47    }
48}
49#[cfg(feature = "rayon")]
50pub use local::{map_in, MapInError};
51pub use map::{map, MapError};
52#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
53pub use placement::{broadcast, gather, scatter, PlacementError, PlacementErrorKind};
54#[cfg(all(any(feature = "mpi", feature = "rsmpi-rt"), not(feature = "runtime")))]
55pub use pmap::{pmap, PmapOptions};
56#[cfg(any(feature = "mpi", feature = "rsmpi-rt"))]
57pub use pmap::{PmapError, PmapErrorKind};
58
59#[cfg(all(feature = "mpi", feature = "rsmpi-rt"))]
60compile_error!("hataori: features `mpi` and `rsmpi-rt` are mutually exclusive");
61
62#[cfg(all(feature = "mpi", not(feature = "rsmpi-rt")))]
63#[allow(unused_imports)]
64use mpi_upstream as mpi_backend;
65
66#[cfg(all(feature = "rsmpi-rt", not(feature = "mpi")))]
67#[allow(unused_imports)]
68use mpi_runtime as mpi_backend;