fpmas 1.6
Public Member Functions | Static Public Attributes | List of all members
fpmas::api::communication::MpiCommunicator Class Referenceabstract

#include <communication.h>

Inheritance diagram for fpmas::api::communication::MpiCommunicator:
Inheritance graph
[legend]

Public Member Functions

virtual int getRank () const =0
 
virtual int getSize () const =0
 
virtual void send (const void *data, int count, MPI_Datatype datatype, int destination, int tag)=0
 
virtual void send (const DataPack &data, MPI_Datatype datatype, int destination, int tag)=0
 
virtual void send (int destination, int tag)=0
 
virtual void Isend (const void *data, int count, MPI_Datatype datatype, int destination, int tag, Request &request)=0
 
virtual void Isend (const DataPack &data, MPI_Datatype datatype, int destination, int tag, Request &request)=0
 
virtual void Isend (int destination, int tag, Request &request)=0
 
virtual void Issend (const void *data, int count, MPI_Datatype datatype, int destination, int tag, Request &request)=0
 
virtual void Issend (const DataPack &data, MPI_Datatype datatype, int destination, int tag, Request &request)=0
 
virtual void Issend (int destination, int tag, Request &request)=0
 
virtual void probe (MPI_Datatype type, int source, int tag, Status &status)=0
 
virtual bool Iprobe (MPI_Datatype type, int source, int tag, Status &status)=0
 
virtual void recv (int source, int tag, Status &status=Status::IGNORE)=0
 
virtual void recv (void *buffer, int count, MPI_Datatype datatype, int source, int tag, Status &status)=0
 
virtual void recv (DataPack &data, MPI_Datatype datatype, int source, int tag, Status &status)=0
 
virtual bool test (Request &request)=0
 
virtual void wait (Request &request)=0
 
virtual void waitAll (std::vector< Request > &requests)=0
 
virtual std::unordered_map< int, DataPackallToAll (std::unordered_map< int, DataPack > export_map, MPI_Datatype datatype)=0
 
virtual std::vector< DataPackgather (DataPack data, MPI_Datatype datatype, int root)=0
 
virtual std::vector< DataPackallGather (DataPack data, MPI_Datatype datatype)=0
 
virtual DataPack bcast (DataPack data, MPI_Datatype datatype, int root)=0
 
virtual void barrier ()=0
 

Static Public Attributes

static MPI_Datatype IGNORE_TYPE = MPI_INT
 

Detailed Description

MpiCommunicator interface.

Defines a low-level wrapper around MPI functions to make it more C++ compliant.

A limited set of functions, that are actually used in the fpmas library, have been adapted. More functions might be added in the future.

Constructor & Destructor Documentation

◆ ~MpiCommunicator()

virtual fpmas::api::communication::MpiCommunicator::~MpiCommunicator ( )
inlinevirtual

Member Function Documentation

◆ getRank()

virtual int fpmas::api::communication::MpiCommunicator::getRank ( ) const
pure virtual

Returns the rank of this communicator.

Returns
rank

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ getSize()

virtual int fpmas::api::communication::MpiCommunicator::getSize ( ) const
pure virtual

Returns the size of the group to which this communicator belongs.

Returns
group size

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ send() [1/3]

virtual void fpmas::api::communication::MpiCommunicator::send ( const void *  data,
int  count,
MPI_Datatype  datatype,
int  destination,
int  tag 
)
pure virtual

Sends data to destination (blocking, asynchronous).

This corresponds to the MPI standard mode. In this case, it is up to the MPI implementation to decide if the message is buffered or not (for example, depending on the message size):

  • If the message is buffered, the method returns once data has been copied to the buffer.
  • Else, the method returns only when the matching recv() has been initiated and data is sent, what might produce some deadlock behavior. See the Isend() method to prevent such situations.
Parameters
datainput buffer
countitems count in the buffer
datatypeMPI type of the data to send
destinationrank of the destination process
tagmessage tag

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ send() [2/3]

virtual void fpmas::api::communication::MpiCommunicator::send ( const DataPack data,
MPI_Datatype  datatype,
int  destination,
int  tag 
)
pure virtual

Equivalent to send(data.buffer, data.count, datatype, destination, tag)

Parameters
datainput DataPack
datatypeMPI type of the data to send
destinationrank of the destination process
tagmessage tag

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ send() [3/3]

virtual void fpmas::api::communication::MpiCommunicator::send ( int  destination,
int  tag 
)
pure virtual

Sends a void message to destination (blocking, asynchronous).

This might be useful to send END message for example, when only a message tag without body might be enough.

Parameters
destinationrank of the destination process
tagmessage tag

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Isend() [1/3]

virtual void fpmas::api::communication::MpiCommunicator::Isend ( const void *  data,
int  count,
MPI_Datatype  datatype,
int  destination,
int  tag,
Request request 
)
pure virtual

Sends data to destination (non-blocking, asynchronous).

The FPMAS implementation always copy the input data to the input Request.

The method returns immediately, without waiting for the message to be buffered or received by the destination process.

The operation must be completed with wait() or waitAll() so that the request object is properly freed.

Parameters
datainput buffer
countitems count in the buffer
datatypeMPI type of the data to send
destinationrank of the destination process
tagmessage tag
requestoutput Request

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Isend() [2/3]

virtual void fpmas::api::communication::MpiCommunicator::Isend ( const DataPack data,
MPI_Datatype  datatype,
int  destination,
int  tag,
Request request 
)
pure virtual

Equivalent to send(data.buffer, data.count, datatype, destination, tag, request)

Parameters
datainput DataPack
datatypeMPI type of the data to send
destinationrank of the destination process
tagmessage tag
requestoutput Request

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Isend() [3/3]

virtual void fpmas::api::communication::MpiCommunicator::Isend ( int  destination,
int  tag,
Request request 
)
pure virtual

Sends a void message to destination (non-blocking, asynchronous).

This might be useful to send END message for example, when only a message tag without body might be enough.

Parameters
destinationrank of the destination process
tagmessage tag
requestoutput Request

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Issend() [1/3]

virtual void fpmas::api::communication::MpiCommunicator::Issend ( const void *  data,
int  count,
MPI_Datatype  datatype,
int  destination,
int  tag,
Request request 
)
pure virtual

Sends data to destination (non-blocking, synchronous).

Contrary to the default MPI specification, the specified data buffer can be reused immediately when the method return. This is allowed because the specified data is copied to the input request.

In consequence, the Request must be completed using either test(Request&) or wait(Request&) to properly free the data buffer with the specified request.

The request completes when it is guaranteed that the message has been received by the destination process.

Parameters
datainput buffer
countitems count in the buffer
datatypeMPI type of the data to send
destinationrank of the destination process
tagmessage tag
requestoutput Request

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Issend() [2/3]

virtual void fpmas::api::communication::MpiCommunicator::Issend ( const DataPack data,
MPI_Datatype  datatype,
int  destination,
int  tag,
Request request 
)
pure virtual

Equivalent to Issend(data.buffer, data.count, datatype, destination, tag, request).

Parameters
datainput DataPack
datatypeMPI type of the data to send
destinationrank of the destination process
tagmessage tag
requestoutput Request

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Issend() [3/3]

virtual void fpmas::api::communication::MpiCommunicator::Issend ( int  destination,
int  tag,
Request request 
)
pure virtual

Sends a void message to destination (non-blocking, synchronous).

This might be useful to send notification messages when only a message tag without body might be enough.

The test(Request&) or wait(Request&) functions can be used to wait for completion.

The request completes when it is guaranteed that the message has been received by the destination process.

Parameters
destinationrank of the destination process
tagmessage tag
requestoutput Request

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ probe()

virtual void fpmas::api::communication::MpiCommunicator::probe ( MPI_Datatype  type,
int  source,
int  tag,
Status status 
)
pure virtual

Blocking probe.

Blocks until a message with the specified tag is received from source.

Upon return, the output status contains information about the message to receive.

Parameters
typeexpected message type
sourcesource rank
tagrecv tag
statusMPI status

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ Iprobe()

virtual bool fpmas::api::communication::MpiCommunicator::Iprobe ( MPI_Datatype  type,
int  source,
int  tag,
Status status 
)
pure virtual

Non-blocking probe.

Returns true if and only if a message with the specified tag can be received from source.

Upon return, the output status contains information about the message to receive.

Parameters
typeexpected message type
sourcesource rank
tagrecv tag
statusMPI status
Returns
true iff a message is available

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ recv() [1/3]

virtual void fpmas::api::communication::MpiCommunicator::recv ( int  source,
int  tag,
Status status = Status::IGNORE 
)
pure virtual

Receives a message without data.

Completes an eventually corresponding synchronous send operation.

Parameters
sourcerank of the process to receive from
tagmessage tag
statusoutput MPI status

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ recv() [2/3]

virtual void fpmas::api::communication::MpiCommunicator::recv ( void *  buffer,
int  count,
MPI_Datatype  datatype,
int  source,
int  tag,
Status status 
)
pure virtual

Receives data from source into buffer.

The length of the output buffer should be large enough to contain the message to receive. probe() and Iprobe() might be use to query the length of a message before receiving it.

Parameters
bufferoutput buffer
countitems count to receive
datatypeMPI type of the data to receive
sourcerank of the process to receive from
tagmessage tag
statusoutput MPI status

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ recv() [3/3]

virtual void fpmas::api::communication::MpiCommunicator::recv ( DataPack data,
MPI_Datatype  datatype,
int  source,
int  tag,
Status status 
)
pure virtual

Equivalent to recv(data.buffer, data.count, datatype, source, tag, status)

Parameters
dataoutput DataPack
datatypeMPI type of the data to receive
sourcerank of the process to receive from
tagmessage tag
statusoutput MPI status

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ test()

virtual bool fpmas::api::communication::MpiCommunicator::test ( Request request)
pure virtual

Tests if the input request is complete.

Might be use to check the status of requests performed using non-blocking communication methods.

Moreover, the request internal data buffer is freed if completion is detected.

Parameters
requestRequest to test
Returns
true iff the request is complete

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ wait()

virtual void fpmas::api::communication::MpiCommunicator::wait ( Request request)
pure virtual

Waits for the input request to complete.

Can be used to complete non-blocking communications. Upon return, the request internal data buffer is freed.

Parameters
requestRequest to wait

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ waitAll()

virtual void fpmas::api::communication::MpiCommunicator::waitAll ( std::vector< Request > &  requests)
pure virtual

Waits for the completion of all requests.

Can be used to complete non-blocking communications. Upon return, all requests internal data buffers are freed.

Parameters
requestsRequests to wait

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ allToAll()

virtual std::unordered_map< int, DataPack > fpmas::api::communication::MpiCommunicator::allToAll ( std::unordered_map< int, DataPack export_map,
MPI_Datatype  datatype 
)
pure virtual

Performs a complete data exchange among processor.

The export_map is a [rank, data] map : each DataPack is sent to the corresponding rank. The map is not required to contain an entry (i.e. data to send) for all available ranks.

From each process, received data is gathered by origin rank in the returned [rank, data] map.

Parameters
export_mapdata to export to each process
datatypeMPI type of the data to send / receive
Returns
data received from each process

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ gather()

virtual std::vector< DataPack > fpmas::api::communication::MpiCommunicator::gather ( DataPack  data,
MPI_Datatype  datatype,
int  root 
)
pure virtual

Gathers data at root.

All processes (including root), specify data to send to root. If the current process rank corresponds to root, sent data, ordered by rank, are returned in the output vector. Else, an empty vector is returned.

Notice that input DataPacks might have different length, and can be empty for some processes.

Parameters
datadata to send to root
datatypeMPI datatype
rootrank of the root process
Returns
if rank == root, a vector containing gathered data, else an empty vector.

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ allGather()

virtual std::vector< DataPack > fpmas::api::communication::MpiCommunicator::allGather ( DataPack  data,
MPI_Datatype  datatype 
)
pure virtual

Gathers data on all processes.

Each process sends a data instance, and all sent data are received on all processes, ordered by rank. In consequence, vectors returned on all processes are the same.

Notice that input DataPacks might have different length, and can be empty for some processes.

Parameters
datato send to all processes
datatypeMPI datatype
Returns
data sent by all processes

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ bcast()

virtual DataPack fpmas::api::communication::MpiCommunicator::bcast ( DataPack  data,
MPI_Datatype  datatype,
int  root 
)
pure virtual

Broadcasts data.

data is sent from root to all other processes, and received data is returned (including at root). On other processes than root, the data parameter is ignored.

Notice that the input DataPack might be empty.

Parameters
datadata to broadcast
datatypeMPI datatype
rootrank of the process from which data is sent
Returns
received data from root

Implemented in fpmas::communication::MpiCommunicatorBase.

◆ barrier()

virtual void fpmas::api::communication::MpiCommunicator::barrier ( )
pure virtual

Defines a synchronization barrier.

Blocks the caller until all processes have called it. The call returns at any process only after all processes have entered the call.

Implemented in fpmas::communication::MpiCommunicatorBase.

Member Data Documentation

◆ IGNORE_TYPE

MPI_Datatype fpmas::api::communication::MpiCommunicator::IGNORE_TYPE = MPI_INT
static

Datatype used for recv / send operation without data.

See also
send(int, int, int)
recv(int, int, int)

The documentation for this class was generated from the following files: