fpmas 1.6
Public Types | Public Member Functions | List of all members
fpmas::communication::detail::TypedMpi< T, PackType > Class Template Reference

#include <communication.h>

Inheritance diagram for fpmas::communication::detail::TypedMpi< T, PackType >:
Inheritance graph
[legend]
Collaboration diagram for fpmas::communication::detail::TypedMpi< T, PackType >:
Collaboration graph
[legend]

Public Types

typedef PackType pack_type
 

Public Member Functions

 TypedMpi (api::communication::MpiCommunicator &comm)
 
std::unordered_map< int, std::vector< T > > migrate (std::unordered_map< int, std::vector< T > > export_map) override
 
std::unordered_map< int, T > allToAll (std::unordered_map< int, T > export_map) override
 
std::vector< T > gather (const T &, int root) override
 
std::vector< T > allGather (const T &) override
 
bcast (const T &, int root) override
 
void send (const T &, int, int) override
 
void Isend (const T &, int, int, Request &) override
 
void Issend (const T &, int, int, Request &) override
 
void probe (int source, int tag, Status &status) override
 
bool Iprobe (int source, int tag, Status &status) override
 
recv (int source, int tag, Status &status=Status::IGNORE) override
 
virtual std::unordered_map< int, std::vector< T > > migrate (std::unordered_map< int, std::vector< T > > export_map)=0
 
virtual std::unordered_map< int, T > allToAll (std::unordered_map< int, T > export_map)=0
 
virtual std::vector< T > gather (const T &data, int root)=0
 
virtual std::vector< T > allGather (const T &data)=0
 
virtual T bcast (const T &data, int root)=0
 
virtual void send (const T &data, int destination, int tag)=0
 
virtual void Isend (const T &data, int destination, int tag, Request &req)=0
 
virtual void Issend (const T &data, int destination, int tag, Request &req)=0
 
virtual void probe (int source, int tag, Status &status)=0
 
virtual bool Iprobe (int source, int tag, Status &status)=0
 
virtual T recv (int source, int tag, Status &status=Status::IGNORE)=0
 

Detailed Description

template<typename T, typename PackType>
class fpmas::communication::detail::TypedMpi< T, PackType >

An fpmas::io::datapack::BasicObjectPack based fpmas::api::communication::TypedMpi implementation.

Each T instance is serialized as a DataPack using the specified PackType, and sent as MPI_CHAR using the provided api::communication::MpiCommunicator.

This means that ANY TYPE that can be serialized / unserialized as PackType can be easily sent across processors through MPI using this class, preventing users from struggling with low-level MPI issues and custom MPI_Datatype definitions.

Template Parameters
Tdata to transmit, serializable into a PackType
PackTypeBasicObjectPack implementation (e.g.: fpmas::io::datapack::JsonPack, fpmas::io::datapack::ObjectPack, fpmas::io::datapack::LightObjectPack...)

Member Typedef Documentation

◆ pack_type

template<typename T , typename PackType >
typedef PackType fpmas::communication::detail::TypedMpi< T, PackType >::pack_type

BasicObjectPack implementation used to serialize data.

Constructor & Destructor Documentation

◆ TypedMpi()

template<typename T , typename PackType >
fpmas::communication::detail::TypedMpi< T, PackType >::TypedMpi ( api::communication::MpiCommunicator comm)
inline

TypedMpi constructor.

The specified MPI communicator will be used to perform actual message sending between processors.

To sum up, the role of this class is to serialize / unserialize input / output data, and transmit it to / from the underlying api::communication::MpiCommunicator instance.

Parameters
commreference to an MPI communicator instance

Member Function Documentation

◆ migrate()

template<typename T , typename PackType >
std::unordered_map< int, std::vector< T > > fpmas::communication::detail::TypedMpi< T, PackType >::migrate ( std::unordered_map< int, std::vector< T > >  export_map)
overridevirtual

Performs a migration of data across all processors.

The "migration" operation follows the same rules as MpiCommunicator::allToAll, except that vectors of T instances can be used, for convenience.

Parameters
export_mapvectors of data to send to each process
Returns
vectors of data received from each process

Implements fpmas::api::communication::TypedMpi< T >.

◆ allToAll()

template<typename T , typename PackType >
std::unordered_map< int, T > fpmas::communication::detail::TypedMpi< T, PackType >::allToAll ( std::unordered_map< int, T >  export_map)
overridevirtual

Performs a complete exchange of T instances among processor.

Follows the same rules as MpiCommunicator::allToAll().

Parameters
export_mapdata to export to each process
Returns
data received from each process

Implements fpmas::api::communication::TypedMpi< T >.

◆ gather()

template<typename T , typename PackType >
std::vector< T > fpmas::communication::detail::TypedMpi< T, PackType >::gather ( const T &  data,
int  root 
)
overridevirtual

Gathers T instances at root.

Follows the same rules as MpiCommunicator::gather().

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

Implements fpmas::api::communication::TypedMpi< T >.

◆ allGather()

template<typename T , typename PackType >
std::vector< T > fpmas::communication::detail::TypedMpi< T, PackType >::allGather ( const T &  data)
overridevirtual

Gathers T instances on all processes.

Follows the same rules as MpiCommunicator::allGather().

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

Implements fpmas::api::communication::TypedMpi< T >.

◆ bcast()

template<typename T , typename PackType >
T fpmas::communication::detail::TypedMpi< T, PackType >::bcast ( const T &  data,
int  root 
)
overridevirtual

Broadcasts a T instance to all processes.

Follows the same rules as MpiCommunicator::bcast().

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

Implements fpmas::api::communication::TypedMpi< T >.

◆ send()

template<typename T , typename PackType >
void fpmas::communication::detail::TypedMpi< T, PackType >::send ( const T &  data,
int  destination,
int  tag 
)
overridevirtual

Sends a T instance to destination (blocking).

Follows the same rules as MpiCommunicator::send().

Parameters
datareference to the T object to send to destination
destinationrank of the destination process
tagmessage tag

Implements fpmas::api::communication::TypedMpi< T >.

◆ Isend()

template<typename T , typename PackType >
void fpmas::communication::detail::TypedMpi< T, PackType >::Isend ( const T &  data,
int  destination,
int  tag,
Request req 
)
overridevirtual

Sends a T instance to destination (non-blocking).

Follows the same rules as MpiCommunicator::Isend().

Parameters
datareference to the T object to send to destination
destinationrank of the destination process
tagmessage tag
reqoutput Request

Implements fpmas::api::communication::TypedMpi< T >.

◆ Issend()

template<typename T , typename PackType >
void fpmas::communication::detail::TypedMpi< T, PackType >::Issend ( const T &  data,
int  destination,
int  tag,
Request req 
)
overridevirtual

Sends a T instance to destination (non-blocking, synchronous).

Follows the same rules as MpiCommunicator::Issend().

Parameters
datareference to the T object to send to destination
destinationrank of the destination process
tagmessage tag
reqoutput Request

Implements fpmas::api::communication::TypedMpi< T >.

◆ probe()

template<typename T , typename PackType >
void fpmas::communication::detail::TypedMpi< T, PackType >::probe ( int  source,
int  tag,
Status status 
)
overridevirtual

Blocking probe.

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

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

Parameters
sourcesource rank
tagrecv tag
statusMPI status

Implements fpmas::api::communication::TypedMpi< T >.

◆ Iprobe()

template<typename T , typename PackType >
bool fpmas::communication::detail::TypedMpi< T, PackType >::Iprobe ( int  source,
int  tag,
Status status 
)
overridevirtual

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 size of the message to receive.

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

Implements fpmas::api::communication::TypedMpi< T >.

◆ recv()

template<typename T , typename PackType >
T fpmas::communication::detail::TypedMpi< T, PackType >::recv ( int  source,
int  tag,
Status status = Status::IGNORE 
)
overridevirtual

Receives a T object from source.

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

Implements fpmas::api::communication::TypedMpi< T >.


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