Skip to main content

class mpi_communicator

Declaration

class mpi_communicator : public communicator { /* full declaration omitted */ };

Description

MPI implementation of the communicator interface. Wraps an MPI_Comm, manages strided MPI datatypes for sends / receives and optionally maintains an inbound / outbound queue of pilot messages.

Inherits from: communicator

Member Variables

MPI_Comm m_mpi_comm = (static_cast<ompi_communicator_t *>(static_cast<void *>(&(ompi_mpi_comm_null))))
in_flight_pilot m_inbound_pilot
continually Irecv'd into after the first call to poll_inbound_pilots()
std::vector<in_flight_pilot> m_outbound_pilots
std::unordered_map<size_t, unique_datatype> m_scalar_type_cache
std::unordered_map<stride, unique_datatype> m_array_type_cache

Member Aliases

  • using unique_datatype = std::unique_ptr< std::remove_pointer_t<MPI_Datatype>, datatype_deleter>;

Member Function Overview

Inherited from communicator:

Member Functions

void collective_barrier()

Description

Blocks until all nodes in this communicator have called collective_barrier(). Must be ordered identically to all other collective operations on this communicator across all nodes.


[[nodiscard]] std::unique_ptr<communicator>
collective_clone()

Description

Creates a new communicator that is fully concurrent to this one, and which has its own "namespace" for peer-to-peer and collective operations. Must be ordered identically to all other collective operations on this communicator across all nodes.


node_id get_local_node_id() const

Description

Returns the 0-based id of the local node in the communicator.


MPI_Comm get_native() const

Description

Returns the underlying MPI_Comm. The result is never MPI_COMM_NULL.


size_t get_num_nodes() const

Description

Returns the number of nodes (processes) that are part of this communicator.


mpi_communicator(const mpi_communicator&)

Parameters

const mpi_communicator&

mpi_communicator(mpi_communicator&&)

Parameters

mpi_communicator&&

explicit mpi_communicator(
    collective_clone_from_tag tag,
    MPI_Comm mpi_comm)

Description

Creates a new mpi_communicator by cloning the given MPI_Comm, which must not be MPI_COMM_NULL.

Parameters

collective_clone_from_tag tag
MPI_Comm mpi_comm

mpi_communicator& operator=(
    const mpi_communicator&)

Parameters

const mpi_communicator&

mpi_communicator& operator=(mpi_communicator&&)

Parameters

mpi_communicator&&

[[nodiscard]] std::vector<inbound_pilot>
poll_inbound_pilots()

Description

Returns all inbound pilots received on this communicator since the last invocation of the same function. Never blocks.


[[nodiscard]] async_event receive_payload(
    node_id from,
    message_id msgid,
    void* base,
    const stride& stride)

Description

Begins receiving strided data (which was previously announced using an inbound_pilot) from the specified node. The base allocation must remain live until the returned event completes, and no element inside stride must be written to during that time.

Parameters

node_id from
message_id msgid
void* base
const stride& stride

void send_outbound_pilot(
    const outbound_pilot& pilot)

Description

Asynchronously sends a pilot message, returning without acknowledgement from the receiver. The pilot is copied internally and the reference does not need to remain live after the function returns.

Parameters

const outbound_pilot& pilot

[[nodiscard]] async_event send_payload(
    node_id to,
    message_id msgid,
    const void* base,
    const stride& stride)

Description

Begins sending strided data (that was previously announced using an outbound_pilot) to the specified node. The base allocation must remain live until the returned event completes, and no element inside stride must be written to during that time.

Parameters

node_id to
message_id msgid
const void* base
const stride& stride

~mpi_communicator()

Description

Communicator destruction is a collective operation like collective_barrier. The user must ensure that any asynchronous operation is already complete when the destructor runs.


MPI_Datatype get_array_type(const stride& stride)

Parameters

const stride& stride

MPI_Datatype get_scalar_type(size_t bytes)

Parameters

size_t bytes