OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::DynamicCommunicationBuffer Class Reference

#include <dyncombuff.h>

+ Inheritance diagram for oofem::DynamicCommunicationBuffer:
+ Collaboration diagram for oofem::DynamicCommunicationBuffer:

Public Member Functions

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

Static Public Member Functions

static void printInfo ()
 

Protected Types

enum  DCB_Mode { DCB_null, DCB_send, DCB_receive }
 Receiver mode. More...
 

Protected Member Functions

CommunicationPacketallocateNewPacket (int)
 
void freePacket (CommunicationPacket *)
 
int receiveCompleted ()
 
int sendCompleted ()
 
void popNewRecvPacket ()
 
void pushNewRecvPacket (CommunicationPacket *)
 
void clear ()
 
int giveFitSize (MPI_Datatype type, int availableSpace, int arrySize)
 
template<class T >
int __write (T *src, int n, MPI_Datatype type)
 Templated low-level array packing method. More...
 
template<class T >
int __read (T *dest, int n, MPI_Datatype type)
 Templated low-level array unpacking method. More...
 

Protected Attributes

std::list< CommunicationPacket * > packet_list
 
std::list< CommunicationPacket * >::iterator recvIt
 Iterator to iterate over received packets. More...
 
CommunicationPacketactive_packet
 Active packet. More...
 
int active_tag
 Active rank and tag (send by initSend,initReceive, and initExchange). More...
 
int active_rank
 
int number_of_packets
 
enum oofem::DynamicCommunicationBuffer::DCB_Mode mode
 
bool completed
 Communication completion flag. More...
 
- Protected Attributes inherited from oofem::CommunicationBuffer
MPI_Comm communicator
 

Static Protected Attributes

static CommunicationPacketPool packetPool
 Static packet pool. More...
 

Detailed Description

Definition at line 158 of file dyncombuff.h.

Member Enumeration Documentation

Receiver mode.

Enumerator
DCB_null 
DCB_send 
DCB_receive 

Definition at line 171 of file dyncombuff.h.

Constructor & Destructor Documentation

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

Constructor. Creates buffer of given size, using given communicator for packing.

Definition at line 151 of file dyncombuff.C.

References completed, DCB_null, mode, and number_of_packets.

oofem::DynamicCommunicationBuffer::DynamicCommunicationBuffer ( MPI_Comm  comm,
bool  dynamic = 0 
)

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

Definition at line 165 of file dyncombuff.C.

References completed, DCB_null, mode, and number_of_packets.

oofem::DynamicCommunicationBuffer::~DynamicCommunicationBuffer ( )
virtual

Destructor.

Definition at line 179 of file dyncombuff.C.

References clear().

Member Function Documentation

template<class T >
int oofem::DynamicCommunicationBuffer::__read ( T *  dest,
int  n,
MPI_Datatype  type 
)
inlineprotected

Templated low-level array unpacking method.

Templated version used since implementation is similar for different types but type info is needed since implementation is relying on pointer arithmetic.

Definition at line 290 of file dyncombuff.h.

References oofem::MPIBuffer::giveAvailableSpace(), and oofem::MPIBuffer::unpackArray().

template<class T >
int oofem::DynamicCommunicationBuffer::__write ( T *  src,
int  n,
MPI_Datatype  type 
)
inlineprotected

Templated low-level array packing method.

Templated version used since implementation is similar for different types but type info is needed since implementation is relying on pointer arithmetic.

Definition at line 258 of file dyncombuff.h.

References oofem::MPIBuffer::giveAvailableSpace(), and oofem::MPIBuffer::packArray().

int oofem::DynamicCommunicationBuffer::bcast ( int  root)
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.

Implements oofem::CommunicationBuffer.

Definition at line 446 of file dyncombuff.C.

References OOFEM_ERROR.

void oofem::DynamicCommunicationBuffer::clear ( )
protected
void oofem::DynamicCommunicationBuffer::freePacket ( CommunicationPacket p)
protected

Definition at line 408 of file dyncombuff.C.

References packetPool, and oofem::CommunicationPacketPool::pushPacket().

Referenced by clear().

int oofem::DynamicCommunicationBuffer::giveFitSize ( MPI_Datatype  type,
int  availableSpace,
int  arrySize 
)
protected

Definition at line 381 of file dyncombuff.C.

References oofem::CommunicationBuffer::communicator.

void oofem::DynamicCommunicationBuffer::init ( )
virtual

Initializes buffer to empty state.

All packed data are lost.

Implements oofem::CommunicationBuffer.

Definition at line 185 of file dyncombuff.C.

References clear(), and completed.

Referenced by iRecv().

void oofem::DynamicCommunicationBuffer::initForPacking ( )
virtual

Initialize for packing.

Implements oofem::CommunicationBuffer.

Definition at line 192 of file dyncombuff.C.

References active_packet, allocateNewPacket(), clear(), number_of_packets, and packet_list.

void oofem::DynamicCommunicationBuffer::initForUnpacking ( )
virtual

Initialize for Unpacking (data already received).

Implements oofem::CommunicationBuffer.

Definition at line 203 of file dyncombuff.C.

References packet_list, popNewRecvPacket(), and recvIt.

Referenced by receiveCompleted().

int oofem::DynamicCommunicationBuffer::iRecv ( int  source,
int  tag,
int  count = 0 
)
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.

Implements oofem::CommunicationBuffer.

Definition at line 281 of file dyncombuff.C.

References active_packet, active_rank, active_tag, allocateNewPacket(), oofem::CommunicationBuffer::communicator, completed, DCB_receive, init(), oofem::CommunicationPacket::iRecv(), mode, and number_of_packets.

int oofem::DynamicCommunicationBuffer::iSend ( int  dest,
int  tag 
)
virtual

Starts standard mode, nonblocking send.

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

set last (active) send packet as eof

Implements oofem::CommunicationBuffer.

Definition at line 254 of file dyncombuff.C.

References active_packet, active_rank, active_tag, oofem::CommunicationBuffer::communicator, completed, DCB_send, mode, packet_list, and oofem::CommunicationPacket::setEOFFlag().

void oofem::DynamicCommunicationBuffer::popNewRecvPacket ( )
protected

Definition at line 427 of file dyncombuff.C.

References active_packet, OOFEM_ERROR, and recvIt.

Referenced by initForUnpacking().

static void oofem::DynamicCommunicationBuffer::printInfo ( )
inlinestatic

Definition at line 238 of file dyncombuff.h.

References oofem::CommunicationPacketPool::printInfo().

void oofem::DynamicCommunicationBuffer::pushNewRecvPacket ( CommunicationPacket p)
protected

Definition at line 439 of file dyncombuff.C.

References packet_list.

Referenced by receiveCompleted().

virtual int oofem::DynamicCommunicationBuffer::read ( int *  data,
int  count 
)
inlinevirtual

Reads count integer values into array pointed by data.

Implements oofem::DataStream.

Definition at line 203 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::read ( long *  data,
int  count 
)
inlinevirtual

Reads count long values into array pointed by data.

Implements oofem::DataStream.

Definition at line 205 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::read ( unsigned long *  data,
int  count 
)
inlinevirtual

Reads count unsigned long values into array pointed by data.

Implements oofem::DataStream.

Definition at line 207 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::read ( double *  data,
int  count 
)
inlinevirtual

Reads count double values into array pointed by data.

Implements oofem::DataStream.

Definition at line 209 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::read ( char *  data,
int  count 
)
inlinevirtual

Reads count char values into array pointed by data.

Implements oofem::DataStream.

Definition at line 211 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::resize ( int  newSize)
inlinevirtual

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.

Implements oofem::CommunicationBuffer.

Definition at line 184 of file dyncombuff.h.

int oofem::DynamicCommunicationBuffer::sendCompleted ( )
protected

Definition at line 333 of file dyncombuff.C.

References completed, and packet_list.

Referenced by testCompletion(), and waitCompletion().

int oofem::DynamicCommunicationBuffer::testCompletion ( )
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
True if operation complete, false otherwise.

Implements oofem::CommunicationBuffer.

Definition at line 350 of file dyncombuff.C.

References DCB_receive, DCB_send, mode, receiveCompleted(), and sendCompleted().

int oofem::DynamicCommunicationBuffer::waitCompletion ( )
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
True if request is successful.

Implements oofem::CommunicationBuffer.

Definition at line 362 of file dyncombuff.C.

References DCB_receive, DCB_send, mode, receiveCompleted(), and sendCompleted().

virtual int oofem::DynamicCommunicationBuffer::write ( const int *  data,
int  count 
)
inlinevirtual

Writes count integer values from array pointed by data.

Implements oofem::DataStream.

Definition at line 192 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::write ( const long *  data,
int  count 
)
inlinevirtual

Writes count long values from array pointed by data.

Implements oofem::DataStream.

Definition at line 194 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::write ( const unsigned long *  data,
int  count 
)
inlinevirtual

Writes count unsigned long values from array pointed by data.

Implements oofem::DataStream.

Definition at line 196 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::write ( const double *  data,
int  count 
)
inlinevirtual

Writes count double values from array pointed by data.

Implements oofem::DataStream.

Definition at line 198 of file dyncombuff.h.

virtual int oofem::DynamicCommunicationBuffer::write ( const char *  data,
int  count 
)
inlinevirtual

Writes count char values from array pointed by data.

Implements oofem::DataStream.

Definition at line 200 of file dyncombuff.h.

Member Data Documentation

CommunicationPacket* oofem::DynamicCommunicationBuffer::active_packet
protected

Active packet.

Definition at line 165 of file dyncombuff.h.

Referenced by clear(), initForPacking(), iRecv(), iSend(), popNewRecvPacket(), and receiveCompleted().

int oofem::DynamicCommunicationBuffer::active_rank
protected

Definition at line 167 of file dyncombuff.h.

Referenced by iRecv(), iSend(), and receiveCompleted().

int oofem::DynamicCommunicationBuffer::active_tag
protected

Active rank and tag (send by initSend,initReceive, and initExchange).

Definition at line 167 of file dyncombuff.h.

Referenced by iRecv(), iSend(), and receiveCompleted().

bool oofem::DynamicCommunicationBuffer::completed
protected

Communication completion flag.

Definition at line 175 of file dyncombuff.h.

Referenced by DynamicCommunicationBuffer(), init(), iRecv(), iSend(), receiveCompleted(), and sendCompleted().

enum oofem::DynamicCommunicationBuffer::DCB_Mode oofem::DynamicCommunicationBuffer::mode
protected
int oofem::DynamicCommunicationBuffer::number_of_packets
protected
std :: list< CommunicationPacket * > oofem::DynamicCommunicationBuffer::packet_list
protected
CommunicationPacketPool oofem::DynamicCommunicationBuffer::packetPool
staticprotected

Static packet pool.

Definition at line 173 of file dyncombuff.h.

Referenced by allocateNewPacket(), freePacket(), and oofem::CommunicationPacket::unpackHeader().

std :: list< CommunicationPacket * >:: iterator oofem::DynamicCommunicationBuffer::recvIt
protected

Iterator to iterate over received packets.

Definition at line 163 of file dyncombuff.h.

Referenced by initForUnpacking(), and popNewRecvPacket().


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