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 */
Distributed simulator implementation using lookahead.
virtual void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
static void ReceiveMessages()
Check for received messages complete.
static TypeId GetTypeId(void)
Register this type.
static bool g_freeCommunicator
Did ns-3 create the communicator? Have to free it.
static void TestSendComplete()
Check for completed sends.
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
static uint32_t g_size
Size of the MPI COM_WORLD group.
static bool g_enabled
Has this interface been enabled.
virtual void Disable()
Clean up the ns-3 parallel communications interface.
static std::list< SentBuffer > g_pendingTx
List of pending non-blocking sends.
virtual MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
virtual void Destroy()
Deletes storage used by the parallel environment.
virtual uint32_t GetSystemId()
Get the id number of this rank.
static MPI_Request * g_requests
Pending non-blocking receives.
static uint32_t g_rxCount
Total packets received.
static char ** g_pRxBuffers
Data buffers for non-blocking reads.
static uint32_t g_txCount
Total packets sent.
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
virtual bool IsEnabled()
Returns enabled state of parallel environment.
static uint32_t g_sid
System ID (rank) for this task.
virtual uint32_t GetSize()
Get the number of ranks used by ns-3.
A base class which provides memory management and object aggregation.
Definition: object.h:88
network packets
Definition: packet.h:232
Pure virtual base class for the interface between ns-3 and the parallel communication layer being use...
Tracks non-blocking sends.
MPI_Request m_request
The MPI request handle.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const uint32_t MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation
Declaration of class ns3::ParallelCommunicationInterface.