47 #define __CommunicationPacket_DEFAULT_SIZE 40960 80 virtual void init(MPI_Comm comm);
92 int iSend(MPI_Comm communicator,
int dest,
int tag);
102 int iRecv(MPI_Comm communicator,
int source,
int tag,
int count = 0);
110 virtual int testCompletion();
119 virtual int waitCompletion();
129 int packHeader(MPI_Comm);
130 int unpackHeader(MPI_Comm);
142 allocatedPackets = leasedPackets = freePackets;
163 std :: list< CommunicationPacket * > :: iterator
recvIt;
184 virtual int resize(
int newSize) {
return 1; }
188 virtual void initForPacking();
190 virtual void initForUnpacking();
192 virtual int write(
const int *src,
int n)
193 {
return __write(src, n, MPI_INT); }
194 virtual int write(
const long *src,
int n)
195 {
return __write(src, n, MPI_LONG); }
196 virtual int write(
const unsigned long *src,
int n)
197 {
return __write(src, n, MPI_UNSIGNED_LONG); }
198 virtual int write(
const double *src,
int n)
199 {
return __write(src, n, MPI_DOUBLE); }
200 virtual int write(
const char *src,
int n)
201 {
return __write(src, n, MPI_CHAR); }
203 virtual int read(
int *dest,
int n)
204 {
return __read(dest, n, MPI_INT); }
205 virtual int read(
long *dest,
int n)
206 {
return __read(dest, n, MPI_LONG); }
207 virtual int read(
unsigned long *dest,
int n)
208 {
return __read(dest, n, MPI_UNSIGNED_LONG); }
209 virtual int read(
double *dest,
int n)
210 {
return __read(dest, n, MPI_DOUBLE); }
211 virtual int read(
char *dest,
int n)
212 {
return __read(dest, n, MPI_CHAR); }
215 virtual int iSend(
int dest,
int tag);
216 virtual int iRecv(
int source,
int tag,
int count = 0);
217 virtual int bcast(
int root);
226 int testCompletion();
235 virtual int waitCompletion();
244 int receiveCompleted();
247 void popNewRecvPacket();
251 int giveFitSize(MPI_Datatype type,
int availableSpace,
int arrySize);
258 template<
class T >
int __write(T *src,
int n, MPI_Datatype type) {
260 int start_indx = 0, end_indx, _size;
261 int remaining_size = n;
265 end_indx = start_indx + _size;
268 _result &= active_packet->
packArray(communicator, src + start_indx, _size, type);
271 if ( end_indx >= n ) {
276 active_packet = this->allocateNewPacket(++number_of_packets);
277 packet_list.push_back(active_packet);
278 start_indx = end_indx;
279 remaining_size -= _size;
290 template<
class T >
int __read(T *dest,
int n, MPI_Datatype type) {
292 int start_indx = 0, end_indx, _size;
293 int remaining_size = n;
297 end_indx = start_indx + _size;
300 _result &= active_packet->
unpackArray(communicator, dest + start_indx, _size, type);
303 if ( end_indx >= n ) {
308 this->popNewRecvPacket();
309 start_indx = end_indx;
310 remaining_size -= _size;
318 #endif // dyncombuff_h virtual int write(const char *src, int n)
Writes count char values from array pointed by data.
virtual int read(long *dest, int n)
Reads count long values into array pointed by data.
CommunicationPacket * active_packet
Active packet.
int packArray(MPI_Comm communicator, const void *src, int n, MPI_Datatype type)
Packs array of a values of given type into buffer.
static CommunicationPacketPool packetPool
Static packet pool.
int __write(T *src, int n, MPI_Datatype type)
Templated low-level array packing method.
virtual int read(int *dest, int n)
Reads count integer values into array pointed by data.
virtual int read(char *dest, int n)
Reads count char values into array pointed by data.
virtual int read(unsigned long *dest, int n)
Reads count unsigned long values into array pointed by data.
int active_tag
Active rank and tag (send by initSend,initReceive, and initExchange).
std::list< CommunicationPacket * >::iterator recvIt
Iterator to iterate over received packets.
bool completed
Communication completion flag.
std::list< CommunicationPacket * > packet_list
Class CommunicationPacket represent a data-packet, that is used to implement dynamic communicator...
Class CommunicationBuffer provides abstraction for communication buffer.
std::list< CommunicationPacket * > available_packets
virtual int write(const unsigned long *src, int n)
Writes count unsigned long values from array pointed by data.
virtual int write(const long *src, int n)
Writes count long values from array pointed by data.
virtual int read(double *dest, int n)
Reads count double values into array pointed by data.
CommunicationPacketPool()
virtual int write(const int *src, int n)
Writes count integer values from array pointed by data.
int __read(T *dest, int n, MPI_Datatype type)
Templated low-level array unpacking method.
int unpackArray(MPI_Comm communicator, void *dest, int n, MPI_Datatype type)
Unpacks array of values of given type from buffer.
std::list< CommunicationPacket * > leased_packets
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual int write(const double *src, int n)
Writes count double values from array pointed by data.
~CommunicationPacketPool()
virtual int resize(int newSize)
Resizes buffer to given size.