ObjectCommunicator< CLASS > Class Template Reference

#include <ObjectCommunicator.hpp>

Collaboration diagram for ObjectCommunicator< CLASS >:
Collaboration graph
[legend]

List of all members.

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

template<typename CLASS >
ObjectCommunicator< CLASS >::ObjectCommunicator (  )  [inline]

Member Function Documentation

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

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, ObjectCommunicator< CLASS >::mIsWriting, ObjectCommunicator< CLASS >::mMpiRequest, and ObjectCommunicator< CLASS >::mRecvBuffer.

Referenced by NodeBasedCellPopulation< DIM >::GetReceivedCells().

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

Post an asynchronous receive for an object

Parameters:
sourceProcess the process from which the data will be received
tag the unique identifier code

Definition at line 233 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld(), ObjectCommunicator< CLASS >::mIsWriting, ObjectCommunicator< CLASS >::mMpiRequest, and ObjectCommunicator< CLASS >::mRecvBuffer.

Referenced by NodeBasedCellPopulation< DIM >::NonBlockingSendCellsToNeighbourProcesses().

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

Send an object.

Parameters:
pObject A pointer to the object to be sent
destinationProcess the index of the process to send the data to
tag a unique identifier tag for this communication

Definition at line 187 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld(), ObjectCommunicator< CLASS >::mSendBuffer, ObjectCommunicator< CLASS >::mSendBufferLength, and ObjectCommunicator< CLASS >::mSendString.

Referenced by NodeBasedCellPopulation< DIM >::NonBlockingSendCellsToNeighbourProcesses().

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

Receive an object

Parameters:
sourceProcess the process from which the data will be received
tag the unique identifier code
status pointer to the MPI status
Returns:
A pointer to the object returned.

Definition at line 211 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

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

Send an object.

Parameters:
pObject A pointer to the object to be sent
destinationProcess the index of the process to send the data to
tag a unique identifier tag for this communication

Definition at line 166 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

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 
) [inline]

Send and receive an object

Parameters:
pSendObject a pointer to the object to send
destinationProcess the rank of the target process
sendTag the tag to send with.
sourceProcess the process from which the data will be received
sourceTag the tag to receive with
status a reference to an MPI_Status object.
Returns:
A pointer to the object returned.

Definition at line 276 of file ObjectCommunicator.hpp.

References PetscTools::GetWorld().

Referenced by NodeBasedCellPopulation< DIM >::SendCellsToNeighbourProcesses().


Member Data Documentation

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.

Referenced by ObjectCommunicator< CLASS >::GetRecvObject(), and ObjectCommunicator< CLASS >::IRecvObject().

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

An MPI_Request used in MPI_Irecv

Definition at line 81 of file ObjectCommunicator.hpp.

Referenced by ObjectCommunicator< CLASS >::GetRecvObject(), and ObjectCommunicator< CLASS >::IRecvObject().

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

A buffer for use in asynchronous communication

Definition at line 62 of file ObjectCommunicator.hpp.

Referenced by ObjectCommunicator< CLASS >::GetRecvObject(), and ObjectCommunicator< CLASS >::IRecvObject().

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.

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 >::ISendObject(), and ObjectCommunicator< CLASS >::ObjectCommunicator().

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

The size of a string we are sending

Definition at line 78 of file ObjectCommunicator.hpp.

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

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 >::ISendObject(), and ObjectCommunicator< CLASS >::ObjectCommunicator().


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

Generated by  doxygen 1.6.2