Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
ObjectCommunicator< CLASS > Class Template Reference

#include <ObjectCommunicator.hpp>

+ Inheritance diagram for ObjectCommunicator< CLASS >:
+ Collaboration diagram for ObjectCommunicator< CLASS >:

Public Member Functions

 ObjectCommunicator ()
 
void SendObject (boost::shared_ptr< CLASS > const pObject, unsigned destinationProcess, unsigned tag)
 
void ISendObject (boost::shared_ptr< CLASS > const pObject, unsigned destinationProcess, unsigned tag)
 
boost::shared_ptr< CLASS > RecvObject (unsigned sourceProcess, unsigned tag, MPI_Status &status)
 
void IRecvObject (unsigned sourceProcess, unsigned tag)
 
boost::shared_ptr< CLASS > GetRecvObject ()
 
boost::shared_ptr< CLASS > SendRecvObject (boost::shared_ptr< CLASS > const pSendObject, unsigned destinationProcess, unsigned sendTag, unsigned sourceProcess, unsigned sourceTag, MPI_Status &status)
 

Private Attributes

char * mRecvBuffer
 
std::vector< char * > mSendBuffer
 
std::vector< std::string > mSendString
 
unsigned mRecvBufferLength
 
unsigned mSendBufferLength
 
MPI_Request mMpiRequest
 
bool mIsWriting
 

Detailed Description

template<typename CLASS>
class ObjectCommunicator< CLASS >

This is a helper class to enable classes that can be serialized to be sent using PetSc MPI communication. The object is serialized in to a string of characters, and then de-serialized on the receive process.

Definition at line 57 of file ObjectCommunicator.hpp.

Constructor & Destructor Documentation

◆ ObjectCommunicator()

template<typename CLASS >
ObjectCommunicator< CLASS >::ObjectCommunicator ( )

Member Function Documentation

◆ GetRecvObject()

template<typename CLASS >
boost::shared_ptr< CLASS > ObjectCommunicator< CLASS >::GetRecvObject ( )

Obtain a proper object once a call to IRecv has completed

Returns
a boost shared pointer to a receive object

Definition at line 244 of file ObjectCommunicator.hpp.

References EXCEPTION.

◆ IRecvObject()

template<typename CLASS >
void ObjectCommunicator< CLASS >::IRecvObject ( unsigned  sourceProcess,
unsigned  tag 
)

Post an asynchronous receive for an object

Parameters
sourceProcessthe process from which the data will be received
tagthe unique identifier code

Definition at line 233 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

◆ ISendObject()

template<typename CLASS >
void ObjectCommunicator< CLASS >::ISendObject ( boost::shared_ptr< CLASS > const  pObject,
unsigned  destinationProcess,
unsigned  tag 
)

Send an object.

Parameters
pObjectA pointer to the object to be sent
destinationProcessthe index of the process to send the data to
taga unique identifier tag for this communication

Definition at line 187 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

◆ RecvObject()

template<typename CLASS >
boost::shared_ptr< CLASS > ObjectCommunicator< CLASS >::RecvObject ( unsigned  sourceProcess,
unsigned  tag,
MPI_Status &  status 
)

Receive an object

Parameters
sourceProcessthe process from which the data will be received
tagthe unique identifier code
statuspointer to the MPI status
Returns
A pointer to the object returned.

Definition at line 211 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

◆ SendObject()

template<typename CLASS >
void ObjectCommunicator< CLASS >::SendObject ( boost::shared_ptr< CLASS > const  pObject,
unsigned  destinationProcess,
unsigned  tag 
)

Send an object.

Parameters
pObjectA pointer to the object to be sent
destinationProcessthe index of the process to send the data to
taga unique identifier tag for this communication

Definition at line 166 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

◆ SendRecvObject()

template<typename CLASS >
boost::shared_ptr< CLASS > ObjectCommunicator< CLASS >::SendRecvObject ( boost::shared_ptr< CLASS > const  pSendObject,
unsigned  destinationProcess,
unsigned  sendTag,
unsigned  sourceProcess,
unsigned  sourceTag,
MPI_Status &  status 
)

Send and receive an object

Parameters
pSendObjecta pointer to the object to send
destinationProcessthe rank of the target process
sendTagthe tag to send with.
sourceProcessthe process from which the data will be received
sourceTagthe tag to receive with
statusa reference to an MPI_Status object.
Returns
A pointer to the object returned.

Definition at line 276 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

Member Data Documentation

◆ mIsWriting

template<typename CLASS >
bool ObjectCommunicator< CLASS >::mIsWriting
private

A flag, used as a lock to ensure that we don't accidentally start overwriting the above buffer, mRecvBuffer

Definition at line 84 of file ObjectCommunicator.hpp.

◆ mMpiRequest

template<typename CLASS >
MPI_Request ObjectCommunicator< CLASS >::mMpiRequest
private

An MPI_Request used in MPI_Irecv

Definition at line 81 of file ObjectCommunicator.hpp.

◆ mRecvBuffer

template<typename CLASS >
char* ObjectCommunicator< CLASS >::mRecvBuffer
private

A buffer for use in asynchronous communication

Definition at line 62 of file ObjectCommunicator.hpp.

◆ mRecvBufferLength

template<typename CLASS >
unsigned ObjectCommunicator< CLASS >::mRecvBufferLength
private

The size of a string we are waiting for in an asynchronous receive

Definition at line 75 of file ObjectCommunicator.hpp.

◆ mSendBuffer

template<typename CLASS >
std::vector<char* > ObjectCommunicator< CLASS >::mSendBuffer
private

A group of buffers for use in asynchronous communication. There's one for each process so that a non-blocking send request won't accidentally overwrite a message which is actively being communicated to another remote process

Definition at line 67 of file ObjectCommunicator.hpp.

Referenced by ObjectCommunicator< CLASS >::ObjectCommunicator().

◆ mSendBufferLength

template<typename CLASS >
unsigned ObjectCommunicator< CLASS >::mSendBufferLength
private

The size of a string we are sending

Definition at line 78 of file ObjectCommunicator.hpp.

◆ mSendString

template<typename CLASS >
std::vector<std::string> ObjectCommunicator< CLASS >::mSendString
private

A group of strings for use in asynchronous communication. There's one for each process so that a non-blocking send request won't accidentally overwrite a message which is actively being communicated to another remote process

Definition at line 72 of file ObjectCommunicator.hpp.

Referenced by ObjectCommunicator< CLASS >::ObjectCommunicator().


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