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
18/**
19 * \file
20 * \ingroup mpi
21 * Declaration of classes ns3::SentBuffer and ns3::GrantedTimeWindowMpiInterface.
22 */
23
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
42/**
43 * maximum MPI message size for easy
44 * buffer creation
45 */
47
48/**
49 * \ingroup mpi
50 *
51 * \brief Tracks non-blocking sends
52 *
53 * This class is used to keep track of the asynchronous non-blocking
54 * sends that have been posted.
55 */
57{
58 public:
59 SentBuffer();
61
62 /**
63 * \return pointer to sent buffer
64 */
65 uint8_t* GetBuffer();
66 /**
67 * \param buffer pointer to sent buffer
68 */
69 void SetBuffer(uint8_t* buffer);
70 /**
71 * \return MPI request
72 */
73 MPI_Request* GetRequest();
74
75 private:
76 uint8_t* m_buffer; /**< The buffer. */
77 MPI_Request m_request; /**< The MPI request handle. */
78};
79
80class Packet;
82
83/**
84 * \ingroup mpi
85 *
86 * \brief Interface between ns-3 and MPI
87 *
88 * Implements the interface used by the singleton parallel controller
89 * to interface between NS3 and the communications layer being
90 * used for inter-task packet transfers.
91 */
93{
94 public:
95 /**
96 * Register this type.
97 * \return The object TypeId.
98 */
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
121 /**
122 * Check for received messages complete
123 */
124 static void ReceiveMessages();
125 /**
126 * Check for completed sends
127 */
128 static void TestSendComplete();
129 /**
130 * \return received count in packets
131 */
132 static uint32_t GetRxCount();
133 /**
134 * \return transmitted count in packets
135 */
136 static uint32_t GetTxCount();
137
138 /** System ID (rank) for this task. */
140 /** Size of the MPI COM_WORLD group. */
142
143 /** Total packets received. */
145
146 /** Total packets sent. */
148
149 /** Has this interface been enabled. */
150 static bool g_enabled;
151
152 /**
153 * Has MPI Init been called by this interface.
154 * Alternatively user supplies a communicator.
155 */
156 static bool g_mpiInitCalled;
157
158 /** Pending non-blocking receives. */
159 static MPI_Request* g_requests;
160
161 /** Data buffers for non-blocking reads. */
162 static char** g_pRxBuffers;
163
164 /** List of pending non-blocking sends. */
165 static std::list<SentBuffer> g_pendingTx;
166
167 /** MPI communicator being used for ns-3 tasks. */
168 static MPI_Comm g_communicator;
169
170 /** Did ns-3 create the communicator? Have to free it. */
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:77
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.