A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
granted-time-window-mpi-interface.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: George Riley <riley@ece.gatech.edu>
16 */
17
24// This object contains static methods that provide an easy interface
25// to the necessary MPI information.
26
27#ifndef NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H
28#define NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H
29
31
32#include "ns3/buffer.h"
33#include "ns3/nstime.h"
34
35#include <list>
36#include <mpi.h>
37#include <stdint.h>
38
39namespace ns3
40{
41
47
57{
58 public:
59 SentBuffer();
61
65 uint8_t* GetBuffer();
69 void SetBuffer(uint8_t* buffer);
73 MPI_Request* GetRequest();
74
75 private:
76 uint8_t* m_buffer;
77 MPI_Request m_request;
78};
79
80class Packet;
82
93{
94 public:
99 static TypeId GetTypeId();
100
101 // Inherited
102 void Destroy() override;
103 uint32_t GetSystemId() override;
104 uint32_t GetSize() override;
105 bool IsEnabled() override;
106 void Enable(int* pargc, char*** pargv) override;
107 void Enable(MPI_Comm communicator) override;
108 void Disable() override;
109 void SendPacket(Ptr<Packet> p, const Time& rxTime, uint32_t node, uint32_t dev) override;
110 MPI_Comm GetCommunicator() override;
111
112 private:
113 /*
114 * The granted time window implementation is a collaboration of several
115 * classes. Methods that should be invoked only by the
116 * collaborators are private to restrict use.
117 * It is not intended for state to be shared.
118 */
120
124 static void ReceiveMessages();
128 static void TestSendComplete();
132 static uint32_t GetRxCount();
136 static uint32_t GetTxCount();
137
142
145
148
150 static bool g_enabled;
151
156 static bool g_mpiInitCalled;
157
159 static MPI_Request* g_requests;
160
162 static char** g_pRxBuffers;
163
165 static std::list<SentBuffer> g_pendingTx;
166
168 static MPI_Comm g_communicator;
169
172};
173
174} // namespace ns3
175
176#endif /* NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H */
Distributed simulator implementation using lookahead.
static void ReceiveMessages()
Check for received messages complete.
MPI_Comm GetCommunicator() override
Return the communicator used to run ns-3.
static bool g_freeCommunicator
Did ns-3 create the communicator? Have to free it.
uint32_t GetSystemId() override
Get the id number of this rank.
void Disable() override
Clean up the ns-3 parallel communications interface.
static void TestSendComplete()
Check for completed sends.
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev) override
Send a packet to a remote node.
static uint32_t g_size
Size of the MPI COM_WORLD group.
static bool g_enabled
Has this interface been enabled.
static std::list< SentBuffer > g_pendingTx
List of pending non-blocking sends.
void Enable(int *pargc, char ***pargv) override
Setup the parallel communication interface.
bool IsEnabled() override
Returns enabled state of parallel environment.
static MPI_Request * g_requests
Pending non-blocking receives.
static uint32_t g_rxCount
Total packets received.
uint32_t GetSize() override
Get the number of ranks used by ns-3.
static char ** g_pRxBuffers
Data buffers for non-blocking reads.
void Destroy() override
Deletes storage used by the parallel environment.
static uint32_t g_txCount
Total packets sent.
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
static TypeId GetTypeId()
Register this type.
static uint32_t g_sid
System ID (rank) for this task.
A base class which provides memory management and object aggregation.
Definition: object.h:89
network packets
Definition: packet.h:239
Pure virtual base class for the interface between ns-3 and the parallel communication layer being use...
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Tracks non-blocking sends.
MPI_Request m_request
The MPI request handle.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
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.