OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
Class CommunicationPacket represent a data-packet, that is used to implement dynamic communicator. More...
#include <dyncombuff.h>
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_TYPE * | buff |
Buffer. Dynamically allocated. More... | |
MPI_Request | request |
MPI request handle. More... | |
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.
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.
|
virtual |
Destructor.
Definition at line 61 of file dyncombuff.C.
|
inline |
Definition at line 125 of file dyncombuff.h.
|
inline |
Definition at line 126 of file dyncombuff.h.
Referenced by oofem::DynamicCommunicationBuffer::receiveCompleted().
|
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().
|
virtual |
Starts standard mode, nonblocking receive.
The buffer must be large enough to receive all data.
source | Rank of source. |
tag | Message tag. |
count | Number of elements to receive (bytes). Causes receive buffer to resize to count elements. If zero (default value) buffer is not resized. |
communicator | Communicator request handle. |
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().
|
virtual |
Starts standard mode, nonblocking send.
dest | Rank of destination. |
tag | Message tag. |
communicator | Communicator request handle. |
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().
|
inline |
Definition at line 124 of file dyncombuff.h.
Referenced by oofem::DynamicCommunicationBuffer::iSend().
|
inline |
Definition at line 123 of file dyncombuff.h.
Referenced by oofem::DynamicCommunicationBuffer::allocateNewPacket().
|
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.
Definition at line 101 of file dyncombuff.C.
References oofem::MPIBuffer::request.
Referenced by oofem::DynamicCommunicationBuffer::receiveCompleted().
int oofem::CommunicationPacket::unpackHeader | ( | MPI_Comm | comm | ) |
Definition at line 133 of file dyncombuff.C.
References oofem::MPIBuffer::buff, EOF_Flag, number, oofem::DynamicCommunicationBuffer::packetPool, and oofem::MPIBuffer::size.
Referenced by oofem::DynamicCommunicationBuffer::receiveCompleted().
|
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.
Reimplemented from oofem::MPIBuffer.
Definition at line 110 of file dyncombuff.C.
References oofem::MPIBuffer::request.
|
protected |
Definition at line 64 of file dyncombuff.h.
Referenced by CommunicationPacket(), init(), packHeader(), and unpackHeader().
|
protected |
Definition at line 63 of file dyncombuff.h.
Referenced by CommunicationPacket(), packHeader(), and unpackHeader().