A Discrete-Event Network Simulator
API
null-message-mpi-interface.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2013. Lawrence Livermore National Security, LLC.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Steven Smith <smith84@llnl.gov>
19  */
20 
27 #ifndef NS3_NULLMESSAGE_MPI_INTERFACE_H
28 #define NS3_NULLMESSAGE_MPI_INTERFACE_H
29 
31 
32 #include <ns3/nstime.h>
33 #include <ns3/buffer.h>
34 
35 #include "mpi.h"
36 #include <list>
37 
38 namespace ns3 {
39 
40 class NullMessageSimulatorImpl;
41 class NullMessageSentBuffer;
42 class RemoteChannelBundle;
43 class Packet;
44 
52 {
53 public:
58  static TypeId GetTypeId (void);
59 
62 
63  // Inherited
64  virtual void Destroy ();
65  virtual uint32_t GetSystemId ();
66  virtual uint32_t GetSize ();
67  virtual bool IsEnabled ();
68  virtual void Enable (int* pargc, char*** pargv);
69  virtual void Enable (MPI_Comm communicator);
70  virtual void Disable ();
71  virtual void SendPacket (Ptr<Packet> p, const Time &rxTime, uint32_t node, uint32_t dev);
72  virtual MPI_Comm GetCommunicator();
73 
74 private:
75 
84 
103  static void SendNullMessage (const Time& guaranteeUpdate, Ptr<RemoteChannelBundle> bundle);
108  static void ReceiveMessagesNonBlocking ();
113  static void ReceiveMessagesBlocking ();
117  static void TestSendComplete ();
118 
125  static void InitializeSendReceiveBuffers (void);
126 
136  static void ReceiveMessages (bool blocking = false);
137 
139  static uint32_t g_sid;
140 
142  static uint32_t g_size;
143 
145  static uint32_t g_numNeighbors;
146 
148  static bool g_enabled;
149 
154  static bool g_mpiInitCalled;
155 
157  static MPI_Request* g_requests;
158 
160  static char** g_pRxBuffers;
161 
163  static std::list<NullMessageSentBuffer> g_pendingTx;
164 
166  static MPI_Comm g_communicator;
167 
169  static bool g_freeCommunicator;
170 };
171 
172 } // namespace ns3
173 
174 #endif /* NS3_NULL_MESSAGE_MPI_INTERFACE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::NullMessageMpiInterface::g_size
static uint32_t g_size
Size of the MPI COM_WORLD group.
Definition: null-message-mpi-interface.h:142
ns3::RemoteChannelBundle
Collection of ns-3 channels between local and remote nodes.
Definition: remote-channel-bundle.h:52
ns3::NullMessageMpiInterface::ReceiveMessagesBlocking
static void ReceiveMessagesBlocking()
Blocking message receive.
Definition: null-message-mpi-interface.cc:328
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::NullMessageMpiInterface::TestSendComplete
static void TestSendComplete()
Check for completed sends.
Definition: null-message-mpi-interface.cc:443
ns3::NullMessageMpiInterface::g_communicator
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
Definition: null-message-mpi-interface.h:166
ns3::NullMessageMpiInterface::g_pRxBuffers
static char ** g_pRxBuffers
Data buffers for non-blocking receives.
Definition: null-message-mpi-interface.h:160
ns3::NullMessageMpiInterface::g_freeCommunicator
static bool g_freeCommunicator
Did we create the communicator? Have to free it.
Definition: null-message-mpi-interface.h:169
ns3::NullMessageMpiInterface::ReceiveMessages
static void ReceiveMessages(bool blocking=false)
Check for received messages complete.
Definition: null-message-mpi-interface.cc:345
ns3::NullMessageMpiInterface::Enable
virtual void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
Definition: null-message-mpi-interface.cc:195
ns3::NullMessageMpiInterface::g_sid
static uint32_t g_sid
System ID (rank) for this task.
Definition: null-message-mpi-interface.h:139
ns3::NullMessageMpiInterface::g_mpiInitCalled
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
Definition: null-message-mpi-interface.h:154
ns3::NullMessageMpiInterface::g_requests
static MPI_Request * g_requests
Pending non-blocking receives.
Definition: null-message-mpi-interface.h:157
ns3::Ptr< Packet >
ns3::NullMessageMpiInterface::InitializeSendReceiveBuffers
static void InitializeSendReceiveBuffers(void)
Initialize send and receive buffers.
Definition: null-message-mpi-interface.cc:235
ns3::NullMessageMpiInterface::SendPacket
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
Definition: null-message-mpi-interface.cc:260
ns3::NullMessageMpiInterface::g_numNeighbors
static uint32_t g_numNeighbors
Number of neighbor tasks, tasks that this task shares a link with.
Definition: null-message-mpi-interface.h:145
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::NullMessageMpiInterface::GetCommunicator
virtual MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
Definition: null-message-mpi-interface.cc:182
ns3::NullMessageSimulatorImpl
Simulator implementation using MPI and a Null Message algorithm.
Definition: null-message-simulator-impl.h:52
ns3::NullMessageMpiInterface::~NullMessageMpiInterface
~NullMessageMpiInterface()
Definition: null-message-mpi-interface.cc:156
ns3::NullMessageMpiInterface
Interface between ns-3 and MPI for the Null Message distributed simulation implementation.
Definition: null-message-mpi-interface.h:52
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::NullMessageMpiInterface::GetSystemId
virtual uint32_t GetSystemId()
Get the id number of this rank.
Definition: null-message-mpi-interface.cc:168
ns3::NullMessageMpiInterface::NullMessageMpiInterface
NullMessageMpiInterface()
Definition: null-message-mpi-interface.cc:151
ns3::NullMessageMpiInterface::GetSize
virtual uint32_t GetSize()
Get the number of ranks used by ns-3.
Definition: null-message-mpi-interface.cc:175
ns3::NullMessageMpiInterface::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: null-message-mpi-interface.cc:142
ns3::NullMessageMpiInterface::g_pendingTx
static std::list< NullMessageSentBuffer > g_pendingTx
List of pending non-blocking sends.
Definition: null-message-mpi-interface.h:163
ns3::NullMessageMpiInterface::SendNullMessage
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
Definition: null-message-mpi-interface.cc:299
ns3::NullMessageMpiInterface::IsEnabled
virtual bool IsEnabled()
Returns enabled state of parallel environment.
Definition: null-message-mpi-interface.cc:189
ns3::NullMessageMpiInterface::Disable
virtual void Disable()
Clean up the ns-3 parallel communications interface.
Definition: null-message-mpi-interface.cc:465
ns3::NullMessageMpiInterface::ReceiveMessagesNonBlocking
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
Definition: null-message-mpi-interface.cc:337
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::NullMessageMpiInterface::g_enabled
static bool g_enabled
Has this interface been enabled.
Definition: null-message-mpi-interface.h:148
ns3::NullMessageMpiInterface::Destroy
virtual void Destroy()
Deletes storage used by the parallel environment.
Definition: null-message-mpi-interface.cc:162
parallel-communication-interface.h
Declaration of class ns3::ParallelCommunicationInterface.