OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
#include <dyncombuff.h>
Public Member Functions | |
DynamicCommunicationBuffer (MPI_Comm comm, int size, bool dynamic=0) | |
Constructor. Creates buffer of given size, using given communicator for packing. More... | |
DynamicCommunicationBuffer (MPI_Comm comm, bool dynamic=0) | |
Constructor. Creates empty buffer, using given communicator for packing. More... | |
virtual | ~DynamicCommunicationBuffer () |
Destructor. More... | |
virtual int | resize (int newSize) |
Resizes buffer to given size. More... | |
virtual void | init () |
Initializes buffer to empty state. More... | |
virtual void | initForPacking () |
Initialize for packing. More... | |
virtual void | initForUnpacking () |
Initialize for Unpacking (data already received). More... | |
virtual int | write (const int *src, int n) |
Writes count integer values from array pointed by data. More... | |
virtual int | write (const long *src, int n) |
Writes count long values from array pointed by data. More... | |
virtual int | write (const unsigned long *src, int n) |
Writes count unsigned long values from array pointed by data. More... | |
virtual int | write (const double *src, int n) |
Writes count double values from array pointed by data. More... | |
virtual int | write (const char *src, int n) |
Writes count char values from array pointed by data. More... | |
virtual int | read (int *dest, int n) |
Reads count integer values into array pointed by data. More... | |
virtual int | read (long *dest, int n) |
Reads count long values into array pointed by data. More... | |
virtual int | read (unsigned long *dest, int n) |
Reads count unsigned long values into array pointed by data. More... | |
virtual int | read (double *dest, int n) |
Reads count double values into array pointed by data. More... | |
virtual int | read (char *dest, int n) |
Reads count char values into array pointed by data. More... | |
virtual int | iSend (int dest, int tag) |
Starts standard mode, nonblocking send. More... | |
virtual int | iRecv (int source, int tag, int count=0) |
Starts standard mode, nonblocking receive. More... | |
virtual int | bcast (int root) |
Initializes broadcast over collaborating processes. More... | |
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::CommunicationBuffer | |
CommunicationBuffer (MPI_Comm comm, int size, bool dynamic=0) | |
CommunicationBuffer (MPI_Comm comm, bool dynamic=0) | |
Constructor. Creates empty buffer, using given communicator for packing. More... | |
virtual | ~CommunicationBuffer () |
Destructor. More... | |
virtual int | read (bool &data) |
Reads a bool value from data. More... | |
virtual int | write (bool data) |
Writes a bool value. More... | |
virtual int | givePackSizeOfInt (int count) |
virtual int | givePackSizeOfDouble (int count) |
virtual int | givePackSizeOfChar (int count) |
virtual int | givePackSizeOfBool (int count) |
virtual int | givePackSizeOfLong (int count) |
Public Member Functions inherited from oofem::DataStream | |
virtual | ~DataStream () |
Destructor. More... | |
int | read (int &data) |
int | read (unsigned long &data) |
int | read (long &data) |
int | read (double &data) |
int | read (char &data) |
int | read (std::string &data) |
Reads a string (stored as an int for the length followed by char*). More... | |
int | write (int data) |
int | write (unsigned long data) |
int | write (long data) |
int | write (double data) |
int | write (char data) |
int | write (const std::string &data) |
Reads a string (stored as an int for the length followed by char*). More... | |
int | write (const char *data) |
Writes a string (wrapper needed, otherwise write(bool) is called ) More... | |
Static Public Member Functions | |
static void | printInfo () |
Protected Types | |
enum | DCB_Mode { DCB_null, DCB_send, DCB_receive } |
Receiver mode. More... | |
Protected Member Functions | |
CommunicationPacket * | allocateNewPacket (int) |
void | freePacket (CommunicationPacket *) |
int | receiveCompleted () |
int | sendCompleted () |
void | popNewRecvPacket () |
void | pushNewRecvPacket (CommunicationPacket *) |
void | clear () |
int | giveFitSize (MPI_Datatype type, int availableSpace, int arrySize) |
template<class T > | |
int | __write (T *src, int n, MPI_Datatype type) |
Templated low-level array packing method. More... | |
template<class T > | |
int | __read (T *dest, int n, MPI_Datatype type) |
Templated low-level array unpacking method. More... | |
Protected Attributes | |
std::list< CommunicationPacket * > | packet_list |
std::list< CommunicationPacket * >::iterator | recvIt |
Iterator to iterate over received packets. More... | |
CommunicationPacket * | active_packet |
Active packet. More... | |
int | active_tag |
Active rank and tag (send by initSend,initReceive, and initExchange). More... | |
int | active_rank |
int | number_of_packets |
enum oofem::DynamicCommunicationBuffer::DCB_Mode | mode |
bool | completed |
Communication completion flag. More... | |
Protected Attributes inherited from oofem::CommunicationBuffer | |
MPI_Comm | communicator |
Static Protected Attributes | |
static CommunicationPacketPool | packetPool |
Static packet pool. More... | |
Definition at line 158 of file dyncombuff.h.
|
protected |
oofem::DynamicCommunicationBuffer::DynamicCommunicationBuffer | ( | MPI_Comm | comm, |
int | size, | ||
bool | dynamic = 0 |
||
) |
Constructor. Creates buffer of given size, using given communicator for packing.
Definition at line 151 of file dyncombuff.C.
References completed, DCB_null, mode, and number_of_packets.
oofem::DynamicCommunicationBuffer::DynamicCommunicationBuffer | ( | MPI_Comm | comm, |
bool | dynamic = 0 |
||
) |
Constructor. Creates empty buffer, using given communicator for packing.
Definition at line 165 of file dyncombuff.C.
References completed, DCB_null, mode, and number_of_packets.
|
virtual |
|
inlineprotected |
Templated low-level array unpacking method.
Templated version used since implementation is similar for different types but type info is needed since implementation is relying on pointer arithmetic.
Definition at line 290 of file dyncombuff.h.
References oofem::MPIBuffer::giveAvailableSpace(), and oofem::MPIBuffer::unpackArray().
|
inlineprotected |
Templated low-level array packing method.
Templated version used since implementation is similar for different types but type info is needed since implementation is relying on pointer arithmetic.
Definition at line 258 of file dyncombuff.h.
References oofem::MPIBuffer::giveAvailableSpace(), and oofem::MPIBuffer::packArray().
|
protected |
Definition at line 399 of file dyncombuff.C.
References oofem::CommunicationBuffer::communicator, oofem::CommunicationPacket::init(), packetPool, oofem::CommunicationPacketPool::popPacket(), and oofem::CommunicationPacket::setNumber().
Referenced by initForPacking(), iRecv(), and receiveCompleted().
|
virtual |
Initializes broadcast over collaborating processes.
The whole buffer size is broadcasted. All buffers participating in broadcast should have the same size.
root | Rank of broadcast root. |
Implements oofem::CommunicationBuffer.
Definition at line 446 of file dyncombuff.C.
References OOFEM_ERROR.
|
protected |
Definition at line 414 of file dyncombuff.C.
References active_packet, freePacket(), number_of_packets, and packet_list.
Referenced by init(), initForPacking(), and ~DynamicCommunicationBuffer().
|
protected |
Definition at line 408 of file dyncombuff.C.
References packetPool, and oofem::CommunicationPacketPool::pushPacket().
Referenced by clear().
|
protected |
Definition at line 381 of file dyncombuff.C.
References oofem::CommunicationBuffer::communicator.
|
virtual |
Initializes buffer to empty state.
All packed data are lost.
Implements oofem::CommunicationBuffer.
Definition at line 185 of file dyncombuff.C.
References clear(), and completed.
Referenced by iRecv().
|
virtual |
Initialize for packing.
Implements oofem::CommunicationBuffer.
Definition at line 192 of file dyncombuff.C.
References active_packet, allocateNewPacket(), clear(), number_of_packets, and packet_list.
|
virtual |
Initialize for Unpacking (data already received).
Implements oofem::CommunicationBuffer.
Definition at line 203 of file dyncombuff.C.
References packet_list, popNewRecvPacket(), and recvIt.
Referenced by receiveCompleted().
|
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. |
Implements oofem::CommunicationBuffer.
Definition at line 281 of file dyncombuff.C.
References active_packet, active_rank, active_tag, allocateNewPacket(), oofem::CommunicationBuffer::communicator, completed, DCB_receive, init(), oofem::CommunicationPacket::iRecv(), mode, and number_of_packets.
|
virtual |
Starts standard mode, nonblocking send.
dest | Rank of destination. |
tag | Message tag. |
set last (active) send packet as eof
Implements oofem::CommunicationBuffer.
Definition at line 254 of file dyncombuff.C.
References active_packet, active_rank, active_tag, oofem::CommunicationBuffer::communicator, completed, DCB_send, mode, packet_list, and oofem::CommunicationPacket::setEOFFlag().
|
protected |
Definition at line 427 of file dyncombuff.C.
References active_packet, OOFEM_ERROR, and recvIt.
Referenced by initForUnpacking().
|
inlinestatic |
Definition at line 238 of file dyncombuff.h.
References oofem::CommunicationPacketPool::printInfo().
|
protected |
Definition at line 439 of file dyncombuff.C.
References packet_list.
Referenced by receiveCompleted().
|
inlinevirtual |
Reads count integer values into array pointed by data.
Implements oofem::DataStream.
Definition at line 203 of file dyncombuff.h.
|
inlinevirtual |
Reads count long values into array pointed by data.
Implements oofem::DataStream.
Definition at line 205 of file dyncombuff.h.
|
inlinevirtual |
Reads count unsigned long values into array pointed by data.
Implements oofem::DataStream.
Definition at line 207 of file dyncombuff.h.
|
inlinevirtual |
Reads count double values into array pointed by data.
Implements oofem::DataStream.
Definition at line 209 of file dyncombuff.h.
|
inlinevirtual |
Reads count char values into array pointed by data.
Implements oofem::DataStream.
Definition at line 211 of file dyncombuff.h.
|
protected |
Definition at line 295 of file dyncombuff.C.
References active_packet, active_rank, active_tag, allocateNewPacket(), oofem::CommunicationBuffer::communicator, completed, oofem::CommunicationPacket::hasEOFFlag(), initForUnpacking(), oofem::CommunicationPacket::iRecv(), number_of_packets, pushNewRecvPacket(), oofem::CommunicationPacket::testCompletion(), and oofem::CommunicationPacket::unpackHeader().
Referenced by testCompletion(), and waitCompletion().
|
inlinevirtual |
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. |
Implements oofem::CommunicationBuffer.
Definition at line 184 of file dyncombuff.h.
|
protected |
Definition at line 333 of file dyncombuff.C.
References completed, and packet_list.
Referenced by testCompletion(), and waitCompletion().
|
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.
Implements oofem::CommunicationBuffer.
Definition at line 350 of file dyncombuff.C.
References DCB_receive, DCB_send, mode, receiveCompleted(), and sendCompleted().
|
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.
Implements oofem::CommunicationBuffer.
Definition at line 362 of file dyncombuff.C.
References DCB_receive, DCB_send, mode, receiveCompleted(), and sendCompleted().
|
inlinevirtual |
Writes count integer values from array pointed by data.
Implements oofem::DataStream.
Definition at line 192 of file dyncombuff.h.
|
inlinevirtual |
Writes count long values from array pointed by data.
Implements oofem::DataStream.
Definition at line 194 of file dyncombuff.h.
|
inlinevirtual |
Writes count unsigned long values from array pointed by data.
Implements oofem::DataStream.
Definition at line 196 of file dyncombuff.h.
|
inlinevirtual |
Writes count double values from array pointed by data.
Implements oofem::DataStream.
Definition at line 198 of file dyncombuff.h.
|
inlinevirtual |
Writes count char values from array pointed by data.
Implements oofem::DataStream.
Definition at line 200 of file dyncombuff.h.
|
protected |
Active packet.
Definition at line 165 of file dyncombuff.h.
Referenced by clear(), initForPacking(), iRecv(), iSend(), popNewRecvPacket(), and receiveCompleted().
|
protected |
Definition at line 167 of file dyncombuff.h.
Referenced by iRecv(), iSend(), and receiveCompleted().
|
protected |
Active rank and tag (send by initSend,initReceive, and initExchange).
Definition at line 167 of file dyncombuff.h.
Referenced by iRecv(), iSend(), and receiveCompleted().
|
protected |
Communication completion flag.
Definition at line 175 of file dyncombuff.h.
Referenced by DynamicCommunicationBuffer(), init(), iRecv(), iSend(), receiveCompleted(), and sendCompleted().
|
protected |
Referenced by DynamicCommunicationBuffer(), iRecv(), iSend(), testCompletion(), and waitCompletion().
|
protected |
Definition at line 168 of file dyncombuff.h.
Referenced by clear(), DynamicCommunicationBuffer(), initForPacking(), iRecv(), and receiveCompleted().
|
protected |
Definition at line 161 of file dyncombuff.h.
Referenced by clear(), initForPacking(), initForUnpacking(), iSend(), pushNewRecvPacket(), and sendCompleted().
|
staticprotected |
Static packet pool.
Definition at line 173 of file dyncombuff.h.
Referenced by allocateNewPacket(), freePacket(), and oofem::CommunicationPacket::unpackHeader().
|
protected |
Iterator to iterate over received packets.
Definition at line 163 of file dyncombuff.h.
Referenced by initForUnpacking(), and popNewRecvPacket().