78 return ( MPI_Isend(this->
buff, this->
curr_pos, MPI_PACKED, dest, tag,
79 communicator, & this->
request) == MPI_SUCCESS );
87 if ( count >= this->
size ) {
89 if ( this->
resize(count) == 0 ) {
95 return ( MPI_Irecv(this->
buff, this->
size, MPI_PACKED, source, tag,
96 communicator, & this->
request) == MPI_SUCCESS );
105 MPI_Test(& this->
request, & flag, & status);
114 return ( MPI_Wait(& this->
request, & status) == MPI_SUCCESS );
124 _arry [ 0 ] = this->
number;
127 _res = MPI_Pack(_arry, 2, MPI_INT, this->
buff,
size, & _pos, comm);
129 return ( _res == MPI_SUCCESS );
138 _res = MPI_Unpack(this->
buff, this->
size, & _pos, _arry, 2, MPI_INT, comm);
139 this->
number = _arry [ 0 ];
142 return ( _res == MPI_SUCCESS );
342 result &= packet->testCompletion();
383 int arrySpace, guessSize;
384 MPI_Pack_size(arrySize, type,
communicator, & arrySpace);
385 if ( availableSpace >= arrySpace ) {
389 guessSize = ( int ) floor( ( (
double ) arrySize / (
double ) arrySpace ) * availableSpace ) + 1;
392 MPI_Pack_size(guessSize, type,
communicator, & arrySpace);
393 }
while ( ( availableSpace < arrySpace ) && ( guessSize > 0 ) );
459 if ( available_packets.empty() ) {
467 result = available_packets.front();
468 available_packets.pop_front();
474 leased_packets.push_back(result);
485 std :: list< CommunicationPacket * > :: iterator it = std :: find(leased_packets.begin(), leased_packets.end(), p);
486 if ( it != leased_packets.end() ) {
488 leased_packets.erase(it);
489 available_packets.push_back(p);
491 OOFEM_ERROR(
"request to push strange packet (not allocated by pool)");
495 available_packets.push_back(p);
505 if ( !leased_packets.empty() ) {
509 for (
auto &packet: available_packets ) {
515 available_packets.clear();
516 allocatedPackets = leasedPackets = freePackets = 0;
523 OOFEM_LOG_INFO(
"CommunicationPacketPool: allocated %d packets\n(packet size: %d, %d leased, %d free)\n",
int testCompletion()
Tests if the operation identified by this->request is complete.
int packHeader(MPI_Comm)
Packs packet header info at receiver beginning.
virtual int iRecv(int source, int tag, int count=0)
Starts standard mode, nonblocking receive.
virtual void init()
Initializes buffer to empty state.
CommunicationPacket * active_packet
Active packet.
CommunicationPacket * allocateNewPacket(int)
virtual ~CommunicationPacket()
Destructor.
int max(int i, int j)
Returns bigger value form two given decimals.
static CommunicationPacketPool packetPool
Static packet pool.
virtual ~DynamicCommunicationBuffer()
Destructor.
int givePackSize(MPI_Comm communicator, MPI_Datatype type, int size)
Returns pack size required to pack array of given type and size (c-style).
ComBuff_BYTE_TYPE * buff
Buffer. Dynamically allocated.
int iRecv(MPI_Comm communicator, int source, int tag, int count=0)
Starts standard mode, nonblocking receive.
virtual int testCompletion()
Tests if the operation identified by this->request is complete.
virtual void initForPacking()
Initialize for packing.
virtual int iSend(int dest, int tag)
Starts standard mode, nonblocking send.
virtual int waitCompletion()
Waits until a completion of a nonblocking communication.
enum oofem::DynamicCommunicationBuffer::DCB_Mode mode
DynamicCommunicationBuffer(MPI_Comm comm, int size, bool dynamic=0)
Constructor. Creates buffer of given size, using given communicator for packing.
MPI_Request request
MPI request handle.
void pushNewRecvPacket(CommunicationPacket *)
int active_tag
Active rank and tag (send by initSend,initReceive, and initExchange).
std::list< CommunicationPacket * >::iterator recvIt
Iterator to iterate over received packets.
int resize(int newSize)
Resizes buffer to given size.
bool completed
Communication completion flag.
std::list< CommunicationPacket * > packet_list
virtual int bcast(int root)
Initializes broadcast over collaborating processes.
Class CommunicationPacket represent a data-packet, that is used to implement dynamic communicator...
#define OOFEM_LOG_INFO(...)
Class CommunicationBuffer provides abstraction for communication buffer.
int size
Size and current position in buffer in bytes (sizeof(char)).
int unpackHeader(MPI_Comm)
#define __CommunicationPacket_DEFAULT_SIZE
void pushPacket(CommunicationPacket *)
void freePacket(CommunicationPacket *)
virtual int waitCompletion()
Waits until a completion of a nonblocking communication.
int giveFitSize(MPI_Datatype type, int availableSpace, int arrySize)
int iSend(MPI_Comm communicator, int dest, int tag)
Starts standard mode, nonblocking send.
CommunicationPacket(MPI_Comm comm, int size, int num)
Constructor. Creates buffer of given size, using given communicator for packing.
the oofem namespace is to define a context or scope in which all oofem names are defined.
CommunicationPacket * popPacket(MPI_Comm)
virtual void init(MPI_Comm comm)
Initializes buffer to empty state.
#define OOFEM_WARNING(...)
virtual void initForUnpacking()
Initialize for Unpacking (data already received).
virtual void init()
Initializes buffer to empty state.