Skip to main content

pmap

Function pmap 

Source
pub fn pmap<C, T, U, E, F>(
    world: &C,
    domain: &Domain,
    options: PmapOptions,
    root_items: Option<Vec<T>>,
    f: F,
) -> Result<Option<Vec<U>>, PmapError>
where C: Communicator, T: Serialize + DeserializeOwned + Send, U: Serialize + DeserializeOwned + Send, E: Display + Send, F: Fn(T) -> Result<U, E> + Send + Sync,
Expand description

Dynamically maps root-owned items across MPI ranks and each rank’s explicit Rayon domain.

Every rank must call this collective in the same order with identical options. Only options.root supplies items and receives ordered results. The call must originate on the MPI initialization/main thread outside every Rayon worker, and MPI must provide MPI_THREAD_FUNNELED or stronger. Callback state may borrow non-'static data while satisfying the stated Rayon Send/Sync bounds; values retain the serialization bounds required by remote execution.

Local execution is pmap_lanes with RayonLanes: the coordinator keeps MPI progress on the calling thread while lanes execute local batches, so when PmapOptions::prefetch is true each remote domain may hold one additional batch and blocking task/result transfer overlaps adjacent batch execution. The root domain remains capacity one, and all MPI calls remain on the calling thread.

§Errors

Returns PmapErrorKind::Preflight when a rank lacks a pooled, admitted domain, enters from a Rayon worker, or disagrees about options; PmapErrorKind::User with a converged error key when a callback fails; PmapErrorKind::Wire or PmapErrorKind::Protocol for transport or protocol failures; and PmapErrorKind::Reentrant when pmap is already active on this thread.