ESyS-Particle  2.3.4
mpisgbuf.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 #ifndef __MPISGBUF_H
14 #define __MPISGBUF_H
15 
16 #include <mpi.h>
17 #include <string>
18 #include "Parallel/mpibuf.h"
19 
29 {
30 protected:
31  MPI_Comm m_comm;
32  int m_rank;
33  int m_size;
35  MPI_Status m_status;
36 
37 public:
38  AMPISGBufferRoot(MPI_Comm);
39  virtual ~AMPISGBufferRoot(){};
40 
41  virtual void clear()=0;
42  virtual void gather()=0;
43  virtual void scatter()=0;
44  virtual void append(int,int)=0;
45  virtual void append(double,int)=0;
46  virtual void append(const char*,int)=0;
47  virtual void append(const Vec3 &,int);
48  virtual int pop_int(int)=0;
49  virtual double pop_double(int)=0;
50  virtual void pop_doubles(int,double *,int)=0;
51  virtual Vec3 pop_vector(int);
52  const MPI_Status& status(){return m_status;};
53 };
54 
64 {
65  protected:
66  int m_root;
68 
69 public:
70  AMPISGBufferLeaf(MPI_Comm,int);
71  virtual ~AMPISGBufferLeaf(){};
72 
73  virtual void clear()=0;
74  virtual void send()=0;
75  virtual void receive()=0;
76  virtual void append(int)=0;
77  virtual void append(double)=0;
78  virtual int pop_int()=0;
79  virtual double pop_double()=0;
80  virtual void pop_doubles(double *,int)=0;
81  virtual std::string pop_string()=0;
82  const MPI_Status& status(){return m_status;};
83 };
84 
94 {
95 private:
96  char* m_buffer;
99  int *m_position;
100 
101 public:
102  CMPISGBufferRoot(MPI_Comm,int);
103  virtual ~CMPISGBufferRoot();
104 
105  virtual void clear();
106  virtual void gather();
107  virtual void scatter();
108  virtual void append(int,int);
109  virtual void append(double,int);
110  virtual void append(const char*,int);
111  virtual int pop_int(int);
112  virtual double pop_double(int);
113  virtual void pop_doubles(int,double *,int);
114 };
115 
125 {
126 private:
127  char* m_buffer;
130 
131 public:
132  CMPISGBufferLeaf(MPI_Comm,int,int);
133  virtual ~CMPISGBufferLeaf();
134 
135  virtual void clear();
136  virtual void send();
137  virtual void receive();
138  virtual void append(int);
139  virtual void append(double);
140  virtual void append(const char*);
141  virtual int pop_int();
142  virtual double pop_double();
143  virtual void pop_doubles(double *,int);
144  virtual std::string pop_string();
145 };
146 
147 #endif // __MPISGBUF_H
AMPISGBufferLeaf::m_root
int m_root
rank of the root process
Definition: mpisgbuf.h:66
AMPISGBufferLeaf::pop_double
virtual double pop_double()=0
CMPISGBufferRoot
Buffer for MPI scatter/gather, root component.
Definition: mpisgbuf.h:94
AMPISGBufferRoot::m_rank
int m_rank
the rank in this communicator
Definition: mpisgbuf.h:32
CMPISGBufferRoot::gather
virtual void gather()
Definition: mpisgbuf.cpp:82
CMPISGBufferLeaf::pop_int
virtual int pop_int()
Definition: mpisgbuf.cpp:272
CMPISGBufferRoot::m_buffersize
int m_buffersize
the size of the buffer per slice
Definition: mpisgbuf.h:98
CMPISGBufferLeaf::clear
virtual void clear()
Definition: mpisgbuf.cpp:213
AMPISGBufferRoot::pop_vector
virtual Vec3 pop_vector(int)
Definition: mpisgbuf.cpp:40
esys::lsm::bpu::len
int len(const boost::python::object &pyOb)
Definition: Util.h:30
AMPISGBufferRoot::pop_double
virtual double pop_double(int)=0
AMPISGBufferRoot::append
virtual void append(double, int)=0
AMPISGBufferRoot::m_status
MPI_Status m_status
Definition: mpisgbuf.h:35
AMPISGBufferLeaf::send
virtual void send()=0
CMPISGBufferLeaf::pop_double
virtual double pop_double()
Definition: mpisgbuf.cpp:286
CMPISGBufferRoot::CMPISGBufferRoot
CMPISGBufferRoot(MPI_Comm, int)
Definition: mpisgbuf.cpp:54
AMPISGBufferLeaf::~AMPISGBufferLeaf
virtual ~AMPISGBufferLeaf()
Definition: mpisgbuf.h:71
AMPIBuffer::m_comm
MPI_Comm m_comm
the MPI Communicator used for the send/recv operations
Definition: mpibuf.h:36
AMPIBuffer::m_status
MPI_Status m_status
Definition: mpibuf.h:37
AMPISGBufferLeaf::pop_string
virtual std::string pop_string()=0
AMPISGBufferRoot::append
virtual void append(const char *, int)=0
CMPISGBufferRoot::m_buffer
char * m_buffer
Definition: mpisgbuf.h:96
CMPISGBufferLeaf::~CMPISGBufferLeaf
virtual ~CMPISGBufferLeaf()
Definition: mpisgbuf.cpp:208
CMPISGBufferRoot::pop_double
virtual double pop_double(int)
Definition: mpisgbuf.cpp:160
AMPISGBufferLeaf::m_int_increment
int m_int_increment
Definition: mpisgbuf.h:67
AMPISGBufferRoot::append
virtual void append(int, int)=0
AMPIBuffer
Abstract base class for MPI send/recv buffer.
Definition: mpibuf.h:34
AMPISGBufferLeaf::clear
virtual void clear()=0
AMPISGBufferLeaf::pop_doubles
virtual void pop_doubles(double *, int)=0
AMPISGBufferRoot::AMPISGBufferRoot
AMPISGBufferRoot(MPI_Comm)
Definition: mpisgbuf.cpp:24
CMPISGBufferLeaf::CMPISGBufferLeaf
CMPISGBufferLeaf(MPI_Comm, int, int)
Definition: mpisgbuf.cpp:197
CMPISGBufferLeaf::append
virtual void append(int)
Definition: mpisgbuf.cpp:239
Vec3::X
VEC3_INLINE double & X()
Definition: vec3.h:119
AMPISGBufferRoot::pop_int
virtual int pop_int(int)=0
AMPISGBufferRoot::m_comm
MPI_Comm m_comm
the MPI communicator used for the scatter/gather operations
Definition: mpisgbuf.h:31
CMPISGBufferRoot::m_position
int * m_position
the current end of the content in each slice
Definition: mpisgbuf.h:99
Vec3::Z
VEC3_INLINE double & Z()
Definition: vec3.h:121
CMPISGBufferLeaf::pop_doubles
virtual void pop_doubles(double *, int)
Definition: mpisgbuf.cpp:294
CMPISGBufferLeaf::m_buffersize
int m_buffersize
the size of the buffer
Definition: mpisgbuf.h:128
NULL
#define NULL
Definition: t_list.h:17
AMPISGBufferRoot::status
const MPI_Status & status()
Definition: mpisgbuf.h:52
CMPISGBufferRoot::clear
virtual void clear()
Definition: mpisgbuf.cpp:72
AMPISGBufferRoot::clear
virtual void clear()=0
mpibuf.h
AMPISGBufferRoot::gather
virtual void gather()=0
AMPISGBufferLeaf::status
const MPI_Status & status()
Definition: mpisgbuf.h:82
Vec3::Y
VEC3_INLINE double & Y()
Definition: vec3.h:120
CMPISGBufferLeaf::receive
virtual void receive()
Definition: mpisgbuf.cpp:229
CMPISGBufferLeaf::send
virtual void send()
Definition: mpisgbuf.cpp:221
AMPISGBufferRoot::scatter
virtual void scatter()=0
CMPISGBufferRoot::~CMPISGBufferRoot
virtual ~CMPISGBufferRoot()
Definition: mpisgbuf.cpp:65
CMPISGBufferLeaf::m_buffer
char * m_buffer
Definition: mpisgbuf.h:127
AMPISGBufferLeaf::m_dbl_increment
int m_dbl_increment
the "packing size" of int/double
Definition: mpisgbuf.h:67
Vec3
Definition: vec3.h:47
CMPISGBufferLeaf::pop_string
virtual std::string pop_string()
Definition: mpisgbuf.cpp:305
AMPISGBufferLeaf::AMPISGBufferLeaf
AMPISGBufferLeaf(MPI_Comm, int)
Definition: mpisgbuf.cpp:181
CMPISGBufferRoot::pop_doubles
virtual void pop_doubles(int, double *, int)
Definition: mpisgbuf.cpp:168
mpisgbuf.h
AMPISGBufferLeaf::receive
virtual void receive()=0
CMPISGBufferLeaf
Buffer for MPI scatter/gather, leaf component.
Definition: mpisgbuf.h:125
AMPISGBufferLeaf::append
virtual void append(double)=0
CMPISGBufferRoot::scatter
virtual void scatter()
Definition: mpisgbuf.cpp:90
AMPISGBufferRoot::m_int_increment
int m_int_increment
Definition: mpisgbuf.h:34
CMPISGBufferRoot::append
virtual void append(int, int)
Definition: mpisgbuf.cpp:103
AMPISGBufferLeaf
Abstract base class for scatter/gather buffer, leaf component.
Definition: mpisgbuf.h:64
CMPISGBufferRoot::pop_int
virtual int pop_int(int)
Definition: mpisgbuf.cpp:143
AMPISGBufferLeaf::pop_int
virtual int pop_int()=0
AMPISGBufferRoot::m_size
int m_size
size of the communicator
Definition: mpisgbuf.h:33
CMPISGBufferRoot::m_dummy_buffer
char * m_dummy_buffer
dummy buffer sent by root to itself
Definition: mpisgbuf.h:97
AMPISGBufferLeaf::append
virtual void append(int)=0
AMPISGBufferRoot::pop_doubles
virtual void pop_doubles(int, double *, int)=0
CMPISGBufferLeaf::m_position
int m_position
the current end of the content
Definition: mpisgbuf.h:129
AMPISGBufferRoot::~AMPISGBufferRoot
virtual ~AMPISGBufferRoot()
Definition: mpisgbuf.h:39
AMPISGBufferRoot::m_dbl_increment
int m_dbl_increment
the "packing size" of int/double
Definition: mpisgbuf.h:34
AMPISGBufferRoot
Abstract base class for scatter/gather buffer, root component.
Definition: mpisgbuf.h:29