61CommunicationPacket :: ~CommunicationPacket()
66CommunicationPacket :: init(MPI_Comm comm)
75CommunicationPacket :: iSend(MPI_Comm communicator,
int dest,
int tag)
78 return ( MPI_Isend(this->
buff, this->
curr_pos, MPI_PACKED, dest, tag,
79 communicator, & this->
request) == MPI_SUCCESS );
84CommunicationPacket :: iRecv(MPI_Comm communicator,
int source,
int tag, std::size_t count)
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 );
101CommunicationPacket :: testCompletion() {
105 MPI_Test(& this->
request, & flag, & status);
110CommunicationPacket :: waitCompletion()
114 return ( MPI_Wait(& this->
request, & status) == MPI_SUCCESS );
119CommunicationPacket :: packHeader(MPI_Comm comm)
124 _arry [ 0 ] = this->
number;
127 _res = MPI_Pack(_arry, 2, MPI_INT, this->
buff,
size, & _pos, comm);
129 return ( _res == MPI_SUCCESS );
133CommunicationPacket :: unpackHeader(MPI_Comm comm)
138 _res = MPI_Unpack(this->
buff, this->
size, & _pos, _arry, 2, MPI_INT, comm);
139 this->
number = _arry [ 0 ];
142 return ( _res == MPI_SUCCESS );
151 DynamicCommunicationBuffer :: DynamicCommunicationBuffer(MPI_Comm comm, std::size_t size,
bool dynamic) :
165DynamicCommunicationBuffer :: DynamicCommunicationBuffer(MPI_Comm comm,
bool dynamic) :
179DynamicCommunicationBuffer :: ~DynamicCommunicationBuffer()
185DynamicCommunicationBuffer :: init()
192DynamicCommunicationBuffer :: initForPacking()
203DynamicCommunicationBuffer :: initForUnpacking()
254DynamicCommunicationBuffer :: iSend(
int dest,
int tag)
281DynamicCommunicationBuffer :: iRecv(
int source,
int tag, std::size_t count)
295int DynamicCommunicationBuffer :: receiveCompleted()
333int DynamicCommunicationBuffer :: sendCompleted()
342 result &= packet->testCompletion();
350DynamicCommunicationBuffer :: testCompletion()
362DynamicCommunicationBuffer :: waitCompletion()
381DynamicCommunicationBuffer :: giveFitSize(MPI_Datatype type,
int availableSpace,
int arrySize)
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 ) );
399DynamicCommunicationBuffer :: allocateNewPacket(
int n)
414DynamicCommunicationBuffer :: clear()
427DynamicCommunicationBuffer :: popNewRecvPacket()
446DynamicCommunicationBuffer :: bcast(
int root)
455CommunicationPacketPool :: popPacket(MPI_Comm comm)
491 OOFEM_ERROR(
"request to push strange packet (not allocated by pool)");
503CommunicationPacketPool :: clear()
521CommunicationPacketPool :: printInfo()
523 OOFEM_LOG_INFO(
"CommunicationPacketPool: allocated %d packets\n(packet size: %d, %d leased, %d free)\n",
CommunicationBuffer(MPI_Comm comm, std::size_t size, bool dynamic=0)
std ::list< CommunicationPacket * > available_packets
std ::list< CommunicationPacket * > leased_packets
int packHeader(MPI_Comm)
Packs packet header info at receiver beginning.
virtual void init(MPI_Comm comm)
enum oofem::DynamicCommunicationBuffer::DCB_Mode mode
std::list< CommunicationPacket * >::iterator recvIt
Iterator to iterate over received packets.
int active_tag
Active rank and tag (send by initSend,initReceive, and initExchange).
CommunicationPacket * active_packet
Active packet.
void initForUnpacking() override
Initialize for Unpacking (data already received).
void freePacket(CommunicationPacket *)
static CommunicationPacketPool packetPool
Static packet pool.
void pushNewRecvPacket(CommunicationPacket *)
bool completed
Communication completion flag.
std ::list< CommunicationPacket * > packet_list
CommunicationPacket * allocateNewPacket(int)
ComBuff_BYTE_TYPE * buff
Buffer. Dynamically allocated.
std::size_t size
Size and current position in buffer in bytes (sizeof(char)).
MPIBuffer(std::size_t size, bool dynamic=0)
Constructor. Creates buffer of given size, using given communicator for packing.
int givePackSize(MPI_Comm communicator, MPI_Datatype type, std::size_t size)
int resize(std::size_t newSize)
#define __CommunicationPacket_DEFAULT_SIZE
#define OOFEM_WARNING(...)
#define OOFEM_LOG_INFO(...)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)