ESyS-Particle  2.3.4
CMPIVarSGBufferRoot Class Reference

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

#include <mpisgvbuf.h>

Inheritance diagram for CMPIVarSGBufferRoot:
Collaboration diagram for CMPIVarSGBufferRoot:

Public Member Functions

 CMPIVarSGBufferRoot (MPI_Comm, int isize=16)
 
virtual ~CMPIVarSGBufferRoot ()
 
virtual void clear ()
 
virtual void gather ()
 
virtual void scatter ()
 
virtual void append (int, int)
 
virtual void append (double, int)
 
virtual void append (const char *, int)
 
virtual int pop_int (int)
 
virtual double pop_double (int)
 
virtual void pop_doubles (int, double *, int)
 
- Public Member Functions inherited from AMPISGBufferRoot
 AMPISGBufferRoot (MPI_Comm)
 
virtual ~AMPISGBufferRoot ()
 
virtual void append (const Vec3 &, int)
 
virtual Vec3 pop_vector (int)
 
const MPI_Status & status ()
 

Protected Member Functions

void grow ()
 
void growTo (int)
 

Private Attributes

char * m_vbuffer
 
char * m_dummy_vbuffer
 dummy buffer sent by root to itself More...
 
int m_vbuffersize
 the size of the buffer per slice More...
 
int * m_position
 the current end of the content in each slice More...
 
int * m_rpos
 the number of bytes in the slice (i.e. m_position-m_displ) More...
 
int * m_recvcount
 the buffer for the transfer of the size of the vbuffer More...
 
int * m_displ
 
int m_ndummy
 

Additional Inherited Members

- Protected Attributes inherited from AMPISGBufferRoot
MPI_Comm m_comm
 the MPI communicator used for the scatter/gather operations More...
 
int m_rank
 the rank in this communicator More...
 
int m_size
 size of the communicator More...
 
int m_int_increment
 
int m_dbl_increment
 the "packing size" of int/double More...
 
MPI_Status m_status
 

Detailed Description

class for variable size scatter/gather buffer, root component

Author
Steffen Abe $Revision$ $Date$

Constructor & Destructor Documentation

◆ CMPIVarSGBufferRoot()

CMPIVarSGBufferRoot::CMPIVarSGBufferRoot ( MPI_Comm  comm,
int  isize = 16 
)

Constructor for CMPISGBufferRoot

Parameters
commthe MPI communicator
isizeinitial buffer size per slice, default 16 byte

References m_displ, m_dummy_vbuffer, m_position, m_recvcount, m_rpos, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

◆ ~CMPIVarSGBufferRoot()

CMPIVarSGBufferRoot::~CMPIVarSGBufferRoot ( )
virtual

Member Function Documentation

◆ append() [1/3]

void CMPIVarSGBufferRoot::append ( const char *  str,
int  nslice 
)
virtual

Append a C-string to a given slice of the buffer.

Parameters
strthe string
nslicethe nr. of the slice
Warning
No check for overflow

Implements AMPISGBufferRoot.

References grow(), esys::lsm::bpu::len(), AMPISGBufferRoot::m_comm, m_displ, AMPISGBufferRoot::m_int_increment, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ append() [2/3]

void CMPIVarSGBufferRoot::append ( double  d,
int  nslice 
)
virtual

Append a double to a given slice of the buffer.

Parameters
dthe double
nslicethe nr. of the slice
Warning
No check for overflow

Implements AMPISGBufferRoot.

References grow(), AMPISGBufferRoot::m_comm, AMPISGBufferRoot::m_dbl_increment, m_displ, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ append() [3/3]

void CMPIVarSGBufferRoot::append ( int  i,
int  nslice 
)
virtual

Append an integer to a given slice of the buffer.

Parameters
ithe integer
nslicethe nr. of the slice
Warning
No check for overflow

Implements AMPISGBufferRoot.

References grow(), AMPISGBufferRoot::m_comm, m_displ, AMPISGBufferRoot::m_int_increment, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ clear()

void CMPIVarSGBufferRoot::clear ( )
virtual

◆ gather()

void CMPIVarSGBufferRoot::gather ( )
virtual

Send data to the root process, using MPI_Gather and MPI_Gatherv. The receive buffer grows to fit the data if neccessary.

Implements AMPISGBufferRoot.

References growTo(), AMPISGBufferRoot::m_comm, m_displ, m_dummy_vbuffer, m_position, AMPISGBufferRoot::m_rank, m_recvcount, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

Here is the call graph for this function:

◆ grow()

void CMPIVarSGBufferRoot::grow ( )
protected

Grows the buffer to twice its current size, thus guaranteeing that append works in amortized constant time. Currently grows the buffer homogeneously, i.e. all slices have the same size.

Warning
no check if there is enough space for the new buffer

References m_displ, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

Referenced by append().

Here is the caller graph for this function:

◆ growTo()

void CMPIVarSGBufferRoot::growTo ( int  size)
protected

References m_displ, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

Referenced by gather().

Here is the caller graph for this function:

◆ pop_double()

double CMPIVarSGBufferRoot::pop_double ( int  nslice)
virtual

Pops an double from a given slice of the the buffer.

Parameters
nslicethe nr. of the slice
Returns
the double.
Warning
No check for underflow

Implements AMPISGBufferRoot.

References AMPISGBufferRoot::m_comm, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

◆ pop_doubles()

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

◆ pop_int()

int CMPIVarSGBufferRoot::pop_int ( int  nslice)
virtual

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

Parameters
nslicethe nr. of the slice
Returns
the int.
Warning
No check for underflow

Implements AMPISGBufferRoot.

References AMPISGBufferRoot::m_comm, m_position, AMPISGBufferRoot::m_size, m_vbuffer, and m_vbuffersize.

◆ scatter()

void CMPIVarSGBufferRoot::scatter ( )
virtual

Send data to all other members of the communicator, using MPI_Scatter/MPI_Scatterv

Implements AMPISGBufferRoot.

References AMPISGBufferRoot::m_comm, m_displ, m_dummy_vbuffer, m_ndummy, m_position, AMPISGBufferRoot::m_rank, m_rpos, AMPISGBufferRoot::m_size, and m_vbuffer.

Member Data Documentation

◆ m_displ

int* CMPIVarSGBufferRoot::m_displ
private

◆ m_dummy_vbuffer

char* CMPIVarSGBufferRoot::m_dummy_vbuffer
private

dummy buffer sent by root to itself

Referenced by CMPIVarSGBufferRoot(), gather(), scatter(), and ~CMPIVarSGBufferRoot().

◆ m_ndummy

int CMPIVarSGBufferRoot::m_ndummy
private

Referenced by scatter().

◆ m_position

int* CMPIVarSGBufferRoot::m_position
private

the current end of the content in each slice

Referenced by append(), clear(), CMPIVarSGBufferRoot(), gather(), grow(), growTo(), pop_double(), pop_doubles(), pop_int(), scatter(), and ~CMPIVarSGBufferRoot().

◆ m_recvcount

int* CMPIVarSGBufferRoot::m_recvcount
private

the buffer for the transfer of the size of the vbuffer

Referenced by CMPIVarSGBufferRoot(), gather(), and ~CMPIVarSGBufferRoot().

◆ m_rpos

int* CMPIVarSGBufferRoot::m_rpos
private

the number of bytes in the slice (i.e. m_position-m_displ)

Referenced by CMPIVarSGBufferRoot(), scatter(), and ~CMPIVarSGBufferRoot().

◆ m_vbuffer

char* CMPIVarSGBufferRoot::m_vbuffer
private

◆ m_vbuffersize

int CMPIVarSGBufferRoot::m_vbuffersize
private

the size of the buffer per slice

Referenced by append(), CMPIVarSGBufferRoot(), gather(), grow(), growTo(), pop_double(), pop_doubles(), and pop_int().


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