81 if (
size >= newSize ) {
107 this->
buff = newBuff;
141 void *__src =
const_cast< void *
>(src);
142 return ( MPI_Pack(__src, n, type, this->
buff, this->
size,
143 & this->
curr_pos, communicator) == MPI_SUCCESS );
150 dest, n, type, communicator) == MPI_SUCCESS );
156 return ( MPI_Isend(this->
buff, this->
curr_pos, MPI_PACKED, dest, tag,
157 communicator, & this->
request) == MPI_SUCCESS );
165 if ( count >= this->
size ) {
167 if ( this->
resize(count) == 0 ) {
173 return ( MPI_Irecv(this->
buff, this->
size, MPI_PACKED, source, tag,
174 communicator, & this->
request) == MPI_SUCCESS );
183 MPI_Test(& this->
request, & flag, & status);
193 MPI_Test(& this->
request, & flag, & status);
195 source = status.MPI_SOURCE;
196 tag = status.MPI_TAG;
206 return ( MPI_Wait(& this->
request, & status) == MPI_SUCCESS );
213 return MPI_Bcast(this->
buff, this->
size, MPI_PACKED, root, communicator);
221 MPI_Pack_size(size, type, communicator, & requredSpace);
229 for (
int _i = 0; _i < 20; ++_i ) {
230 fprintf(stderr,
"%d ",
buff [ _i ]);
233 fprintf(stderr,
"\n");
260 int ret = this->read(& val, 1);
268 return this->write(& val, 1);
274 MPI_Pack_size(count, MPI_INT, communicator, & requiredSpace);
275 return requiredSpace;
281 MPI_Pack_size(count, MPI_DOUBLE, communicator, & requiredSpace);
282 return requiredSpace;
288 MPI_Pack_size(count, MPI_CHAR, communicator, & requiredSpace);
289 return requiredSpace;
295 MPI_Pack_size(count, MPI_CHAR, communicator, & requiredSpace);
296 return requiredSpace;
302 MPI_Pack_size(count, MPI_LONG, communicator, & requiredSpace);
303 return requiredSpace;
virtual int givePackSizeOfLong(int count)
virtual void init()
Initializes buffer to empty state.
int packArray(MPI_Comm communicator, const void *src, int n, MPI_Datatype type)
Packs array of a values of given type into buffer.
int bcast(MPI_Comm communicator, int root)
Initializes broadcast over collaborating processes.
virtual int givePackSizeOfChar(int count)
int givePackSize(MPI_Comm communicator, MPI_Datatype type, int size)
Returns pack size required to pack array of given type and size (c-style).
char ComBuff_BYTE_TYPE
Type with size equal to one byte (sizeof (ComBuff_BYTE_TYPE) should be 1).
ComBuff_BYTE_TYPE * buff
Buffer. Dynamically allocated.
virtual int iSend(MPI_Comm communicator, int dest, int tag)
Starts standard mode, nonblocking send.
virtual int waitCompletion()
Waits until a completion of a nonblocking communication.
MPI_Request request
MPI request handle.
int resize(int newSize)
Resizes buffer to given size.
virtual int givePackSizeOfInt(int count)
int size
Size and current position in buffer in bytes (sizeof(char)).
virtual int write(bool data)
Writes a bool value.
bool isDynamic
Dynamic flag (if true, buffer can grow, but reallocation is needed).
virtual int givePackSizeOfDouble(int count)
virtual int iRecv(MPI_Comm communicator, int source, int tag, int count=0)
Starts standard mode, nonblocking receive.
int testCompletion()
Tests if the operation identified by this->request is complete.
int unpackArray(MPI_Comm communicator, void *dest, int n, MPI_Datatype type)
Unpacks array of values of given type from buffer.
MPIBuffer(int size, bool dynamic=0)
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.
virtual int read(bool &data)
Reads a bool value from data.
#define __CommunicationBuffer_ALLOC_CHUNK
#define OOFEM_WARNING(...)
virtual ~MPIBuffer()
Destructor.
virtual int givePackSizeOfBool(int count)