ESyS-Particle  2.3.4
CMPIVarSGBufferLeaf Class Reference

class for variable size scatter/gather buffer, leaf component More...

#include <mpisgvbuf.h>

Inheritance diagram for CMPIVarSGBufferLeaf:
Collaboration diagram for CMPIVarSGBufferLeaf:

Public Member Functions

 CMPIVarSGBufferLeaf (MPI_Comm, int, int isize=16)
 
virtual ~CMPIVarSGBufferLeaf ()
 
virtual void clear ()
 
virtual void send ()
 
virtual void receive ()
 
virtual void append (int)
 
virtual void append (double)
 
virtual void append (const char *)
 
virtual int pop_int ()
 
virtual double pop_double ()
 
virtual void pop_doubles (double *, int)
 
virtual std::string pop_string ()
 
- Public Member Functions inherited from AMPISGBufferLeaf
 AMPISGBufferLeaf (MPI_Comm, int)
 
virtual ~AMPISGBufferLeaf ()
 
const MPI_Status & status ()
 
- 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 ()
 

Protected Member Functions

void grow ()
 
void growTo (int)
 

Private Attributes

char * m_vbuffer
 
int m_vbuffersize
 the size of the buffer More...
 
int m_position
 the current end of the content More...
 
int m_data_size
 

Additional Inherited Members

- Protected Attributes inherited from AMPISGBufferLeaf
int m_root
 rank of the root process More...
 
int m_int_increment
 
int m_dbl_increment
 the "packing size" of int/double More...
 
- 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

class for variable size scatter/gather buffer, leaf component

Author
Steffen Abe $Revision$ $Date$

Constructor & Destructor Documentation

◆ CMPIVarSGBufferLeaf()

CMPIVarSGBufferLeaf::CMPIVarSGBufferLeaf ( MPI_Comm  comm,
int  root,
int  isize = 16 
)

Constuctor for CMPISGBufferLeaf

Parameters
commthe MPI communicator
rootrank of the root process
isizeinitial size of the communication buffer, default 16

References m_position, m_vbuffer, and m_vbuffersize.

◆ ~CMPIVarSGBufferLeaf()

CMPIVarSGBufferLeaf::~CMPIVarSGBufferLeaf ( )
virtual

References m_vbuffer.

Member Function Documentation

◆ append() [1/3]

void CMPIVarSGBufferLeaf::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(), esys::lsm::bpu::len(), AMPIBuffer::m_comm, AMPISGBufferLeaf::m_int_increment, m_position, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ append() [2/3]

void CMPIVarSGBufferLeaf::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 AMPISGBufferLeaf.

References grow(), AMPIBuffer::m_comm, AMPISGBufferLeaf::m_dbl_increment, m_position, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ append() [3/3]

void CMPIVarSGBufferLeaf::append ( int  i)
virtual

Append an integer to the buffer. If necessary, the buffer is enlarged.

Warning
currently does not check if there is enough free space to allocate larger buffer

Implements AMPISGBufferLeaf.

References grow(), AMPIBuffer::m_comm, AMPISGBufferLeaf::m_int_increment, m_position, m_vbuffer, and m_vbuffersize.

Referenced by TSubLattice< T >::countParticles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void CMPIVarSGBufferLeaf::clear ( )
virtual

Implements AMPISGBufferLeaf.

References m_position.

◆ grow()

void CMPIVarSGBufferLeaf::grow ( )
protected

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

References m_position, m_vbuffer, and m_vbuffersize.

Referenced by append().

Here is the caller graph for this function:

◆ growTo()

void CMPIVarSGBufferLeaf::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

References m_position, m_vbuffer, and m_vbuffersize.

Referenced by receive().

Here is the caller graph for this function:

◆ pop_double()

double CMPIVarSGBufferLeaf::pop_double ( )
virtual

Pops a double from the buffer.

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

Implements AMPISGBufferLeaf.

References AMPIBuffer::m_comm, m_position, m_vbuffer, and m_vbuffersize.

◆ pop_doubles()

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

◆ pop_int()

int CMPIVarSGBufferLeaf::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 AMPISGBufferLeaf.

References AMPIBuffer::m_comm, m_position, m_vbuffer, and m_vbuffersize.

◆ pop_string()

std::string CMPIVarSGBufferLeaf::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 string.
See also
CVarMPISingle::pop_int()

Implements AMPISGBufferLeaf.

References esys::lsm::bpu::len(), AMPIBuffer::m_comm, m_position, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ receive()

void CMPIVarSGBufferLeaf::receive ( )
virtual

Receive data from root process, using MPI_Scatter/MPI_Scatterv. The buffer grows to fit the data, if neccesary.

Implements AMPISGBufferLeaf.

References growTo(), AMPIBuffer::m_comm, m_data_size, AMPISGBufferLeaf::m_root, m_vbuffer, m_vbuffersize, and NULL.

Here is the call graph for this function:

◆ send()

void CMPIVarSGBufferLeaf::send ( )
virtual

Send data to the root process, using MPI_Gather/MPI_Gatherv

Implements AMPISGBufferLeaf.

References AMPIBuffer::m_comm, m_position, AMPISGBufferLeaf::m_root, m_vbuffer, and NULL.

Referenced by TSubLattice< T >::countParticles().

Here is the caller graph for this function:

Member Data Documentation

◆ m_data_size

int CMPIVarSGBufferLeaf::m_data_size
private

Referenced by receive().

◆ m_position

int CMPIVarSGBufferLeaf::m_position
private

the current end of the content

Referenced by append(), clear(), CMPIVarSGBufferLeaf(), grow(), growTo(), pop_double(), pop_doubles(), pop_int(), pop_string(), and send().

◆ m_vbuffer

char* CMPIVarSGBufferLeaf::m_vbuffer
private

◆ m_vbuffersize

int CMPIVarSGBufferLeaf::m_vbuffersize
private

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