A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::GrantedTimeWindowMpiInterface Class Reference

Interface between ns-3 and MPI. More...

#include "granted-time-window-mpi-interface.h"

+ Inheritance diagram for ns3::GrantedTimeWindowMpiInterface:
+ Collaboration diagram for ns3::GrantedTimeWindowMpiInterface:

Public Member Functions

void Destroy () override
 Deletes storage used by the parallel environment.
 
void Disable () override
 Clean up the ns-3 parallel communications interface.
 
void Enable (int *pargc, char ***pargv) override
 Setup the parallel communication interface.
 
void Enable (MPI_Comm communicator) override
 Setup the parallel communication interface using the specified communicator.
 
MPI_Comm GetCommunicator () override
 Return the communicator used to run ns-3.
 
uint32_t GetSize () override
 Get the number of ranks used by ns-3.
 
uint32_t GetSystemId () override
 Get the id number of this rank.
 
bool IsEnabled () override
 Returns enabled state of parallel environment.
 
void SendPacket (Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev) override
 Send a packet to a remote node.
 
- Public Member Functions inherited from ns3::ParallelCommunicationInterface
virtual ~ParallelCommunicationInterface ()
 Destructor.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Register this type.
 

Static Private Member Functions

static uint32_t GetRxCount ()
 
static uint32_t GetTxCount ()
 
static void ReceiveMessages ()
 Check for received messages complete.
 
static void TestSendComplete ()
 Check for completed sends.
 
- Static Private Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Private Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Static Private Attributes

static MPI_Comm g_communicator = MPI_COMM_WORLD
 MPI communicator being used for ns-3 tasks.
 
static bool g_enabled = false
 Has this interface been enabled.
 
static bool g_freeCommunicator = false
 Did ns-3 create the communicator? Have to free it.
 
static bool g_mpiInitCalled = false
 Has MPI Init been called by this interface.
 
static std::list< SentBufferg_pendingTx
 List of pending non-blocking sends.
 
static char ** g_pRxBuffers
 Data buffers for non-blocking reads.
 
static MPI_Request * g_requests
 Pending non-blocking receives.
 
static uint32_t g_rxCount = 0
 Total packets received.
 
static uint32_t g_sid = 0
 System ID (rank) for this task.
 
static uint32_t g_size = 1
 Size of the MPI COM_WORLD group.
 
static uint32_t g_txCount = 0
 Total packets sent.
 

Additional Inherited Members

- Private Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Private Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Private Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

Interface between ns-3 and MPI.

Implements the interface used by the singleton parallel controller to interface between NS3 and the communications layer being used for inter-task packet transfers.

Definition at line 81 of file granted-time-window-mpi-interface.h.

Member Function Documentation

◆ Destroy()

void ns3::GrantedTimeWindowMpiInterface::Destroy ( )
overridevirtual

Deletes storage used by the parallel environment.

Implements ns3::ParallelCommunicationInterface.

Definition at line 92 of file granted-time-window-mpi-interface.cc.

References g_pendingTx, g_pRxBuffers, g_requests, GetSize(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Disable()

void ns3::GrantedTimeWindowMpiInterface::Disable ( )
overridevirtual

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 328 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.

◆ Enable() [1/2]

void ns3::GrantedTimeWindowMpiInterface::Enable ( int * pargc,
char *** pargv )
overridevirtual

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.

Note
The `SimulatorImplementationType attribute in ns3::GlobalValues must be set before calling Enable()
Parameters
pargcnumber of command line arguments
pargvcommand line arguments

Implements ns3::ParallelCommunicationInterface.

Definition at line 148 of file granted-time-window-mpi-interface.cc.

References Enable(), g_enabled, g_mpiInitCalled, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by Enable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Enable() [2/2]

void ns3::GrantedTimeWindowMpiInterface::Enable ( MPI_Comm communicator)
overridevirtual

Setup the parallel communication interface using the specified communicator.

See Enable (int* pargc, char*** pargv) for additional information.

Parameters
communicatorMPI Communicator that should be used by ns-3

Implements ns3::ParallelCommunicationInterface.

Definition at line 162 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.

+ Here is the call graph for this function:

◆ GetCommunicator()

MPI_Comm ns3::GrantedTimeWindowMpiInterface::GetCommunicator ( )
overridevirtual

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.

Returns
The MPI Communicator.

Implements ns3::ParallelCommunicationInterface.

Definition at line 141 of file granted-time-window-mpi-interface.cc.

References g_communicator, g_enabled, and NS_ASSERT.

◆ GetRxCount()

uint32_t ns3::GrantedTimeWindowMpiInterface::GetRxCount ( )
staticprivate
Returns
received count in packets

Definition at line 107 of file granted-time-window-mpi-interface.cc.

References g_enabled, g_rxCount, and NS_ASSERT.

Referenced by ns3::DistributedSimulatorImpl::Run().

+ Here is the caller graph for this function:

◆ GetSize()

uint32_t ns3::GrantedTimeWindowMpiInterface::GetSize ( )
overridevirtual

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.

Returns
number of parallel tasks

Implements ns3::ParallelCommunicationInterface.

Definition at line 128 of file granted-time-window-mpi-interface.cc.

References g_enabled, g_size, and NS_ASSERT.

Referenced by Destroy(), and Enable().

+ Here is the caller graph for this function:

◆ GetSystemId()

uint32_t ns3::GrantedTimeWindowMpiInterface::GetSystemId ( )
overridevirtual

Get the id number of this rank.

When running a sequential simulation this will return a systemID of 0.

Returns
system identification

Implements ns3::ParallelCommunicationInterface.

Definition at line 121 of file granted-time-window-mpi-interface.cc.

References g_enabled, g_sid, and NS_ASSERT.

◆ GetTxCount()

uint32_t ns3::GrantedTimeWindowMpiInterface::GetTxCount ( )
staticprivate
Returns
transmitted count in packets

Definition at line 114 of file granted-time-window-mpi-interface.cc.

References g_enabled, g_txCount, and NS_ASSERT.

Referenced by ns3::DistributedSimulatorImpl::Run().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::GrantedTimeWindowMpiInterface::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 84 of file granted-time-window-mpi-interface.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ IsEnabled()

bool ns3::GrantedTimeWindowMpiInterface::IsEnabled ( )
overridevirtual

Returns enabled state of parallel environment.

Returns
true if parallel communication is enabled

Implements ns3::ParallelCommunicationInterface.

Definition at line 135 of file granted-time-window-mpi-interface.cc.

References g_enabled.

◆ ReceiveMessages()

void ns3::GrantedTimeWindowMpiInterface::ReceiveMessages ( )
staticprivate

Check for received messages complete.

Definition at line 240 of file granted-time-window-mpi-interface.cc.

References ns3::Create(), g_communicator, g_pRxBuffers, g_requests, g_rxCount, ns3::NodeList::GetNode(), ns3::MpiInterface::GetSize(), ns3::MAX_MPI_MSG_SIZE, nDevices, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION_NOARGS, ns3::MpiReceiver::Receive(), and ns3::Simulator::ScheduleWithContext().

Referenced by ns3::DistributedSimulatorImpl::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendPacket()

void ns3::GrantedTimeWindowMpiInterface::SendPacket ( Ptr< Packet > p,
const Time & rxTime,
uint32_t node,
uint32_t dev )
overridevirtual

Send a packet to a remote node.

Parameters
ppacket to send
rxTimereceived time at destination node
nodedestination node
devdestination device

Serialize and send a packet to the specified node and net device

Implements ns3::ParallelCommunicationInterface.

Definition at line 201 of file granted-time-window-mpi-interface.cc.

References g_communicator, g_pendingTx, g_txCount, ns3::Time::GetInteger(), ns3::NodeList::GetNode(), ns3::Time::GetTimeStep(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ TestSendComplete()

void ns3::GrantedTimeWindowMpiInterface::TestSendComplete ( )
staticprivate

Check for completed sends.

Definition at line 308 of file granted-time-window-mpi-interface.cc.

References g_pendingTx, and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::DistributedSimulatorImpl::Run().

+ Here is the caller graph for this function:

Member Data Documentation

◆ g_communicator

MPI_Comm ns3::GrantedTimeWindowMpiInterface::g_communicator = MPI_COMM_WORLD
staticprivate

MPI communicator being used for ns-3 tasks.

Definition at line 157 of file granted-time-window-mpi-interface.h.

Referenced by Disable(), Enable(), GetCommunicator(), ReceiveMessages(), and SendPacket().

◆ g_enabled

bool ns3::GrantedTimeWindowMpiInterface::g_enabled = false
staticprivate

Has this interface been enabled.

Definition at line 139 of file granted-time-window-mpi-interface.h.

Referenced by Disable(), Enable(), Enable(), GetCommunicator(), GetRxCount(), GetSize(), GetSystemId(), GetTxCount(), and IsEnabled().

◆ g_freeCommunicator

bool ns3::GrantedTimeWindowMpiInterface::g_freeCommunicator = false
staticprivate

Did ns-3 create the communicator? Have to free it.

Definition at line 160 of file granted-time-window-mpi-interface.h.

Referenced by Disable(), and Enable().

◆ g_mpiInitCalled

bool ns3::GrantedTimeWindowMpiInterface::g_mpiInitCalled = false
staticprivate

Has MPI Init been called by this interface.

Alternatively user supplies a communicator.

Definition at line 145 of file granted-time-window-mpi-interface.h.

Referenced by Disable(), and Enable().

◆ g_pendingTx

std::list< SentBuffer > ns3::GrantedTimeWindowMpiInterface::g_pendingTx
staticprivate

List of pending non-blocking sends.

Definition at line 154 of file granted-time-window-mpi-interface.h.

Referenced by Destroy(), SendPacket(), and TestSendComplete().

◆ g_pRxBuffers

char ** ns3::GrantedTimeWindowMpiInterface::g_pRxBuffers
staticprivate

Data buffers for non-blocking reads.

Definition at line 151 of file granted-time-window-mpi-interface.h.

Referenced by Destroy(), Enable(), and ReceiveMessages().

◆ g_requests

MPI_Request * ns3::GrantedTimeWindowMpiInterface::g_requests
staticprivate

Pending non-blocking receives.

Definition at line 148 of file granted-time-window-mpi-interface.h.

Referenced by Destroy(), Enable(), and ReceiveMessages().

◆ g_rxCount

uint32_t ns3::GrantedTimeWindowMpiInterface::g_rxCount = 0
staticprivate

Total packets received.

Definition at line 133 of file granted-time-window-mpi-interface.h.

Referenced by GetRxCount(), and ReceiveMessages().

◆ g_sid

uint32_t ns3::GrantedTimeWindowMpiInterface::g_sid = 0
staticprivate

System ID (rank) for this task.

Definition at line 128 of file granted-time-window-mpi-interface.h.

Referenced by Enable(), and GetSystemId().

◆ g_size

uint32_t ns3::GrantedTimeWindowMpiInterface::g_size = 1
staticprivate

Size of the MPI COM_WORLD group.

Definition at line 130 of file granted-time-window-mpi-interface.h.

Referenced by Enable(), and GetSize().

◆ g_txCount

uint32_t ns3::GrantedTimeWindowMpiInterface::g_txCount = 0
staticprivate

Total packets sent.

Definition at line 136 of file granted-time-window-mpi-interface.h.

Referenced by GetTxCount(), and SendPacket().


The documentation for this class was generated from the following files: