Skip to main content

hataori/
lib.rs

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