C++ mpi module for stochmagnet_main Package
MPI_CoreToCoreMessage.h
1 #ifndef MPI_CoreToCoreMessage_H
2 #define MPI_CoreToCoreMessage_H
3 
4 //inherited class header
5 #include "MPI_Object.h"
6 
7 
8 //types header
9 #include "MPI_Type.h"
10 
11 //environement header
12 #include "MPI_Environment.h"
13 
14 //MPI timer header
15 #include "MPI_Chrono.h"
16 
28 template<typename T>
30 
31  //attributes
32 private :
33 
34  //UML inheritance classes
36  typedef MPI_Object SuperClass;
37 
38 
39 protected:
40  // CONSTRUCTORS
44 
45  }
46 
47  // DESTRUCTORS
50  virtual ~MPI_CoreToCoreMessage(void) {
51 
52  }
53 public:
54  //memory management
55  //=================
58  virtual tMemSize getMemorySize() const override{
59  return sizeof(*this)+getContentsMemorySize();
60  }
61 
70  virtual tMemSize getContentsMemorySize() const override {
72  }
73 
74  //sender methods
75  //===============
76  //primary type variable
77  //----------------------
78 
79  //pointer of primary type
80  //------------------------
81 
82  //valarray primary type
83  //---------------------
84 public:
91  virtual void send(const MPI_Environment& env,const tMPICoreId& dstCore,
92  const std::valarray<T>& data,const tMPITag& tag)=0;
93 
94  //MPI Type
95  //---------
103  virtual void send(const MPI_Environment& env,const tMPICoreId& dstCore,
104  const T* data,const tMPICount& nData,const tMPIType& dataType,const tMPITag& tag)=0;
105 
106 
107  //receive methods
108  //===============
109 
110  //primary type variable
111  //----------------------
112 
113  //pointer of primary type
114  //------------------------
115  //valarray primary type
116  //---------------------
117 
124  virtual void receive(const MPI_Environment& env,const tMPICoreId& srcCore,
125  std::valarray<T>& data,const tMPITag& tag)=0;
126 
127  //MPI Type
128  //---------
129 
130 
139  virtual void receive(const MPI_Environment& env,const tMPICoreId& dstCore,
140  T* buffer,const tMPICount& nData,const tMPIType& dataType,const tMPITag& tag)=0;
141 
142  //send & receive methods
143  //=======================
144 
145  //primary type variable
146  //----------------------
156  virtual void sendNReceive(const MPI_Environment& env,const tMPICoreId& dstCore,const tMPICoreId& srcCore,
157  const T& sentData,const tMPITag& sentTag,
158  T& receivedData,const tMPITag& receivedTag)=0;
159  //pointer of primary type
160  //------------------------
161  //valarray primary type
162  //---------------------
163 
173  virtual void sendNReceive(const MPI_Environment& env,const tMPICoreId& dstCore,const tMPICoreId& srcCore,
174  const std::valarray<T>& sentData,const tMPITag& sentTag,
175  std::valarray<T>& receivedData,const tMPITag& receivedTag)=0;
176 
177  //MPI Type
178  //---------
179 
180 
194  virtual void sendNReceive(const MPI_Environment& env,const tMPICoreId& dstCore,const tMPICoreId& srcCore,
195  const T* sentData,const tMPICount& nSentData,const tMPIType& sentDataType,const tMPITag& sentTag,
196  T* receivedData,const tMPICount& nReceivedData,const tMPIType& receivedDataType,const tMPITag& receivedTag)=0;
197 
198  //exchange methods
199  //=======================
200 
201  //primary type variable
202  //----------------------
203 
204  //pointer of primary type
205  //------------------------
206  //valarray primary type
207  //---------------------
208 
215  virtual void exchange(const MPI_Environment& env,const tMPICoreId& srcCore,
216  std::valarray<T>& data,const tMPITag& tag)=0;
217 
218  //MPI Type
219  //---------
220 
221 
222 
223  //mesage methods
224  //==============
225 
226 
227 
231  virtual void getElementsNumber(tMPICount& nElements)=0;
232 
235  virtual int wait()=0;
236 
237 
240  virtual tBoolean isFinished()=0;
241 
242 
247  inline static tULLInt WaitAllMessages(const std::vector<CORE_UniquePointer<MPI_CoreToCoreMessage<T>>>& messages) {
248  MPI_Chrono timer;
249  timer.start();
250  typename std::vector<CORE_UniquePointer<MPI_CoreToCoreMessage<T>>>::const_iterator iMessage;
251  tBoolean isAllFinished=false;
252  while (!isAllFinished) {
253  isAllFinished=true;
254  iMessage=messages.begin();
255  while (iMessage!=messages.end()) {
256  isAllFinished=isAllFinished && (*iMessage)->isFinished();
257  iMessage++;
258  }
259  }
260  return timer.stop();
261  }
262 
263 };
264 
265 #endif
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
This class is a time class to manage time within an environment.
Definition: MPI_Chrono.h:20
void start()
start the chrono
Definition: MPI_Chrono.h:114
tULLInt stop() const
stop the chrono
Definition: MPI_Chrono.h:121
This class is a interface class to send / receive message with primitive type T from one to core to o...
Definition: MPI_CoreToCoreMessage.h:29
MPI_CoreToCoreMessage()
create
Definition: MPI_CoreToCoreMessage.h:43
virtual void receive(const MPI_Environment &env, const tMPICoreId &srcCore, std::valarray< T > &data, const tMPITag &tag)=0
receiving a data with flag to dstCore
virtual tBoolean isFinished()=0
test if the message communication is finished
virtual int wait()=0
wait the end of the message communications
virtual void sendNReceive(const MPI_Environment &env, const tMPICoreId &dstCore, const tMPICoreId &srcCore, const T *sentData, const tMPICount &nSentData, const tMPIType &sentDataType, const tMPITag &sentTag, T *receivedData, const tMPICount &nReceivedData, const tMPIType &receivedDataType, const tMPITag &receivedTag)=0
receiving a data with flag to dstCore
virtual void send(const MPI_Environment &env, const tMPICoreId &dstCore, const std::valarray< T > &data, const tMPITag &tag)=0
sending a data with flag to dstCore
virtual void exchange(const MPI_Environment &env, const tMPICoreId &srcCore, std::valarray< T > &data, const tMPITag &tag)=0
receiving a data with flag to dstCore
virtual tMemSize getContentsMemorySize() const override
return nthe memory size of the included associations
Definition: MPI_CoreToCoreMessage.h:70
static tULLInt WaitAllMessages(const std::vector< CORE_UniquePointer< MPI_CoreToCoreMessage< T >>> &messages)
wait for the end of communication of all messages
Definition: MPI_CoreToCoreMessage.h:247
virtual void send(const MPI_Environment &env, const tMPICoreId &dstCore, const T *data, const tMPICount &nData, const tMPIType &dataType, const tMPITag &tag)=0
blocking send a data with tag to dstCore
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: MPI_CoreToCoreMessage.h:58
virtual void sendNReceive(const MPI_Environment &env, const tMPICoreId &dstCore, const tMPICoreId &srcCore, const std::valarray< T > &sentData, const tMPITag &sentTag, std::valarray< T > &receivedData, const tMPITag &receivedTag)=0
receiving a data with flag to dstCore
virtual void receive(const MPI_Environment &env, const tMPICoreId &dstCore, T *buffer, const tMPICount &nData, const tMPIType &dataType, const tMPITag &tag)=0
blocking send a data with tag to dstCore
virtual ~MPI_CoreToCoreMessage(void)
destroy
Definition: MPI_CoreToCoreMessage.h:50
virtual void sendNReceive(const MPI_Environment &env, const tMPICoreId &dstCore, const tMPICoreId &srcCore, const T &sentData, const tMPITag &sentTag, T &receivedData, const tMPITag &receivedTag)=0
receiving a data with flag to dstCore
virtual void getElementsNumber(tMPICount &nElements)=0
get the number of element of the message
This class is a Environment class to define MPI world.
Definition: MPI_Environment.h:36
This class is a base class of E-MicromM core package.
Definition: MPI_Object.h:32