A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
null-message-mpi-interface.h
Go to the documentation of this file.
1/*
2 * Copyright 2013. Lawrence Livermore National Security, LLC.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Steven Smith <smith84@llnl.gov>
18 */
19
26#ifndef NS3_NULLMESSAGE_MPI_INTERFACE_H
27#define NS3_NULLMESSAGE_MPI_INTERFACE_H
28
30
31#include <ns3/buffer.h>
32#include <ns3/nstime.h>
33
34#include <list>
35#include <mpi.h>
36
37namespace ns3
38{
39
40class NullMessageSimulatorImpl;
41class NullMessageSentBuffer;
42class RemoteChannelBundle;
43class Packet;
44
52{
53 public:
58 static TypeId GetTypeId();
59
61 ~NullMessageMpiInterface() override;
62
63 // Inherited
64 void Destroy() override;
65 uint32_t GetSystemId() override;
66 uint32_t GetSize() override;
67 bool IsEnabled() override;
68 void Enable(int* pargc, char*** pargv) override;
69 void Enable(MPI_Comm communicator) override;
70 void Disable() override;
71 void SendPacket(Ptr<Packet> p, const Time& rxTime, uint32_t node, uint32_t dev) override;
72 MPI_Comm GetCommunicator() override;
73
74 private:
75 /*
76 * The null message implementation is a collaboration of several
77 * classes. Methods that should be invoked only by the
78 * collaborators are private to restrict use.
79 * It is not intended for state to be shared.
80 */
83
102 static void SendNullMessage(const Time& guaranteeUpdate, Ptr<RemoteChannelBundle> bundle);
107 static void ReceiveMessagesNonBlocking();
112 static void ReceiveMessagesBlocking();
116 static void TestSendComplete();
117
124 static void InitializeSendReceiveBuffers();
125
135 static void ReceiveMessages(bool blocking = false);
136
139
142
145
147 static bool g_enabled;
148
153 static bool g_mpiInitCalled;
154
156 static MPI_Request* g_requests;
157
159 static char** g_pRxBuffers;
160
162 static std::list<NullMessageSentBuffer> g_pendingTx;
163
165 static MPI_Comm g_communicator;
166
169};
170
171} // namespace ns3
172
173#endif /* NS3_NULL_MESSAGE_MPI_INTERFACE_H */
Interface between ns-3 and MPI for the Null Message distributed simulation implementation.
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
void Destroy() override
Deletes storage used by the parallel environment.
static void ReceiveMessagesBlocking()
Blocking message receive.
void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev) override
Send a packet to a remote node.
bool IsEnabled() override
Returns enabled state of parallel environment.
uint32_t GetSize() override
Get the number of ranks used by ns-3.
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
static TypeId GetTypeId()
Register this type.
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
MPI_Comm GetCommunicator() override
Return the communicator used to run ns-3.
static MPI_Request * g_requests
Pending non-blocking receives.
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
static void TestSendComplete()
Check for completed sends.
static void ReceiveMessages(bool blocking=false)
Check for received messages complete.
void Enable(int *pargc, char ***pargv) override
Setup the parallel communication interface.
static bool g_enabled
Has this interface been enabled.
static char ** g_pRxBuffers
Data buffers for non-blocking receives.
static void InitializeSendReceiveBuffers()
Initialize send and receive buffers.
static uint32_t g_sid
System ID (rank) for this task.
static uint32_t g_size
Size of the MPI COM_WORLD group.
void Disable() override
Clean up the ns-3 parallel communications interface.
static std::list< NullMessageSentBuffer > g_pendingTx
List of pending non-blocking sends.
static bool g_freeCommunicator
Did we create the communicator? Have to free it.
uint32_t GetSystemId() override
Get the id number of this rank.
static uint32_t g_numNeighbors
Number of neighbor tasks, tasks that this task shares a link with.
Simulator implementation using MPI and a Null Message algorithm.
A base class which provides memory management and object aggregation.
Definition: object.h:89
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
Collection of ns-3 channels between local and remote nodes.
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.
Declaration of class ns3::ParallelCommunicationInterface.