OOFEM 3.0
Loading...
Searching...
No Matches
oofem::CommunicationPacket Class Reference

#include <dyncombuff.h>

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

Public Member Functions

 CommunicationPacket (MPI_Comm comm, std::size_t size, int num)
 Constructor. Creates buffer of given size, using given communicator for packing.
 CommunicationPacket (MPI_Comm comm, int num)
 Constructor. Creates empty buffer, using given communicator for packing.
virtual ~CommunicationPacket ()
 Destructor.
virtual void init (MPI_Comm comm)
Services for buffer sending/receiving
int iSend (MPI_Comm communicator, int dest, int tag) override
int iRecv (MPI_Comm communicator, int source, int tag, std::size_t count=0) override
virtual int testCompletion ()
int waitCompletion () override
void setNumber (int _num)
void setEOFFlag ()
int getNumber ()
bool hasEOFFlag ()
int packHeader (MPI_Comm)
 Packs packet header info at receiver beginning.
int unpackHeader (MPI_Comm)
Public Member Functions inherited from oofem::MPIBuffer
 MPIBuffer (std::size_t size, bool dynamic=0)
 Constructor. Creates buffer of given size, using given communicator for packing.
 MPIBuffer (bool dynamic=0)
 Constructor. Creates empty buffer, using given communicator for packing.
virtual ~MPIBuffer ()
 Destructor.
int resize (std::size_t newSize)
virtual void init ()
std::size_t giveSize ()
std::size_t giveAvailableSpace ()
MPI_Request giveRequest ()
int packArray (MPI_Comm communicator, const void *src, std::size_t n, MPI_Datatype type)
int unpackArray (MPI_Comm communicator, void *dest, std::size_t n, MPI_Datatype type)
int givePackSize (MPI_Comm communicator, MPI_Datatype type, std::size_t size)
int testCompletion ()
int testCompletion (int &source, int &tag)
int bcast (MPI_Comm communicator, int root)
void dump ()

Protected Attributes

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

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

◆ CommunicationPacket() [1/2]

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

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

Definition at line 43 of file dyncombuff.C.

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

◆ CommunicationPacket() [2/2]

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 __CommunicationPacket_DEFAULT_SIZE, oofem::MPIBuffer::curr_pos, EOF_Flag, oofem::MPIBuffer::givePackSize(), oofem::MPIBuffer::MPIBuffer(), and number.

◆ ~CommunicationPacket()

oofem::CommunicationPacket::~CommunicationPacket ( )
virtual

Destructor.

Definition at line 61 of file dyncombuff.C.

Member Function Documentation

◆ getNumber()

int oofem::CommunicationPacket::getNumber ( )
inline

Definition at line 125 of file dyncombuff.h.

References number.

◆ hasEOFFlag()

bool oofem::CommunicationPacket::hasEOFFlag ( )
inline

Definition at line 126 of file dyncombuff.h.

References EOF_Flag.

◆ init()

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, and oofem::MPIBuffer::givePackSize().

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

◆ iRecv()

int oofem::CommunicationPacket::iRecv ( MPI_Comm communicator,
int source,
int tag,
std::size_t count = 0 )
overridevirtual

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.

◆ iSend()

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

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.

◆ packHeader()

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().

◆ setEOFFlag()

void oofem::CommunicationPacket::setEOFFlag ( )
inline

Definition at line 124 of file dyncombuff.h.

◆ setNumber()

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

Definition at line 123 of file dyncombuff.h.

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

◆ testCompletion()

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.

◆ unpackHeader()

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

Definition at line 133 of file dyncombuff.C.

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

◆ waitCompletion()

int oofem::CommunicationPacket::waitCompletion ( )
overridevirtual

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

◆ EOF_Flag

bool oofem::CommunicationPacket::EOF_Flag
protected

◆ number

int oofem::CommunicationPacket::number
protected

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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011