OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
#include <combuff.h>
Public Member Functions | |
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... | |
Methods for determining pack size of datatype to pack/unpack to/from buffer | |
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... | |
Protected Attributes | |
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... | |
Services for buffer sending/receiving | |
virtual int | iSend (MPI_Comm communicator, int dest, int tag) |
Starts standard mode, nonblocking send. More... | |
virtual int | iRecv (MPI_Comm communicator, int source, int tag, int count=0) |
Starts standard mode, nonblocking receive. 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... | |
virtual int | waitCompletion () |
Waits until a completion of a nonblocking communication. More... | |
int | bcast (MPI_Comm communicator, int root) |
Initializes broadcast over collaborating processes. More... | |
void | dump () |
int | givePosition () |
oofem::MPIBuffer::MPIBuffer | ( | int | size, |
bool | dynamic = 0 |
||
) |
oofem::MPIBuffer::MPIBuffer | ( | bool | dynamic = 0 | ) |
|
virtual |
int oofem::MPIBuffer::bcast | ( | MPI_Comm | communicator, |
int | root | ||
) |
Initializes broadcast over collaborating processes.
The whole buffer size is broadcasted. All buffers participating in broadcast should have the same size.
communicator | Communicator (handle). |
root | Rank of broadcast root. |
Definition at line 211 of file combuff.C.
Referenced by oofem::StaticCommunicationBuffer::bcast().
|
inline |
Definition at line 92 of file combuff.h.
Referenced by oofem::DynamicCommunicationBuffer::__read(), and oofem::DynamicCommunicationBuffer::__write().
int oofem::MPIBuffer::givePackSize | ( | MPI_Comm | communicator, |
MPI_Datatype | type, | ||
int | size | ||
) |
Returns pack size required to pack array of given type and size (c-style).
communicator | Communicator handle. |
type | Type id. |
size | Size of array to pack. |
Definition at line 218 of file combuff.C.
Referenced by oofem::CommunicationPacket::CommunicationPacket(), oofem::CommunicationPacket::init(), and packArray().
|
inlineprivate |
|
inline |
|
inline |
|
virtual |
Initializes buffer to empty state.
All packed data are lost.
Reimplemented in oofem::StaticCommunicationBuffer.
Definition at line 114 of file combuff.C.
References curr_pos, and request.
Referenced by oofem::CommunicationPacket::init(), and oofem::StaticCommunicationBuffer::init().
|
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 | Request communicator (handle). |
Reimplemented in oofem::CommunicationPacket.
Definition at line 162 of file combuff.C.
References buff, request, resize(), and size.
Referenced by oofem::StaticCommunicationBuffer::iRecv().
|
virtual |
Starts standard mode, nonblocking send.
communicator | Communicator handle. |
dest | Rank of destination. |
tag | Message tag. |
Reimplemented in oofem::CommunicationPacket.
Definition at line 154 of file combuff.C.
References buff, curr_pos, and request.
Referenced by oofem::StaticCommunicationBuffer::iSend().
int oofem::MPIBuffer::packArray | ( | MPI_Comm | communicator, |
const void * | src, | ||
int | n, | ||
MPI_Datatype | type | ||
) |
Packs array of a values of given type into buffer.
Buffer is enlarged if isDynamic flag is set, but it requires memory allocation and deallocation.
communicator | Communicator handle. |
src | Address of first value in memory. |
n | Number of packed integers. |
type | Determines type of array values. |
Definition at line 123 of file combuff.C.
References __CommunicationBuffer_ALLOC_CHUNK, buff, curr_pos, givePackSize(), isDynamic, OOFEM_WARNING, resize(), and size.
Referenced by oofem::DynamicCommunicationBuffer::__write(), and oofem::StaticCommunicationBuffer::write().
int oofem::MPIBuffer::resize | ( | int | newSize | ) |
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.
newSize | new buffer size in bytes. |
Definition at line 78 of file combuff.C.
References buff, curr_pos, OOFEM_ERROR, and size.
Referenced by oofem::CommunicationPacket::iRecv(), iRecv(), MPIBuffer(), packArray(), and oofem::StaticCommunicationBuffer::resize().
int oofem::MPIBuffer::testCompletion | ( | ) |
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 178 of file combuff.C.
References request.
Referenced by oofem::StaticCommunicationBuffer::testCompletion().
int oofem::MPIBuffer::testCompletion | ( | int & | source, |
int & | tag | ||
) |
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.
source | Source tag. |
tag | Tag of received message. |
Definition at line 188 of file combuff.C.
References request.
int oofem::MPIBuffer::unpackArray | ( | MPI_Comm | communicator, |
void * | dest, | ||
int | n, | ||
MPI_Datatype | type | ||
) |
Unpacks array of values of given type from buffer.
communicator | Communicator handle. |
dest | Address of first value in memory, where to store values |
n | Number of unpacked integers. |
type | Determines type of array values. |
Definition at line 147 of file combuff.C.
References buff, curr_pos, and size.
Referenced by oofem::DynamicCommunicationBuffer::__read(), and oofem::StaticCommunicationBuffer::read().
|
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 in oofem::StaticCommunicationBuffer, and oofem::CommunicationPacket.
Definition at line 202 of file combuff.C.
References request.
Referenced by oofem::StaticCommunicationBuffer::waitCompletion().
|
protected |
Buffer. Dynamically allocated.
Definition at line 59 of file combuff.h.
Referenced by bcast(), dump(), oofem::CommunicationPacket::iRecv(), iRecv(), oofem::CommunicationPacket::iSend(), iSend(), MPIBuffer(), packArray(), oofem::CommunicationPacket::packHeader(), resize(), unpackArray(), oofem::CommunicationPacket::unpackHeader(), and ~MPIBuffer().
|
protected |
Definition at line 55 of file combuff.h.
Referenced by oofem::CommunicationPacket::CommunicationPacket(), oofem::CommunicationPacket::init(), init(), oofem::CommunicationPacket::iSend(), iSend(), MPIBuffer(), packArray(), resize(), and unpackArray().
|
protected |
Dynamic flag (if true, buffer can grow, but reallocation is needed).
Definition at line 57 of file combuff.h.
Referenced by MPIBuffer(), and packArray().
|
protected |
MPI request handle.
This value is used by some message parsing functions. EngngCommunicator also assembles array of commbuff handles and wait for some completion (when receiving data for example).
Definition at line 65 of file combuff.h.
Referenced by init(), oofem::CommunicationPacket::iRecv(), iRecv(), oofem::CommunicationPacket::iSend(), iSend(), MPIBuffer(), oofem::CommunicationPacket::testCompletion(), testCompletion(), oofem::CommunicationPacket::waitCompletion(), and waitCompletion().
|
protected |
Size and current position in buffer in bytes (sizeof(char)).
Definition at line 55 of file combuff.h.
Referenced by bcast(), oofem::CommunicationPacket::iRecv(), iRecv(), MPIBuffer(), packArray(), oofem::CommunicationPacket::packHeader(), resize(), unpackArray(), and oofem::CommunicationPacket::unpackHeader().