OMNeT++ Parallel Simulation Support 6.1
Discrete Event Simulation Library
cmpicomm.h
1 //=========================================================================
2 // CMPICOMM.H - part of
3 //
4 // OMNeT++/OMNEST
5 // Discrete System Simulation in C++
6 //
7 //=========================================================================
8 
9 /*--------------------------------------------------------------*
10  Copyright (C) 1992-2017 Andras Varga
11  Copyright (C) 2006-2017 OpenSim Ltd.
12 
13  This file is distributed WITHOUT ANY WARRANTY. See the file
14  `license' for details on this and other legal matters.
15 *--------------------------------------------------------------*/
16 
17 #include "omnetpp/platdep/config.h"
18 
19 #ifdef WITH_MPI
20 
21 #ifndef __OMNETPP_CMPICOMM_H
22 #define __OMNETPP_CMPICOMM_H
23 
24 #include "omnetpp/cparsimcomm.h"
25 
26 namespace omnetpp {
27 
28 class cMPICommBuffer;
29 
35 class SIM_API cMPICommunications : public cParsimCommunications
36 {
37  protected:
38  cMPICommBuffer *recycledBuffer;
39  int numPartitions;
40  int myRank;
41 
42  protected:
46  virtual cMPICommBuffer *doCreateCommBuffer();
47 
48  public:
52  cMPICommunications();
53 
57  virtual ~cMPICommunications();
58 
64  virtual void init(int numPartitions) override;
65 
69  virtual void shutdown() override;
70 
74  virtual int getNumPartitions() const override;
75 
79  virtual int getProcId() const override;
80 
84  virtual cCommBuffer *createCommBuffer() override;
85 
89  virtual void recycleCommBuffer(cCommBuffer *buffer) override;
90 
94  virtual void send(cCommBuffer *buffer, int tag, int destination) override;
95 
99  virtual void broadcast(cCommBuffer *buffer, int tag) override;
100 
105  virtual bool receiveBlocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId) override;
106 
112  virtual bool receiveNonblocking(int filtTag, cCommBuffer *buffer, int& receivedTag, int& sourceProcId) override;
114 };
115 
116 } // namespace omnetpp
117 
118 
119 #endif
120 
121 #endif