OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::CommunicationBuffer Class Referenceabstract

Class CommunicationBuffer provides abstraction for communication buffer. More...

#include <combuff.h>

+ Inheritance diagram for oofem::CommunicationBuffer:
+ Collaboration diagram for oofem::CommunicationBuffer:

Public Member Functions

 CommunicationBuffer (MPI_Comm comm, int size, bool dynamic=0)
 
 CommunicationBuffer (MPI_Comm comm, bool dynamic=0)
 Constructor. Creates empty buffer, using given communicator for packing. More...
 
virtual ~CommunicationBuffer ()
 Destructor. More...
 
virtual int resize (int newSize)=0
 Resizes buffer to given size. More...
 
virtual void init ()=0
 Initializes buffer to empty state. More...
 
virtual void initForPacking ()=0
 Initialize for packing. More...
 
virtual void initForUnpacking ()=0
 Initialize for Unpacking (data already received) More...
 
virtual int read (bool &data)
 Reads a bool value from data. More...
 
virtual int write (bool data)
 Writes a bool value. More...
 
virtual int givePackSizeOfInt (int count)
 
virtual int givePackSizeOfDouble (int count)
 
virtual int givePackSizeOfChar (int count)
 
virtual int givePackSizeOfBool (int count)
 
virtual int givePackSizeOfLong (int count)
 
Services for buffer sending/receiving
virtual int iSend (int dest, int tag)=0
 Starts standard mode, nonblocking send. More...
 
virtual int iRecv (int source, int tag, int count=0)=0
 Starts standard mode, nonblocking receive. More...
 
virtual int testCompletion ()=0
 Tests if the operation identified by this->request is complete. More...
 
virtual int waitCompletion ()=0
 Waits until a completion of a nonblocking communication. More...
 
virtual int bcast (int root)=0
 Initializes broadcast over collaborating processes. More...
 
- Public Member Functions inherited from oofem::DataStream
virtual ~DataStream ()
 Destructor. More...
 
virtual int read (int *data, int count)=0
 Reads count integer values into array pointed by data. More...
 
int read (int &data)
 
virtual int read (unsigned long *data, int count)=0
 Reads count unsigned long values into array pointed by data. More...
 
int read (unsigned long &data)
 
virtual int read (long *data, int count)=0
 Reads count long values into array pointed by data. More...
 
int read (long &data)
 
virtual int read (double *data, int count)=0
 Reads count double values into array pointed by data. More...
 
int read (double &data)
 
virtual int read (char *data, int count)=0
 Reads count char values into array pointed by data. More...
 
int read (char &data)
 
int read (std::string &data)
 Reads a string (stored as an int for the length followed by char*). More...
 
virtual int write (const int *data, int count)=0
 Writes count integer values from array pointed by data. More...
 
int write (int data)
 
virtual int write (const unsigned long *data, int count)=0
 Writes count unsigned long values from array pointed by data. More...
 
int write (unsigned long data)
 
virtual int write (const long *data, int count)=0
 Writes count long values from array pointed by data. More...
 
int write (long data)
 
virtual int write (const double *data, int count)=0
 Writes count double values from array pointed by data. More...
 
int write (double data)
 
virtual int write (const char *data, int count)=0
 Writes count char values from array pointed by data. More...
 
int write (char data)
 
int write (const std::string &data)
 Reads a string (stored as an int for the length followed by char*). More...
 
int write (const char *data)
 Writes a string (wrapper needed, otherwise write(bool) is called ) More...
 

Protected Attributes

MPI_Comm communicator
 

Detailed Description

Class CommunicationBuffer provides abstraction for communication buffer.

buffer is used as input or output buffer to various communication services provided by message parsing libraries. It provides methods for buffer initialization and resizing, methods for packing and/or unpacking data to/from buffer. Multiple messages can be packed/unpacked into/from buffer. The services for packing/unpacking take care about multiple messages stored, they maintain proper current buffer position for data inserting/retrieval. Interface to low level message parsing function is provided, allowing to send and receive buffer to selected destination.

Definition at line 208 of file combuff.h.

Constructor & Destructor Documentation

oofem::CommunicationBuffer::CommunicationBuffer ( MPI_Comm  comm,
int  size,
bool  dynamic = 0 
)
inline

Definition at line 213 of file combuff.h.

oofem::CommunicationBuffer::CommunicationBuffer ( MPI_Comm  comm,
bool  dynamic = 0 
)
inline

Constructor. Creates empty buffer, using given communicator for packing.

Definition at line 217 of file combuff.h.

virtual oofem::CommunicationBuffer::~CommunicationBuffer ( )
inlinevirtual

Destructor.

Definition at line 221 of file combuff.h.

References oofem::DataStream::read(), and oofem::DataStream::write().

Member Function Documentation

virtual int oofem::CommunicationBuffer::bcast ( int  root)
pure virtual

Initializes broadcast over collaborating processes.

The whole buffer size is broadcasted. All buffers participating in broadcast should have the same size.

Parameters
rootRank of broadcast root.
Returns
MPI_SUCCESS if ok.

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

int oofem::CommunicationBuffer::givePackSizeOfBool ( int  count)
virtual

Implements oofem::DataStream.

Definition at line 292 of file combuff.C.

Referenced by oofem::ProcessCommunicatorBuff::givePackSizeOfBool().

int oofem::CommunicationBuffer::givePackSizeOfChar ( int  count)
virtual

Implements oofem::DataStream.

Definition at line 285 of file combuff.C.

Referenced by oofem::ProcessCommunicatorBuff::givePackSizeOfChar().

int oofem::CommunicationBuffer::givePackSizeOfDouble ( int  count)
virtual

Implements oofem::DataStream.

Definition at line 278 of file combuff.C.

Referenced by oofem::ProcessCommunicatorBuff::givePackSizeOfDouble().

int oofem::CommunicationBuffer::givePackSizeOfLong ( int  count)
virtual

Implements oofem::DataStream.

Definition at line 299 of file combuff.C.

Referenced by oofem::ProcessCommunicatorBuff::givePackSizeOfLong().

virtual void oofem::CommunicationBuffer::init ( )
pure virtual

Initializes buffer to empty state.

All packed data are lost.

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::ProcessCommunicatorBuff::initRecvBuff(), and oofem::ProcessCommunicatorBuff::initSendBuff().

virtual void oofem::CommunicationBuffer::initForPacking ( )
pure virtual
virtual void oofem::CommunicationBuffer::initForUnpacking ( )
pure virtual

Initialize for Unpacking (data already received)

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::ProcessCommunicatorBuff::initForUnpacking().

virtual int oofem::CommunicationBuffer::iRecv ( int  source,
int  tag,
int  count = 0 
)
pure virtual

Starts standard mode, nonblocking receive.

The buffer must be large enough to receive all data.

Parameters
sourceRank of source.
tagMessage tag.
countNumber of elements to receive (bytes). Causes receive buffer to resize to count elements. If zero (default value) buffer is not resized.
Returns
MPI_SUCCESS if ok.

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::Natural2GlobalOrdering::init(), and oofem::ProcessCommunicatorBuff::initReceive().

virtual int oofem::CommunicationBuffer::iSend ( int  dest,
int  tag 
)
pure virtual

Starts standard mode, nonblocking send.

Parameters
destRank of destination.
tagMessage tag.
Returns
MPI_SUCCESS if ok.

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::Natural2GlobalOrdering::init(), and oofem::ProcessCommunicatorBuff::initSend().

virtual int oofem::CommunicationBuffer::resize ( int  newSize)
pure virtual

Resizes buffer to given size.

If buffer size is to be enlarged, then previously packed data are kept in new buffer. Otherwise buffer is cleared using init service. Current implementation only performs buffer growing, request for size decrease is ignored to avoid reallocation if further request for growing is encountered.

Parameters
newSizeNew buffer size in bytes.
Returns
Nonzero if successful.

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::Natural2GlobalOrdering::init(), oofem::ProcessCommunicatorBuff::resizeReceiveBuffer(), and oofem::ProcessCommunicatorBuff::resizeSendBuffer().

virtual int oofem::CommunicationBuffer::testCompletion ( )
pure virtual

Tests if the operation identified by this->request is complete.

In such case, true is returned and if communication was initiated by nonblocking send/receive, then request handle is set to MPI_REQUEST_NULL. Otherwise call returns flag=false.

Returns
Nonzero if operation complete, zero otherwise.

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::ProcessCommunicatorBuff::receiveCompleted(), oofem::ProcessCommunicatorBuff::sendCompleted(), and oofem::ProcessCommunicatorBuff::testCompletion().

virtual int oofem::CommunicationBuffer::waitCompletion ( )
pure virtual

Waits until a completion of a nonblocking communication.

The completion of a send operation indicates that the sender is now free to update the locations in the send buffer, the completion of a receive operation indicates that the receive buffer contains the received message, the receiver is now free to access it, and that the status object is set. If the communication object associated with this request was created (nonblocking send or receive call), then the object is deallocated by the call to MPI_WAIT and the request handle is set to MPI_REQUEST_NULL.

Returns
Nonzero if ...

Implemented in oofem::StaticCommunicationBuffer, and oofem::DynamicCommunicationBuffer.

Referenced by oofem::ProcessCommunicatorBuff::waitCompletion().

Member Data Documentation


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

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:34 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011