ESyS-Particle  2.3.4
CMPIBuffer Class Reference

Constant size MPI send/recv buffer. More...

#include <mpibuf.h>

Inheritance diagram for CMPIBuffer:
Collaboration diagram for CMPIBuffer:

Public Member Functions

 CMPIBuffer (MPI_Comm, int)
 
virtual ~CMPIBuffer ()
 
virtual void clear ()
 
virtual void sendTo (int, int)
 
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 *)
 
bool append_checked (int)
 
bool append_checked (double)
 
virtual int pop_int ()
 
virtual double pop_double ()
 
virtual void pop_doubles (double *, int)
 
virtual std::string pop_string ()
 
- Public Member Functions inherited from AMPIBufferPP
 AMPIBufferPP (MPI_Comm comm)
 
virtual ~AMPIBufferPP ()
 
- Public Member Functions inherited from AMPIBuffer
 AMPIBuffer (MPI_Comm comm)
 
virtual ~AMPIBuffer ()
 
virtual void append (const Vec3 &)
 
virtual Vec3 pop_vector ()
 
const MPI_Status & status ()
 

Private Attributes

char * m_buffer
 
int m_buffersize
 the size of the buffer More...
 
int m_position
 the current end of the content More...
 
int m_int_increment
 
int m_dbl_increment
 the "packing size" of int/double More...
 

Additional Inherited Members

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

Detailed Description

Constant size MPI send/recv buffer.

CMPIBuffer implements a send/receive buffer. MPI_pack/MPI_unpack is used the transfer arbitrary data. Type information is not transported. i.e. the user has to know the type of the content of a received message.

Author
Steffen Abe $Revision$ $Date$

Constructor & Destructor Documentation

◆ CMPIBuffer()

CMPIBuffer::CMPIBuffer ( MPI_Comm  comm,
int  s 
)

Constructor. Allocates the buffer and sets the MPI communicator to be used for send/receive operations.

Parameters
commthe MPI communicator
sthe size of the buffer

References m_buffer, m_buffersize, AMPIBuffer::m_comm, m_dbl_increment, m_int_increment, and m_position.

◆ ~CMPIBuffer()

CMPIBuffer::~CMPIBuffer ( )
virtual

References m_buffer.

Member Function Documentation

◆ append() [1/3]

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

Append a string to the buffer. The string appended is a normal (zero-terminated) C-string, but is internally handeled by packing the length frist and then the string.

Warning
No check for overflow

Implements AMPIBuffer.

References esys::lsm::bpu::len(), m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

Here is the call graph for this function:

◆ append() [2/3]

void CMPIBuffer::append ( double  d)
virtual

Append a double to the buffer.

Warning
No check for overflow

Implements AMPIBuffer.

References m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

◆ append() [3/3]

void CMPIBuffer::append ( int  i)
virtual

Append an integer to the buffer.

Warning
No check for overflow

Implements AMPIBuffer.

References m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

◆ append_checked() [1/2]

bool CMPIBuffer::append_checked ( double  d)

Append a double to the buffer with overflow check.

See also
CMPIBuffer::append_checked(int i)

References m_buffer, m_buffersize, AMPIBuffer::m_comm, m_dbl_increment, and m_position.

◆ append_checked() [2/2]

bool CMPIBuffer::append_checked ( int  i)

Append an integer to the buffer with overflow check. If the buffer is big enough the integer is appended, if not nothing is done.

Returns
true if the append succeded, false otherwise

References m_buffer, m_buffersize, AMPIBuffer::m_comm, m_int_increment, and m_position.

◆ clear()

virtual void CMPIBuffer::clear ( )
inlinevirtual

Implements AMPIBuffer.

References m_position.

◆ pop_double()

double CMPIBuffer::pop_double ( )
virtual

Pops a double from the buffer.

Warning
No check for underflow
Returns
the double.
See also
CMPIBuffer::pop_int()

Implements AMPIBuffer.

References m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

◆ pop_doubles()

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

pop an array of doubles from a buffer

Implements AMPIBuffer.

References m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

◆ pop_int()

int CMPIBuffer::pop_int ( )
virtual

Pops an integer from the buffer, i.e. it pops the last sizeof(MPI_INT) bytes of the buffer, interpreting them as an int.

Warning
No check for underflow
Returns
the int.

Implements AMPIBuffer.

References m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

◆ pop_string()

std::string CMPIBuffer::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
CMPISingle::pop_int()

Implements AMPIBuffer.

References esys::lsm::bpu::len(), m_buffer, m_buffersize, AMPIBuffer::m_comm, and m_position.

Here is the call graph for this function:

◆ receiveFrom()

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

Recieves a message from a given source and stores it in the buffer. It is assumed that the buffer is large enough the take the message. If no source and no tag are given, any message from any source is accepted.

Warning
No check if the buffer is big enough
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 m_buffer, m_buffersize, AMPIBuffer::m_comm, m_position, and AMPIBuffer::m_status.

◆ sendTo()

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

Sends the contents of the buffer to a given destination.

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

Implements AMPIBufferPP.

References m_buffer, AMPIBuffer::m_comm, and m_position.

Member Data Documentation

◆ m_buffer

◆ m_buffersize

int CMPIBuffer::m_buffersize
private

◆ m_dbl_increment

int CMPIBuffer::m_dbl_increment
private

the "packing size" of int/double

Referenced by append_checked(), and CMPIBuffer().

◆ m_int_increment

int CMPIBuffer::m_int_increment
private

Referenced by append_checked(), and CMPIBuffer().

◆ m_position

int CMPIBuffer::m_position
private

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