ESyS-Particle  4.0.1
Public Member Functions | Protected Member Functions | List of all members
CVarMPIBuffer Class Reference

MPI send/recv buffer with automagically adjusted size. More...

#include <mpivbuf.h>

Inheritance diagram for CVarMPIBuffer:
Inheritance graph
[legend]
Collaboration diagram for CVarMPIBuffer:
Collaboration graph
[legend]

Public Member Functions

 CVarMPIBuffer (MPI_Comm, int size=16)
virtual void clear ()
virtual void sendTo (int, int)
virtual void NBsendTo (int, int)
virtual void initSendTo (int, int)
virtual void wait ()
virtual void receiveFrom (int src=MPI_ANY_SOURCE, int tag=MPI_ANY_TAG)
virtual void append (int)
virtual void append (double)
virtual void append (const char *)
virtual void append (const Vec3 &V)
virtual int pop_int ()
virtual double pop_double ()
virtual void pop_doubles (double *, int)
virtual std::string pop_string ()
virtual void broadcast (int)
virtual void receiveBroadcast (int)
- Public Member Functions inherited from AMPIBufferPP
 AMPIBufferPP (MPI_Comm comm)
- Public Member Functions inherited from AMPIBuffer
 AMPIBuffer (MPI_Comm comm)
virtual Vec3 pop_vector ()
const MPI_Status & status ()

Protected Member Functions

void grow ()
void growTo (int)

Additional Inherited Members

- Protected Attributes inherited from AMPIBuffer
MPI_Comm m_comm
 the MPI Communicator used for the send/recv operations
MPI_Status m_status

Detailed Description

MPI send/recv buffer with automagically adjusted size.

CVarMPIBuffer implements a send/receive buffer with variable size. The buffer grows automatically if neccesary with each append operation and when the a message is received. It is never automatically shrunk. Both append and send/recv operations slower than a constant size buffer (CMPIBuffer)

Author
Steffen Abe $Revision$ $Date$
Todo:

implement checks for locking

use exeption handling for error checking

Constructor & Destructor Documentation

CVarMPIBuffer::CVarMPIBuffer ( MPI_Comm  comm,
int  size = 16 
)

Constructor. Allocates the buffer and sets the MPI communicator to be used for send/receive operations. If the initial buffer size is not given a buffer of initial size 16 is allocated.

Parameters
commthe MPI communicator
sthe initial size of the buffer, defaults to 16

References AMPIBuffer::m_comm.

Member Function Documentation

void CVarMPIBuffer::append ( int  i)
virtual
void CVarMPIBuffer::append ( double  d)
virtual

Append a double to the buffer. If necessary, the buffer is enlarged.

Warning
currently does not check if there is enough free space to allocate larger buffer
See Also
grow()

Implements AMPIBuffer.

References grow(), and AMPIBuffer::m_comm.

Here is the call graph for this function:

void CVarMPIBuffer::append ( const char *  str)
virtual

Append a string to the buffer. If necessary, the buffer is enlarged.

Warning
currently does not check if there is enough free space to allocate larger buffer
See Also
grow()

Implements AMPIBuffer.

References grow(), and AMPIBuffer::m_comm.

Here is the call graph for this function:

void CVarMPIBuffer::broadcast ( int  root)
virtual
void CVarMPIBuffer::grow ( )
protected

Grows the buffer to twice its current size, thus guaranteeing that append works in amortized constant time.

References growTo().

Referenced by append().

Here is the call graph for this function:

Here is the caller graph for this function:

void CVarMPIBuffer::growTo ( int  size)
protected

Grows the buffer to a given size. If the buffer is already larger that the given size, nothing is done. Used by receiveFrom.

Parameters
sizesize to which the buffer is grown

Referenced by grow(), receiveBroadcast(), and receiveFrom().

Here is the caller graph for this function:

void CVarMPIBuffer::initSendTo ( int  dest,
int  tag 
)
virtual

Initate send,lock buffer and immediately return (equivalent to MPI_Isend)

Parameters
destthe rank of the destination process in the current communicator
tagthe message tag

References BasicCon::Critical(), and AMPIBuffer::m_comm.

Here is the call graph for this function:

void CVarMPIBuffer::NBsendTo ( int  dest,
int  tag 
)
virtual

Nonblocking version of CVarMPIBuffer::sendTo. Uses MPI_Isend and is (should be) thus deadlock-safe.

Parameters
destthe rank of the destination process in the current communicator
tagthe message tag
Warning
It is not checked if the destination actually exists.

References AMPIBuffer::m_comm.

double CVarMPIBuffer::pop_double ( )
virtual
void CVarMPIBuffer::pop_doubles ( double *  dbl,
int  ndb 
)
virtual

pop an array of doubles from a buffer

Implements AMPIBuffer.

References AMPIBuffer::m_comm.

int CVarMPIBuffer::pop_int ( )
virtual
std::string CVarMPIBuffer::pop_string ( )
virtual

Pops a string from the buffer. The first for bytes are interpreted as int, giving the length of the string (without terminating '\0'), the rest as the characters.

Warning
no consistency check, i.e. it is not checked if the length is smaller than the buffersize.
Returns
the double.
See Also
CVarMPISingle::pop_int()

Implements AMPIBuffer.

References AMPIBuffer::m_comm.

Referenced by TSubLattice< T >::addBondedIG(), TSubLattice< T >::addBondedMesh2DIG(), TSubLattice< T >::addBondedTriMeshIG(), TSubLattice< T >::addCappedBondedIG(), TSubLattice< T >::addDamping(), TSubLattice< T >::addMesh2D(), TSubLattice< T >::addMesh2DIG(), TSubLattice< T >::addPairIG(), TRotSubLattice< T >::addRotBondedIG(), TRotSubLattice< T >::addRotThermBondedIG(), TSubLattice< T >::addShortBondedIG(), TSubLattice< T >::addSingleIG(), TSubLattice< T >::addTaggedPairIG(), TSubLattice< T >::addTriMesh(), TSubLattice< T >::addTriMeshIG(), TSubLattice< T >::addWall(), TSubLattice< T >::applyForceToWall(), TSubLattice< T >::getMesh2DStress(), TSubLattice< T >::getMeshFaceRef(), TSubLattice< T >::getMeshNodeRef(), TSubLattice< T >::getTriMeshForce(), TSubLattice< T >::getWallForce(), TSubLattice< T >::getWallPos(), TSubLattice< T >::moveSingleNode(), TSubLattice< T >::moveTaggedNodes(), TSubLattice< T >::moveWallBy(), TSubLattice< T >::removeIG(), TSubLattice< T >::setExIG(), TSubLattice< T >::setVelocityOfWall(), TSubLattice< T >::setWallNormal(), and CSubLatticeControler::translateMeshBy().

Here is the caller graph for this function:

void CVarMPIBuffer::receiveBroadcast ( int  root)
virtual

receive broadcast

Parameters
rootthe root of the broadcast

References growTo(), and AMPIBuffer::m_comm.

Referenced by TSubLattice< T >::addBondedIG(), TSubLattice< T >::addBondedMesh2DIG(), TSubLattice< T >::addBondedTriMeshIG(), TSubLattice< T >::addBondedWIG(), TSubLattice< T >::addCappedBondedIG(), TSubLattice< T >::addDamping(), TSubLattice< T >::addDirBondedWIG(), TSubLattice< T >::addElasticWIG(), TSubLattice< T >::addMesh2D(), TSubLattice< T >::addMesh2DIG(), TSubLattice< T >::addPairIG(), TRotSubLattice< T >::addRotBondedIG(), TRotSubLattice< T >::addRotThermBondedIG(), TSubLattice< T >::addShortBondedIG(), TSubLattice< T >::addSingleIG(), TSubLattice< T >::addTaggedPairIG(), TSubLattice< T >::addTriMesh(), TSubLattice< T >::addTriMeshIG(), TSubLattice< T >::addViscWIG(), TSubLattice< T >::addWall(), TSubLattice< T >::applyForceToWall(), TSubLattice< T >::getMesh2DStress(), TSubLattice< T >::getMeshFaceRef(), TSubLattice< T >::getMeshNodeRef(), TSubLattice< T >::getTriMeshForce(), TSubLattice< T >::getWallForce(), TSubLattice< T >::getWallPos(), ASubLattice::initComplex(), CSubLatticeControler::makeLattice(), TSubLattice< T >::moveParticleTo(), TSubLattice< T >::moveSingleNode(), TSubLattice< T >::moveTaggedNodes(), TSubLattice< T >::moveTaggedParticlesBy(), TSubLattice< T >::moveWallBy(), TSubLattice< T >::removeIG(), CheckPointer::saveRestartable(), TSubLattice< T >::setExIG(), TRotSubLattice< T >::setParticleAngularVelocity(), TSubLattice< T >::setParticleDensity(), TSubLattice< T >::setParticleNonDynamic(), TSubLattice< T >::setParticleNonRot(), TSubLattice< T >::setParticleNonTrans(), TSubLattice< T >::setParticleVelocity(), TSubLattice< T >::setTaggedParticleVel(), TSubLattice< T >::setVelocityOfWall(), CSubLatticeControler::setVerbosity(), TSubLattice< T >::setWallNormal(), TSubLattice< T >::tagParticleNearestTo(), and CSubLatticeControler::translateMeshBy().

Here is the call graph for this function:

Here is the caller graph for this function:

void CVarMPIBuffer::receiveFrom ( int  src = MPI_ANY_SOURCE,
int  tag = MPI_ANY_TAG 
)
virtual

Receives a message from a given source and stores it in the buffer.The size of the buffer is automatically adjusted so it will be big enough to fit the message. For this reason 2 messages are received, the first one for the size of the data, the second one for the data. If no source and no tag are given, any message from any source is accepted.

Parameters
srcrank of the sender in the current communicator, defaults to MPI_ANY_SOURCE
tagthe message tag, defaults to MPI_ANY_TAG

Implements AMPIBufferPP.

References growTo(), and AMPIBuffer::m_comm.

Here is the call graph for this function:

void CVarMPIBuffer::sendTo ( int  dest,
int  tag 
)
virtual

Sends the contents of the buffer to a given destination. There are actually two messages sent, the first one announces the size of the buffer so the buffer on the receiving end can be grown if necessary, the second one does the transfer of the data. It uses buffered sends (MPI_Bsend) and it thus deadlock-save

Parameters
destthe rank of the destination process in the current communicator
tagthe message tag
Warning
It is not checked if the destination actually exists.
Overlapping requests can deadlock.

Implements AMPIBufferPP.

References AMPIBuffer::m_comm.

void CVarMPIBuffer::wait ( )
virtual

Wait for completion of transaction on this buffer. If completed, unlock buffer and return


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