Interface between ns-3 and MPI. More...
#include "granted-time-window-mpi-interface.h"
Public Member Functions | |
virtual void | Destroy () |
Deletes storage used by the parallel environment. More... | |
virtual void | Disable () |
Clean up the ns-3 parallel communications interface. More... | |
virtual void | Enable (int *pargc, char ***pargv) |
Setup the parallel communication interface. More... | |
virtual void | Enable (MPI_Comm communicator) |
Setup the parallel communication interface using the specified communicator. More... | |
virtual MPI_Comm | GetCommunicator () |
Return the communicator used to run ns-3. More... | |
virtual uint32_t | GetSize () |
Get the number of ranks used by ns-3. More... | |
virtual uint32_t | GetSystemId () |
Get the id number of this rank. More... | |
virtual bool | IsEnabled () |
Returns enabled state of parallel environment. More... | |
virtual void | SendPacket (Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev) |
Send a packet to a remote node. More... | |
Public Member Functions inherited from ns3::ParallelCommunicationInterface | |
virtual | ~ParallelCommunicationInterface () |
Destructor. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Private Member Functions | |
static uint32_t | GetRxCount () |
static uint32_t | GetTxCount () |
static void | ReceiveMessages () |
Check for received messages complete. More... | |
static void | TestSendComplete () |
Check for completed sends. More... | |
Static Private Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Private Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Private Attributes | |
static MPI_Comm | g_communicator = MPI_COMM_WORLD |
MPI communicator being used for ns-3 tasks. More... | |
static bool | g_enabled = false |
Has this interface been enabled. More... | |
static bool | g_freeCommunicator = false |
Did ns-3 create the communicator? Have to free it. More... | |
static bool | g_mpiInitCalled = false |
Has MPI Init been called by this interface. More... | |
static std::list< SentBuffer > | g_pendingTx |
List of pending non-blocking sends. More... | |
static char ** | g_pRxBuffers |
Data buffers for non-blocking reads. More... | |
static MPI_Request * | g_requests |
Pending non-blocking receives. More... | |
static uint32_t | g_rxCount = 0 |
Total packets received. More... | |
static uint32_t | g_sid = 0 |
System ID (rank) for this task. More... | |
static uint32_t | g_size = 1 |
Size of the MPI COM_WORLD group. More... | |
static uint32_t | g_txCount = 0 |
Total packets sent. More... | |
Additional Inherited Members | |
Private Member Functions inherited from ns3::Object | |
Object () | |
Constructor. More... | |
virtual | ~Object () |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose (void) |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator (void) const |
Get an iterator to the Objects aggregated to this one. More... | |
virtual TypeId | GetInstanceTypeId (void) const |
Get the most derived TypeId for this Object. More... | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (void) const |
Get a pointer to the requested aggregated Object. More... | |
void | Initialize (void) |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized (void) const |
Check if the object has been initialized. More... | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoDispose (void) |
Destructor implementation. More... | |
virtual void | DoInitialize (void) |
Initialize() implementation. More... | |
virtual void | NotifyNewAggregate (void) |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
Private Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= ([[maybe_unused]] const SimpleRefCount &o) |
Assignment operator. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Private Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising erros. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted (void) |
Notifier called once the ObjectBase is fully constructed. More... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
Interface between ns-3 and MPI.
Introspection did not find any typical Config paths.
Implements the interface used by the singleton parallel controller to interface between NS3 and the communications layer being used for inter-task packet transfers.
No Attributes are defined for this type.
No TraceSources are defined for this type.
Size of this type is 40 bytes (on a 64-bit architecture).
Definition at line 93 of file granted-time-window-mpi-interface.h.
|
virtual |
Deletes storage used by the parallel environment.
Implements ns3::ParallelCommunicationInterface.
Definition at line 105 of file granted-time-window-mpi-interface.cc.
References g_pendingTx, g_pRxBuffers, g_requests, GetSize(), and NS_LOG_FUNCTION.
|
virtual |
Clean up the ns-3 parallel communications interface.
MPI_Finalize will be called only if Enable (int* pargc, char*** pargv) was called.
Implements ns3::ParallelCommunicationInterface.
Definition at line 320 of file granted-time-window-mpi-interface.cc.
References g_communicator, g_enabled, g_freeCommunicator, g_mpiInitCalled, NS_FATAL_ERROR, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Setup the parallel communication interface.
There are two ways to setup the communications interface. This Enable method is the easiest method and should be used in most situations.
Disable() must be invoked at end of an ns-3 application to properly cleanup the parallel communication interface.
This method will call MPI_Init and configure ns-3 to use the MPI_COMM_WORLD communicator.
For more complex situations, such as embedding ns-3 with other MPI simulators or libraries, the Enable(MPI_Comm communcicator) may be used if MPI is initialized externally or if ns-3 needs to be run unique communicator. For example if there are two parallel simulators and the goal is to run each simulator on a different set of ranks.
pargc | number of command line arguments |
pargv | command line arguments |
Implements ns3::ParallelCommunicationInterface.
Definition at line 161 of file granted-time-window-mpi-interface.cc.
References g_enabled, g_mpiInitCalled, NS_ASSERT, and NS_LOG_FUNCTION.
|
virtual |
Setup the parallel communication interface using the specified communicator.
See Enable (int* pargc, char*** pargv) for additional information.
communicator | MPI Communicator that should be used by ns-3 |
Implements ns3::ParallelCommunicationInterface.
Definition at line 175 of file granted-time-window-mpi-interface.cc.
References g_communicator, g_enabled, g_freeCommunicator, g_pRxBuffers, g_requests, g_sid, g_size, GetSize(), ns3::MAX_MPI_MSG_SIZE, NS_ASSERT, and NS_LOG_FUNCTION.
|
virtual |
Return the communicator used to run ns-3.
The communicator returned will be MPI_COMM_WORLD if Enable (int* pargc, char*** pargv) is used to enable or the user specified communicator if Enable (MPI_Comm communicator) is used.
Implements ns3::ParallelCommunicationInterface.
Definition at line 154 of file granted-time-window-mpi-interface.cc.
References g_communicator, g_enabled, and NS_ASSERT.
|
staticprivate |
Definition at line 120 of file granted-time-window-mpi-interface.cc.
References g_enabled, g_rxCount, and NS_ASSERT.
Referenced by ns3::DistributedSimulatorImpl::Run().
|
virtual |
Get the number of ranks used by ns-3.
Returns the size (number of MPI ranks) of the communicator used by ns-3. When running a sequential simulation this will return a size of 1.
Implements ns3::ParallelCommunicationInterface.
Definition at line 141 of file granted-time-window-mpi-interface.cc.
References g_enabled, g_size, and NS_ASSERT.
Referenced by Destroy(), and Enable().
|
virtual |
Get the id number of this rank.
When running a sequential simulation this will return a systemID of 0.
Implements ns3::ParallelCommunicationInterface.
Definition at line 134 of file granted-time-window-mpi-interface.cc.
|
staticprivate |
Definition at line 127 of file granted-time-window-mpi-interface.cc.
References g_enabled, g_txCount, and NS_ASSERT.
Referenced by ns3::DistributedSimulatorImpl::Run().
|
static |
Register this type.
Definition at line 95 of file granted-time-window-mpi-interface.cc.
References ns3::TypeId::SetParent().
|
virtual |
Returns enabled state of parallel environment.
Implements ns3::ParallelCommunicationInterface.
Definition at line 148 of file granted-time-window-mpi-interface.cc.
References g_enabled.
|
staticprivate |
Check for received messages complete.
Definition at line 240 of file granted-time-window-mpi-interface.cc.
References g_communicator, g_pRxBuffers, g_requests, g_rxCount, ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::NetDevice::GetIfIndex(), ns3::Node::GetNDevices(), ns3::NodeList::GetNode(), ns3::Object::GetObject(), ns3::MpiInterface::GetSize(), ns3::MAX_MPI_MSG_SIZE, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION_NOARGS, ns3::MpiReceiver::Receive(), and ns3::Simulator::ScheduleWithContext().
Referenced by ns3::DistributedSimulatorImpl::Run().
|
virtual |
Send a packet to a remote node.
p | packet to send |
rxTime | received time at destination node |
node | destination node |
dev | destination device |
Serialize and send a packet to the specified node and net device
Implements ns3::ParallelCommunicationInterface.
Definition at line 209 of file granted-time-window-mpi-interface.cc.
References g_communicator, g_pendingTx, g_txCount, ns3::Time::GetInteger(), ns3::NodeList::GetNode(), ns3::Packet::GetSerializedSize(), ns3::Node::GetSystemId(), ns3::Time::GetTimeStep(), NS_LOG_FUNCTION, and ns3::Packet::Serialize().
|
staticprivate |
Check for completed sends.
Definition at line 300 of file granted-time-window-mpi-interface.cc.
References g_pendingTx, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::DistributedSimulatorImpl::Run().
|
staticprivate |
MPI communicator being used for ns-3 tasks.
Definition at line 170 of file granted-time-window-mpi-interface.h.
Referenced by Disable(), Enable(), GetCommunicator(), ReceiveMessages(), and SendPacket().
|
staticprivate |
Has this interface been enabled.
Definition at line 152 of file granted-time-window-mpi-interface.h.
Referenced by Disable(), Enable(), GetCommunicator(), GetRxCount(), GetSize(), GetSystemId(), GetTxCount(), and IsEnabled().
|
staticprivate |
Did ns-3 create the communicator? Have to free it.
Definition at line 173 of file granted-time-window-mpi-interface.h.
|
staticprivate |
Has MPI Init been called by this interface.
Alternatively user supplies a communicator.
Definition at line 158 of file granted-time-window-mpi-interface.h.
|
staticprivate |
List of pending non-blocking sends.
Definition at line 167 of file granted-time-window-mpi-interface.h.
Referenced by Destroy(), SendPacket(), and TestSendComplete().
|
staticprivate |
Data buffers for non-blocking reads.
Definition at line 164 of file granted-time-window-mpi-interface.h.
Referenced by Destroy(), Enable(), and ReceiveMessages().
|
staticprivate |
Pending non-blocking receives.
Definition at line 161 of file granted-time-window-mpi-interface.h.
Referenced by Destroy(), Enable(), and ReceiveMessages().
|
staticprivate |
Total packets received.
Definition at line 146 of file granted-time-window-mpi-interface.h.
Referenced by GetRxCount(), and ReceiveMessages().
|
staticprivate |
System ID (rank) for this task.
Definition at line 141 of file granted-time-window-mpi-interface.h.
Referenced by Enable(), and GetSystemId().
|
staticprivate |
Size of the MPI COM_WORLD group.
Definition at line 143 of file granted-time-window-mpi-interface.h.
|
staticprivate |
Total packets sent.
Definition at line 149 of file granted-time-window-mpi-interface.h.
Referenced by GetTxCount(), and SendPacket().