|
OOFEM 3.0
|
#include <combuff.h>
Public Member Functions | |
| 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) |
Methods for determining pack size of datatype to pack/unpack to/from buffer | |
| int | givePackSize (MPI_Comm communicator, MPI_Datatype type, std::size_t size) |
Protected Attributes | |
| 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_TYPE * | buff |
| Buffer. Dynamically allocated. | |
| MPI_Request | request |
Services for buffer sending/receiving | |
| virtual int | iSend (MPI_Comm communicator, int dest, int tag) |
| virtual int | iRecv (MPI_Comm communicator, int source, int tag, std::size_t count=0) |
| int | testCompletion () |
| int | testCompletion (int &source, int &tag) |
| virtual int | waitCompletion () |
| int | bcast (MPI_Comm communicator, int root) |
| void | dump () |
| std::size_t | givePosition () |
| oofem::MPIBuffer::MPIBuffer | ( | std::size_t | size, |
| bool | dynamic = 0 ) |
Constructor. Creates buffer of given size, using given communicator for packing.
Definition at line 46 of file combuff.C.
References buff, curr_pos, isDynamic, request, resize(), and size.
Referenced by oofem::CommunicationPacket::CommunicationPacket(), oofem::CommunicationPacket::CommunicationPacket(), oofem::StaticCommunicationBuffer::StaticCommunicationBuffer(), and oofem::StaticCommunicationBuffer::StaticCommunicationBuffer().
| 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. |
|
inline |
| int oofem::MPIBuffer::givePackSize | ( | MPI_Comm | communicator, |
| MPI_Datatype | type, | ||
| std::size_t | 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 226 of file combuff.C.
References size.
Referenced by oofem::CommunicationPacket::CommunicationPacket(), 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.
|
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.
|
virtual |
Starts standard mode, nonblocking send.
| communicator | Communicator handle. |
| dest | Rank of destination. |
| tag | Message tag. |
Reimplemented in oofem::CommunicationPacket.
| int oofem::MPIBuffer::packArray | ( | MPI_Comm | communicator, |
| const void * | src, | ||
| std::size_t | 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.
| int oofem::MPIBuffer::resize | ( | std::size_t | 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(), and packArray().
| 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 186 of file combuff.C.
References request.
| 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 196 of file combuff.C.
References request.
| int oofem::MPIBuffer::unpackArray | ( | MPI_Comm | communicator, |
| void * | dest, | ||
| std::size_t | 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. |
|
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::CommunicationPacket, and oofem::StaticCommunicationBuffer.
Definition at line 210 of file combuff.C.
References request.
|
protected |
Buffer. Dynamically allocated.
Definition at line 78 of file combuff.h.
Referenced by bcast(), dump(), oofem::CommunicationPacket::iRecv(), iRecv(), oofem::CommunicationPacket::iSend(), iSend(), MPIBuffer(), MPIBuffer(), packArray(), oofem::CommunicationPacket::packHeader(), resize(), unpackArray(), oofem::CommunicationPacket::unpackHeader(), and ~MPIBuffer().
|
protected |
Definition at line 74 of file combuff.h.
Referenced by oofem::CommunicationPacket::CommunicationPacket(), oofem::CommunicationPacket::CommunicationPacket(), giveAvailableSpace(), givePosition(), oofem::CommunicationPacket::init(), init(), oofem::CommunicationPacket::iSend(), iSend(), MPIBuffer(), MPIBuffer(), packArray(), resize(), and unpackArray().
|
protected |
Dynamic flag (if true, buffer can grow, but reallocation is needed).
Definition at line 76 of file combuff.h.
Referenced by MPIBuffer(), 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 84 of file combuff.h.
Referenced by init(), oofem::CommunicationPacket::iRecv(), iRecv(), oofem::CommunicationPacket::iSend(), iSend(), MPIBuffer(), MPIBuffer(), oofem::CommunicationPacket::testCompletion(), testCompletion(), testCompletion(), oofem::CommunicationPacket::waitCompletion(), and waitCompletion().
|
protected |
Size and current position in buffer in bytes (sizeof(char)).
Definition at line 74 of file combuff.h.
Referenced by bcast(), oofem::CommunicationPacket::CommunicationPacket(), giveAvailableSpace(), givePackSize(), giveSize(), oofem::CommunicationPacket::iRecv(), iRecv(), MPIBuffer(), MPIBuffer(), packArray(), oofem::CommunicationPacket::packHeader(), resize(), oofem::StaticCommunicationBuffer::StaticCommunicationBuffer(), unpackArray(), and oofem::CommunicationPacket::unpackHeader().