Go to the documentation of this file.
46MPIBuffer :: MPIBuffer(std::size_t
size,
bool dynamic)
58MPIBuffer :: MPIBuffer(
bool dynamic)
69MPIBuffer :: ~MPIBuffer()
78MPIBuffer :: resize(std::size_t newSize)
81 if (
size >= newSize ) {
107 this->
buff = newBuff;
123MPIBuffer :: packArray(MPI_Comm communicator,
const void *src, std::size_t n, MPI_Datatype type)
141 void *__src =
const_cast< void *
>(src);
143 int _currPosInt =
static_cast<int>(this->
curr_pos);
144 int result = (MPI_Pack(__src, n, type, this->
buff, this->
size,
145 & _currPosInt, communicator) == MPI_SUCCESS );
146 this->
curr_pos =
static_cast<std::size_t
>(_currPosInt);
151MPIBuffer :: unpackArray(MPI_Comm communicator,
void *dest, std::size_t n, MPI_Datatype type)
154 int _currPosInt =
static_cast<int>(this->
curr_pos);
155 int result = (MPI_Unpack(this->
buff, this->
size, & _currPosInt,
156 dest, n, type, communicator) == MPI_SUCCESS );
157 this->
curr_pos =
static_cast<std::size_t
>(_currPosInt);
162MPIBuffer :: iSend(MPI_Comm communicator,
int dest,
int tag)
164 return ( MPI_Isend(this->
buff, this->
curr_pos, MPI_PACKED, dest, tag,
165 communicator, & this->
request) == MPI_SUCCESS );
170MPIBuffer :: iRecv(MPI_Comm communicator,
int source,
int tag, std::size_t count)
173 if ( count >= this->
size ) {
175 if ( this->
resize(count) == 0 ) {
181 return ( MPI_Irecv(this->
buff, this->
size, MPI_PACKED, source, tag,
182 communicator, & this->
request) == MPI_SUCCESS );
186MPIBuffer :: testCompletion()
191 MPI_Test(& this->
request, & flag, & status);
196MPIBuffer :: testCompletion(
int &source,
int &tag)
201 MPI_Test(& this->
request, & flag, & status);
203 source = status.MPI_SOURCE;
204 tag = status.MPI_TAG;
210MPIBuffer :: waitCompletion()
214 return ( MPI_Wait(& this->
request, & status) == MPI_SUCCESS );
219MPIBuffer :: bcast(MPI_Comm communicator,
int root)
221 return MPI_Bcast(this->
buff, this->
size, MPI_PACKED, root, communicator);
226MPIBuffer :: givePackSize(MPI_Comm communicator, MPI_Datatype type, std::size_t
size)
229 MPI_Pack_size(
size, type, communicator, & requiredSpace);
230 return requiredSpace;
237 for (
int _i = 0; _i < 20; ++_i ) {
238 fprintf(stderr,
"%d ",
buff [ _i ]);
241 fprintf(stderr,
"\n");
265int CommunicationBuffer :: read(
bool &data)
268 int ret = this->
read(& val, 1);
273int CommunicationBuffer :: write(
bool data)
276 return this->
write(& val, 1);
279int CommunicationBuffer :: givePackSizeOfInt(std::size_t count)
283 return requiredSpace;
286int CommunicationBuffer :: givePackSizeOfDouble(std::size_t count)
289 MPI_Pack_size(count, MPI_DOUBLE,
communicator, & requiredSpace);
290 return requiredSpace;
293int CommunicationBuffer :: givePackSizeOfChar(std::size_t count)
296 MPI_Pack_size(count, MPI_CHAR,
communicator, & requiredSpace);
297 return requiredSpace;
300int CommunicationBuffer :: givePackSizeOfBool(std::size_t count)
303 MPI_Pack_size(count, MPI_CHAR,
communicator, & requiredSpace);
304 return requiredSpace;
307int CommunicationBuffer :: givePackSizeOfLong(std::size_t count)
310 MPI_Pack_size(count, MPI_LONG,
communicator, & requiredSpace);
311 return requiredSpace;
314int CommunicationBuffer :: givePackSizeOfSizet(std::size_t count)
318 return requiredSpace;
int write(bool data) override
Writes a bool value.
int read(bool &data) override
Reads a bool value from data.
ComBuff_BYTE_TYPE * buff
Buffer. Dynamically allocated.
std::size_t size
Size and current position in buffer in bytes (sizeof(char)).
bool isDynamic
Dynamic flag (if true, buffer can grow, but reallocation is needed).
int givePackSize(MPI_Comm communicator, MPI_Datatype type, std::size_t size)
int resize(std::size_t newSize)
#define __CommunicationBuffer_ALLOC_CHUNK
#define OOFEM_WARNING(...)
This page is part of the
OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak
Bořek Patzák
Project e-mail:
oofem@fsv.cvut.cz
Generated at for OOFEM by
doxygen
1.15.0 written by Dimitri van Heesch,
© 1997-2011