Singleton used to interface to the communications infrastructure when running NS3 in parallel. More...
#include "mpi-interface.h"
Static Public Member Functions | |
static void | Destroy () |
Deletes storage used by the parallel environment. | |
static void | Disable () |
Clean up the ns-3 parallel communications interface. | |
static void | Enable (int *pargc, char ***pargv) |
Setup the parallel communication interface. | |
static void | Enable (MPI_Comm communicator) |
Setup the parallel communication interface using the specified communicator. | |
static MPI_Comm | GetCommunicator () |
Return the communicator used to run ns-3. | |
static uint32_t | GetSize () |
Get the number of ranks used by ns-3. | |
static uint32_t | GetSystemId () |
Get the id number of this rank. | |
static bool | IsEnabled () |
Returns enabled state of parallel environment. | |
static void | SendPacket (Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev) |
Send a packet to a remote node. | |
Static Private Member Functions | |
static void | SetParallelSimulatorImpl () |
Common enable logic. | |
Static Private Attributes | |
static ParallelCommunicationInterface * | g_parallelCommunicationInterface = nullptr |
Static instance of the instantiated parallel controller. | |
Singleton used to interface to the communications infrastructure when running NS3 in parallel.
Delegates the implementation to the specific parallel infrastructure being used. Implementation is defined in the ParallelCommunicationInterface virtual base class; this API mirrors that interface. This singleton is responsible for instantiating an instance of the communication interface based on SimulatorImplementationType attribute in ns3::GlobalValues. The attribute must be set before Enable is invoked.
Definition at line 51 of file mpi-interface.h.
|
static |
Deletes storage used by the parallel environment.
Definition at line 32 of file mpi-interface.cc.
References ns3::ParallelCommunicationInterface::Destroy(), g_parallelCommunicationInterface, and NS_ASSERT.
Referenced by ns3::DistributedSimulatorImpl::Destroy(), and ns3::NullMessageSimulatorImpl::Destroy().
|
static |
Clean up the ns-3 parallel communications interface.
MPI_Finalize will be called only if Enable (int* pargc, char*** pargv) was called.
Definition at line 142 of file mpi-interface.cc.
References ns3::ParallelCommunicationInterface::Disable(), g_parallelCommunicationInterface, and NS_ASSERT.
|
static |
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 |
Definition at line 113 of file mpi-interface.cc.
References ns3::ParallelCommunicationInterface::Enable(), g_parallelCommunicationInterface, and SetParallelSimulatorImpl().
|
static |
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 |
Definition at line 121 of file mpi-interface.cc.
References ns3::ParallelCommunicationInterface::Enable(), g_parallelCommunicationInterface, and SetParallelSimulatorImpl().
|
static |
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.
Definition at line 135 of file mpi-interface.cc.
References g_parallelCommunicationInterface, ns3::ParallelCommunicationInterface::GetCommunicator(), and NS_ASSERT.
Referenced by ns3::DistributedSimulatorImpl::CalculateLookAhead(), and ns3::DistributedSimulatorImpl::Run().
|
static |
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.
Definition at line 52 of file mpi-interface.cc.
References g_parallelCommunicationInterface, and ns3::ParallelCommunicationInterface::GetSize().
Referenced by ns3::DistributedSimulatorImpl::DistributedSimulatorImpl(), ns3::NullMessageSimulatorImpl::NullMessageSimulatorImpl(), ns3::DistributedSimulatorImpl::CalculateLookAhead(), ns3::NullMessageSimulatorImpl::CalculateLookAhead(), and ns3::GrantedTimeWindowMpiInterface::ReceiveMessages().
|
static |
Get the id number of this rank.
When running a sequential simulation this will return a systemID of 0.
Definition at line 39 of file mpi-interface.cc.
References g_parallelCommunicationInterface, and ns3::ParallelCommunicationInterface::GetSystemId().
Referenced by ns3::DistributedSimulatorImpl::DistributedSimulatorImpl(), ns3::NullMessageSimulatorImpl::NullMessageSimulatorImpl(), ns3::DistributedSimulatorImpl::CalculateLookAhead(), ns3::NullMessageSimulatorImpl::CalculateLookAhead(), and ns3::PointToPointHelper::Install().
|
static |
Returns enabled state of parallel environment.
Definition at line 65 of file mpi-interface.cc.
References g_parallelCommunicationInterface, and ns3::ParallelCommunicationInterface::IsEnabled().
Referenced by ns3::PointToPointHelper::Install().
|
static |
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
Definition at line 128 of file mpi-interface.cc.
References g_parallelCommunicationInterface, NS_ASSERT, and ns3::ParallelCommunicationInterface::SendPacket().
Referenced by ns3::PointToPointRemoteChannel::TransmitStart().
|
staticprivate |
Common enable logic.
Definition at line 78 of file mpi-interface.cc.
References ns3::GlobalValue::Bind(), g_parallelCommunicationInterface, ns3::StringValue::Get(), ns3::GlobalValue::GetValueByNameFailSafe(), and NS_LOG_WARN.
Referenced by Enable(), and Enable().
|
staticprivate |
Static instance of the instantiated parallel controller.
Definition at line 156 of file mpi-interface.h.
Referenced by Destroy(), Disable(), Enable(), Enable(), GetCommunicator(), GetSize(), GetSystemId(), IsEnabled(), SendPacket(), and SetParallelSimulatorImpl().