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 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: George Riley <riley@ece.gatech.edu>
5 */
6
7/**
8 * \file
9 * \ingroup mpi
10 * Declaration of classes ns3::SentBuffer and ns3::GrantedTimeWindowMpiInterface.
11 */
12
13// This object contains static methods that provide an easy interface
14// to the necessary MPI information.
15
16#ifndef NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H
17#define NS3_GRANTED_TIME_WINDOW_MPI_INTERFACE_H
18
20
21#include "ns3/buffer.h"
22#include "ns3/nstime.h"
23
24#include <list>
25#include <mpi.h>
26#include <stdint.h>
27
28namespace ns3
29{
30
31/**
32 * maximum MPI message size for easy
33 * buffer creation
34 */
36
37/**
38 * \ingroup mpi
39 *
40 * \brief Tracks non-blocking sends
41 *
42 * This class is used to keep track of the asynchronous non-blocking
43 * sends that have been posted.
44 */
46{
47 public:
48 SentBuffer();
50
51 /**
52 * \return pointer to sent buffer
53 */
54 uint8_t* GetBuffer();
55 /**
56 * \param buffer pointer to sent buffer
57 */
58 void SetBuffer(uint8_t* buffer);
59 /**
60 * \return MPI request
61 */
62 MPI_Request* GetRequest();
63
64 private:
65 uint8_t* m_buffer; /**< The buffer. */
66 MPI_Request m_request; /**< The MPI request handle. */
67};
68
69class Packet;
71
72/**
73 * \ingroup mpi
74 *
75 * \brief Interface between ns-3 and MPI
76 *
77 * Implements the interface used by the singleton parallel controller
78 * to interface between NS3 and the communications layer being
79 * used for inter-task packet transfers.
80 */
82{
83 public:
84 /**
85 * Register this type.
86 * \return The object TypeId.
87 */
88 static TypeId GetTypeId();
89
90 // Inherited
91 void Destroy() override;
92 uint32_t GetSystemId() override;
93 uint32_t GetSize() override;
94 bool IsEnabled() override;
95 void Enable(int* pargc, char*** pargv) override;
96 void Enable(MPI_Comm communicator) override;
97 void Disable() override;
98 void SendPacket(Ptr<Packet> p, const Time& rxTime, uint32_t node, uint32_t dev) override;
99 MPI_Comm GetCommunicator() override;
100
101 private:
102 /*
103 * The granted time window implementation is a collaboration of several
104 * classes. Methods that should be invoked only by the
105 * collaborators are private to restrict use.
106 * It is not intended for state to be shared.
107 */
109
110 /**
111 * Check for received messages complete
112 */
113 static void ReceiveMessages();
114 /**
115 * Check for completed sends
116 */
117 static void TestSendComplete();
118 /**
119 * \return received count in packets
120 */
121 static uint32_t GetRxCount();
122 /**
123 * \return transmitted count in packets
124 */
125 static uint32_t GetTxCount();
126
127 /** System ID (rank) for this task. */
129 /** Size of the MPI COM_WORLD group. */
131
132 /** Total packets received. */
134
135 /** Total packets sent. */
137
138 /** Has this interface been enabled. */
139 static bool g_enabled;
140
141 /**
142 * Has MPI Init been called by this interface.
143 * Alternatively user supplies a communicator.
144 */
145 static bool g_mpiInitCalled;
146
147 /** Pending non-blocking receives. */
148 static MPI_Request* g_requests;
149
150 /** Data buffers for non-blocking reads. */
151 static char** g_pRxBuffers;
152
153 /** List of pending non-blocking sends. */
154 static std::list<SentBuffer> g_pendingTx;
155
156 /** MPI communicator being used for ns-3 tasks. */
157 static MPI_Comm g_communicator;
158
159 /** Did ns-3 create the communicator? Have to free it. */
161};
162
163} // namespace ns3
164
165#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 MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
static uint32_t g_sid
System ID (rank) for this task.
A base class which provides memory management and object aggregation.
Definition object.h:78
network packets
Definition packet.h:228
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.
Tracks non-blocking sends.
MPI_Request m_request
The MPI request handle.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
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.