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

Class CommunicationPacket represent a data-packet, that is used to implement dynamic communicator. More...

#include <dyncombuff.h>

+ Inheritance diagram for oofem::CommunicationPacket:
+ Collaboration diagram for oofem::CommunicationPacket:

Public Member Functions

 CommunicationPacket (MPI_Comm comm, int size, int num)
 Constructor. Creates buffer of given size, using given communicator for packing. More...
 
 CommunicationPacket (MPI_Comm comm, int num)
 Constructor. Creates empty buffer, using given communicator for packing. More...
 
virtual ~CommunicationPacket ()
 Destructor. More...
 
virtual void init (MPI_Comm comm)
 Initializes buffer to empty state. More...
 
void setNumber (int _num)
 
void setEOFFlag ()
 
int getNumber ()
 
bool hasEOFFlag ()
 
int packHeader (MPI_Comm)
 Packs packet header info at receiver beginning. More...
 
int unpackHeader (MPI_Comm)
 
Services for buffer sending/receiving
int iSend (MPI_Comm communicator, int dest, int tag)
 Starts standard mode, nonblocking send. More...
 
int iRecv (MPI_Comm communicator, int source, int tag, int count=0)
 Starts standard mode, nonblocking receive. More...
 
virtual 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::MPIBuffer
 MPIBuffer (int size, bool dynamic=0)
 Constructor. Creates buffer of given size, using given communicator for packing. More...
 
 MPIBuffer (bool dynamic=0)
 Constructor. Creates empty buffer, using given communicator for packing. More...
 
virtual ~MPIBuffer ()
 Destructor. More...
 
int resize (int newSize)
 Resizes buffer to given size. More...
 
virtual void init ()
 Initializes buffer to empty state. More...
 
int giveSize ()
 
int giveAvailableSpace ()
 
MPI_Request giveRequest ()
 Returns associated MPI request handle. More...
 
int packArray (MPI_Comm communicator, const void *src, int n, MPI_Datatype type)
 Packs array of a values of given type into buffer. More...
 
int unpackArray (MPI_Comm communicator, void *dest, int n, MPI_Datatype type)
 Unpacks array of values of given type from buffer. More...
 
int givePackSize (MPI_Comm communicator, MPI_Datatype type, int size)
 Returns pack size required to pack array of given type and size (c-style). More...
 
int testCompletion ()
 Tests if the operation identified by this->request is complete. More...
 
int testCompletion (int &source, int &tag)
 Tests if the operation identified by this->request is complete. More...
 
int bcast (MPI_Comm communicator, int root)
 Initializes broadcast over collaborating processes. More...
 
void dump ()
 

Protected Attributes

int number
 
bool EOF_Flag
 
- Protected Attributes inherited from oofem::MPIBuffer
int size
 Size and current position in buffer in bytes (sizeof(char)). More...
 
int curr_pos
 
bool isDynamic
 Dynamic flag (if true, buffer can grow, but reallocation is needed). More...
 
ComBuff_BYTE_TYPEbuff
 Buffer. Dynamically allocated. More...
 
MPI_Request request
 MPI request handle. More...
 

Detailed Description

Class CommunicationPacket represent a data-packet, that is used to implement dynamic communicator.

Dynamic Communicator can pack messages into a dynamic message. This dynamic message is split into a series of data packets of fixed size (this is not necessary) that are send over network.

A special header is put at the beginning of each packet buffer. This header keeps the message number as well as the EOF flag indicating the last packet in message. This header is packed at the beginning of each packet.

Definition at line 60 of file dyncombuff.h.

Constructor & Destructor Documentation

oofem::CommunicationPacket::CommunicationPacket ( MPI_Comm  comm,
int  size,
int  num 
)

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

Definition at line 43 of file dyncombuff.C.

References oofem::MPIBuffer::curr_pos, EOF_Flag, oofem::MPIBuffer::givePackSize(), and number.

oofem::CommunicationPacket::CommunicationPacket ( MPI_Comm  comm,
int  num 
)

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

Definition at line 52 of file dyncombuff.C.

References oofem::MPIBuffer::curr_pos, EOF_Flag, oofem::MPIBuffer::givePackSize(), and number.

oofem::CommunicationPacket::~CommunicationPacket ( )
virtual

Destructor.

Definition at line 61 of file dyncombuff.C.

Member Function Documentation

int oofem::CommunicationPacket::getNumber ( )
inline

Definition at line 125 of file dyncombuff.h.

bool oofem::CommunicationPacket::hasEOFFlag ( )
inline

Definition at line 126 of file dyncombuff.h.

Referenced by oofem::DynamicCommunicationBuffer::receiveCompleted().

void oofem::CommunicationPacket::init ( MPI_Comm  comm)
virtual

Initializes buffer to empty state.

All packed data are lost.

Definition at line 66 of file dyncombuff.C.

References oofem::MPIBuffer::curr_pos, EOF_Flag, oofem::MPIBuffer::givePackSize(), and oofem::MPIBuffer::init().

Referenced by oofem::DynamicCommunicationBuffer::allocateNewPacket().

int oofem::CommunicationPacket::iRecv ( MPI_Comm  communicator,
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.
communicatorCommunicator request handle.
Returns
MIP_Succes if ok.

Reimplemented from oofem::MPIBuffer.

Definition at line 84 of file dyncombuff.C.

References oofem::MPIBuffer::buff, oofem::MPIBuffer::request, oofem::MPIBuffer::resize(), and oofem::MPIBuffer::size.

Referenced by oofem::DynamicCommunicationBuffer::iRecv(), and oofem::DynamicCommunicationBuffer::receiveCompleted().

int oofem::CommunicationPacket::iSend ( MPI_Comm  communicator,
int  dest,
int  tag 
)
virtual

Starts standard mode, nonblocking send.

Parameters
destRank of destination.
tagMessage tag.
communicatorCommunicator request handle.
Returns
Sends MIP_Succes if ok.

Reimplemented from oofem::MPIBuffer.

Definition at line 75 of file dyncombuff.C.

References oofem::MPIBuffer::buff, oofem::MPIBuffer::curr_pos, packHeader(), and oofem::MPIBuffer::request.

int oofem::CommunicationPacket::packHeader ( MPI_Comm  comm)

Packs packet header info at receiver beginning.

Definition at line 119 of file dyncombuff.C.

References oofem::MPIBuffer::buff, EOF_Flag, number, and oofem::MPIBuffer::size.

Referenced by iSend().

void oofem::CommunicationPacket::setEOFFlag ( )
inline

Definition at line 124 of file dyncombuff.h.

Referenced by oofem::DynamicCommunicationBuffer::iSend().

void oofem::CommunicationPacket::setNumber ( int  _num)
inline

Definition at line 123 of file dyncombuff.h.

Referenced by oofem::DynamicCommunicationBuffer::allocateNewPacket().

int oofem::CommunicationPacket::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.

Definition at line 101 of file dyncombuff.C.

References oofem::MPIBuffer::request.

Referenced by oofem::DynamicCommunicationBuffer::receiveCompleted().

int oofem::CommunicationPacket::unpackHeader ( MPI_Comm  comm)
int oofem::CommunicationPacket::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.

Reimplemented from oofem::MPIBuffer.

Definition at line 110 of file dyncombuff.C.

References oofem::MPIBuffer::request.

Member Data Documentation

bool oofem::CommunicationPacket::EOF_Flag
protected

Definition at line 64 of file dyncombuff.h.

Referenced by CommunicationPacket(), init(), packHeader(), and unpackHeader().

int oofem::CommunicationPacket::number
protected

Definition at line 63 of file dyncombuff.h.

Referenced by CommunicationPacket(), packHeader(), and unpackHeader().


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