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 */
ns3::GrantedTimeWindowMpiInterface::TestSendComplete
static void TestSendComplete()
Check for completed sends.
Definition: granted-time-window-mpi-interface.cc:300
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::SentBuffer::GetRequest
MPI_Request * GetRequest()
Definition: granted-time-window-mpi-interface.cc:76
ns3::SentBuffer::SetBuffer
void SetBuffer(uint8_t *buffer)
Definition: granted-time-window-mpi-interface.cc:70
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::GrantedTimeWindowMpiInterface::Enable
virtual void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
Definition: granted-time-window-mpi-interface.cc:161
ns3::SentBuffer::GetBuffer
uint8_t * GetBuffer()
Definition: granted-time-window-mpi-interface.cc:64
ns3::GrantedTimeWindowMpiInterface::g_freeCommunicator
static bool g_freeCommunicator
Did ns-3 create the communicator? Have to free it.
Definition: granted-time-window-mpi-interface.h:173
ns3::GrantedTimeWindowMpiInterface::Destroy
virtual void Destroy()
Deletes storage used by the parallel environment.
Definition: granted-time-window-mpi-interface.cc:105
ns3::DistributedSimulatorImpl
Distributed simulator implementation using lookahead.
Definition: distributed-simulator-impl.h:108
ns3::GrantedTimeWindowMpiInterface::IsEnabled
virtual bool IsEnabled()
Returns enabled state of parallel environment.
Definition: granted-time-window-mpi-interface.cc:148
ns3::SentBuffer
Tracks non-blocking sends.
Definition: granted-time-window-mpi-interface.h:58
ns3::GrantedTimeWindowMpiInterface::g_sid
static uint32_t g_sid
System ID (rank) for this task.
Definition: granted-time-window-mpi-interface.h:141
ns3::MAX_MPI_MSG_SIZE
const uint32_t MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation
Definition: granted-time-window-mpi-interface.h:47
ns3::GrantedTimeWindowMpiInterface::ReceiveMessages
static void ReceiveMessages()
Check for received messages complete.
Definition: granted-time-window-mpi-interface.cc:240
ns3::GrantedTimeWindowMpiInterface
Interface between ns-3 and MPI.
Definition: granted-time-window-mpi-interface.h:94
ns3::GrantedTimeWindowMpiInterface::g_enabled
static bool g_enabled
Has this interface been enabled.
Definition: granted-time-window-mpi-interface.h:152
ns3::Packet
network packets
Definition: packet.h:232
ns3::SentBuffer::m_request
MPI_Request m_request
The MPI request handle.
Definition: granted-time-window-mpi-interface.h:78
ns3::GrantedTimeWindowMpiInterface::GetRxCount
static uint32_t GetRxCount()
Definition: granted-time-window-mpi-interface.cc:120
ns3::Ptr< Packet >
ns3::GrantedTimeWindowMpiInterface::g_communicator
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
Definition: granted-time-window-mpi-interface.h:170
ns3::GrantedTimeWindowMpiInterface::g_rxCount
static uint32_t g_rxCount
Total packets received.
Definition: granted-time-window-mpi-interface.h:146
ns3::GrantedTimeWindowMpiInterface::g_pRxBuffers
static char ** g_pRxBuffers
Data buffers for non-blocking reads.
Definition: granted-time-window-mpi-interface.h:164
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::GrantedTimeWindowMpiInterface::Disable
virtual void Disable()
Clean up the ns-3 parallel communications interface.
Definition: granted-time-window-mpi-interface.cc:320
ns3::GrantedTimeWindowMpiInterface::g_mpiInitCalled
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
Definition: granted-time-window-mpi-interface.h:158
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::SentBuffer::m_buffer
uint8_t * m_buffer
The buffer.
Definition: granted-time-window-mpi-interface.h:77
ns3::GrantedTimeWindowMpiInterface::g_txCount
static uint32_t g_txCount
Total packets sent.
Definition: granted-time-window-mpi-interface.h:149
ns3::SentBuffer::SentBuffer
SentBuffer()
Definition: granted-time-window-mpi-interface.cc:52
ns3::GrantedTimeWindowMpiInterface::g_requests
static MPI_Request * g_requests
Pending non-blocking receives.
Definition: granted-time-window-mpi-interface.h:161
ns3::GrantedTimeWindowMpiInterface::GetSystemId
virtual uint32_t GetSystemId()
Get the id number of this rank.
Definition: granted-time-window-mpi-interface.cc:134
ns3::GrantedTimeWindowMpiInterface::GetCommunicator
virtual MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
Definition: granted-time-window-mpi-interface.cc:154
ns3::GrantedTimeWindowMpiInterface::g_pendingTx
static std::list< SentBuffer > g_pendingTx
List of pending non-blocking sends.
Definition: granted-time-window-mpi-interface.h:167
ns3::GrantedTimeWindowMpiInterface::SendPacket
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
Definition: granted-time-window-mpi-interface.cc:209
ns3::ParallelCommunicationInterface
Pure virtual base class for the interface between ns-3 and the parallel communication layer being use...
Definition: parallel-communication-interface.h:60
ns3::GrantedTimeWindowMpiInterface::GetSize
virtual uint32_t GetSize()
Get the number of ranks used by ns-3.
Definition: granted-time-window-mpi-interface.cc:141
ns3::GrantedTimeWindowMpiInterface::GetTxCount
static uint32_t GetTxCount()
Definition: granted-time-window-mpi-interface.cc:127
ns3::GrantedTimeWindowMpiInterface::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: granted-time-window-mpi-interface.cc:95
ns3::SentBuffer::~SentBuffer
~SentBuffer()
Definition: granted-time-window-mpi-interface.cc:58
ns3::GrantedTimeWindowMpiInterface::g_size
static uint32_t g_size
Size of the MPI COM_WORLD group.
Definition: granted-time-window-mpi-interface.h:143
parallel-communication-interface.h
Declaration of class ns3::ParallelCommunicationInterface.