A Discrete-Event Network Simulator
API
granted-time-window-mpi-interface.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: George Riley <riley@ece.gatech.edu>
17  */
18 
25 // This object contains static methods that provide an easy interface
26 // to the necessary MPI information.
27 
28 #ifndef NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H
29 #define NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H
30 
31 #include <stdint.h>
32 #include <list>
33 
34 #include "ns3/nstime.h"
35 #include "ns3/buffer.h"
36 
38 
39 #include "mpi.h"
40 
41 namespace ns3 {
42 
47 const uint32_t MAX_MPI_MSG_SIZE = 2000;
48 
58 {
59 public:
60  SentBuffer ();
61  ~SentBuffer ();
62 
66  uint8_t* GetBuffer ();
70  void SetBuffer (uint8_t* buffer);
74  MPI_Request* GetRequest ();
75 
76 private:
77  uint8_t* m_buffer;
78  MPI_Request m_request;
79 };
80 
81 class Packet;
83 
94 {
95 public:
100  static TypeId GetTypeId (void);
101 
102  // Inherited
103  virtual void Destroy ();
104  virtual uint32_t GetSystemId ();
105  virtual uint32_t GetSize ();
106  virtual bool IsEnabled ();
107  virtual void Enable (int* pargc, char*** pargv);
108  virtual void Enable (MPI_Comm communicator);
109  virtual void Disable();
110  virtual void SendPacket (Ptr<Packet> p, const Time &rxTime, uint32_t node, uint32_t dev);
111  virtual MPI_Comm GetCommunicator();
112 
113 private:
114 
115  /*
116  * The granted time window implementation is a collaboration of several
117  * classes. Methods that should be invoked only by the
118  * collaborators are private to restrict use.
119  * It is not intended for state to be shared.
120  */
122 
126  static void ReceiveMessages ();
130  static void TestSendComplete ();
134  static uint32_t GetRxCount ();
138  static uint32_t GetTxCount ();
139 
141  static uint32_t g_sid;
143  static uint32_t g_size;
144 
146  static uint32_t g_rxCount;
147 
149  static uint32_t g_txCount;
150 
152  static bool g_enabled;
153 
158  static bool g_mpiInitCalled;
159 
161  static MPI_Request* g_requests;
162 
164  static char** g_pRxBuffers;
165 
167  static std::list<SentBuffer> g_pendingTx;
168 
170  static MPI_Comm g_communicator;
171 
173  static bool g_freeCommunicator;
174 };
175 
176 } // namespace ns3
177 
178 #endif /* NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H */
static uint32_t g_sid
System ID (rank) for this task.
static uint32_t g_rxCount
Total packets received.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
static uint32_t g_txCount
Total packets sent.
virtual MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
static TypeId GetTypeId(void)
Register this type.
virtual void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
virtual uint32_t GetSize()
Get the number of ranks used by ns-3.
Pure virtual base class for the interface between ns-3 and the parallel communication layer being use...
network packets
Definition: packet.h:231
static void TestSendComplete()
Check for completed sends.
virtual uint32_t GetSystemId()
Get the id number of this rank.
uint8_t * m_buffer
The buffer.
MPI_Request m_request
The MPI request handle.
Tracks non-blocking sends.
virtual bool IsEnabled()
Returns enabled state of parallel environment.
static std::list< SentBuffer > g_pendingTx
List of pending non-blocking sends.
Distributed simulator implementation using lookahead.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
Declaration of class ns3::ParallelCommunicationInterface.
static bool g_freeCommunicator
Did ns-3 create the communicator? Have to free it.
virtual void Disable()
Clean up the ns-3 parallel communications interface.
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
static char ** g_pRxBuffers
Data buffers for non-blocking reads.
static void ReceiveMessages()
Check for received messages complete.
static bool g_enabled
Has this interface been enabled.
const uint32_t MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation
static uint32_t g_size
Size of the MPI COM_WORLD group.
A base class which provides memory management and object aggregation.
Definition: object.h:87
static MPI_Request * g_requests
Pending non-blocking receives.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void Destroy()
Deletes storage used by the parallel environment.