A Discrete-Event Network Simulator
API
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
ns3::NullMessageMpiInterface Class Reference

Interface between ns-3 and MPI for the Null Message distributed simulation implementation. More...

#include "null-message-mpi-interface.h"

+ Inheritance diagram for ns3::NullMessageMpiInterface:

Public Member Functions

 NullMessageMpiInterface ()
 
 ~NullMessageMpiInterface ()
 
virtual void Destroy ()
 Delete all buffers. More...
 
virtual void Disable ()
 Terminates the MPI environment by calling MPI_Finalize This function must be called after Destroy (). More...
 
virtual void Enable (int *pargc, char ***pargv)
 
virtual uint32_t GetSize ()
 
virtual uint32_t GetSystemId ()
 
virtual bool IsEnabled ()
 
virtual void SendPacket (Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
 
- Public Member Functions inherited from ns3::ParallelCommunicationInterface
virtual ~ParallelCommunicationInterface ()
 Destructor. More...
 

Static Public Member Functions

static void InitializeSendReceiveBuffers (void)
 Initialize send and receive buffers. More...
 
static void ReceiveMessagesBlocking ()
 Blocking message receive. More...
 
static void ReceiveMessagesNonBlocking ()
 Non-blocking check for received messages complete. More...
 
static void SendNullMessage (const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
 Send a Null Message to across the specified bundle. More...
 
static void TestSendComplete ()
 Check for completed sends. More...
 

Static Private Member Functions

static void ReceiveMessages (bool blocking=false)
 Check for received messages complete. More...
 

Static Private Attributes

static bool g_enabled = false
 
static bool g_initialized = false
 
static uint32_t g_numNeighbors = 0
 
static std::list< NullMessageSentBufferg_pendingTx
 
static char ** g_pRxBuffers
 
static MPI_Requestg_requests
 
static uint32_t g_sid = 0
 
static uint32_t g_size = 1
 

Detailed Description

Interface between ns-3 and MPI for the Null Message distributed simulation implementation.

Definition at line 88 of file null-message-mpi-interface.h.

Constructor & Destructor Documentation

◆ NullMessageMpiInterface()

ns3::NullMessageMpiInterface::NullMessageMpiInterface ( )

Definition at line 95 of file null-message-mpi-interface.cc.

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

◆ ~NullMessageMpiInterface()

ns3::NullMessageMpiInterface::~NullMessageMpiInterface ( )

Definition at line 108 of file null-message-mpi-interface.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ Destroy()

void ns3::NullMessageMpiInterface::Destroy ( void  )
virtual

Delete all buffers.

Implements ns3::ParallelCommunicationInterface.

Definition at line 114 of file null-message-mpi-interface.cc.

References NS_LOG_FUNCTION.

◆ Disable()

void ns3::NullMessageMpiInterface::Disable ( )
virtual

Terminates the MPI environment by calling MPI_Finalize This function must be called after Destroy ().

Resets m_initialized and m_enabled.

Implements ns3::ParallelCommunicationInterface.

Definition at line 418 of file null-message-mpi-interface.cc.

References g_enabled, g_initialized, g_numNeighbors, g_pendingTx, g_pRxBuffers, g_requests, NS_FATAL_ERROR, and NS_LOG_FUNCTION.

◆ Enable()

void ns3::NullMessageMpiInterface::Enable ( int *  pargc,
char ***  pargv 
)
virtual
Parameters
pargcnumber of command line arguments
pargvcommand line arguments

Sets up interface. Calls MPI Init and posts receives.

Implements ns3::ParallelCommunicationInterface.

Definition at line 145 of file null-message-mpi-interface.cc.

References g_enabled, g_initialized, g_sid, g_size, NS_LOG_FUNCTION, and NS_UNUSED.

◆ GetSize()

uint32_t ns3::NullMessageMpiInterface::GetSize ( void  )
virtual
Returns
number of systems (MPI size)

Implements ns3::ParallelCommunicationInterface.

Definition at line 127 of file null-message-mpi-interface.cc.

References g_enabled, g_size, and NS_ASSERT.

◆ GetSystemId()

uint32_t ns3::NullMessageMpiInterface::GetSystemId ( void  )
virtual
Returns
system id (MPI rank)

Implements ns3::ParallelCommunicationInterface.

Definition at line 120 of file null-message-mpi-interface.cc.

References g_enabled, g_sid, and NS_ASSERT.

◆ InitializeSendReceiveBuffers()

void ns3::NullMessageMpiInterface::InitializeSendReceiveBuffers ( void  )
static

Initialize send and receive buffers.

This method should be called after all links have been added to the RemoteChannelBundle manager to setup any required send and receive buffers.

Definition at line 173 of file null-message-mpi-interface.cc.

References ns3::RemoteChannelBundleManager::Find(), g_enabled, g_numNeighbors, g_pRxBuffers, g_requests, g_size, NS_ASSERT, NS_LOG_FUNCTION_NOARGS, and ns3::RemoteChannelBundleManager::Size().

Referenced by ns3::NullMessageSimulatorImpl::CalculateLookAhead().

◆ IsEnabled()

bool ns3::NullMessageMpiInterface::IsEnabled ( )
virtual
Returns
true if interface is enabled

Implements ns3::ParallelCommunicationInterface.

Definition at line 134 of file null-message-mpi-interface.cc.

References g_enabled, g_initialized, and ns3::Simulator::GetImplementation().

◆ ReceiveMessages()

void ns3::NullMessageMpiInterface::ReceiveMessages ( bool  blocking = false)
staticprivate

Check for received messages complete.

Will block until message has been received if blocking flag is true. When blocking will return after the first message is received. Non-blocking mode will Non-blocking check for received messages complete. Will receive all messages that are queued up locally.

Definition at line 293 of file null-message-mpi-interface.cc.

References ns3::RemoteChannelBundleManager::Find(), g_enabled, g_numNeighbors, g_pRxBuffers, g_requests, ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::Node::GetNDevices(), ns3::NodeList::GetNode(), ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, ns3::MpiReceiver::Receive(), and ns3::Simulator::ScheduleWithContext().

Referenced by ReceiveMessagesBlocking(), and ReceiveMessagesNonBlocking().

◆ ReceiveMessagesBlocking()

void ns3::NullMessageMpiInterface::ReceiveMessagesBlocking ( )
static

Blocking message receive.

Will block until at least one message has been received.

Definition at line 275 of file null-message-mpi-interface.cc.

References NS_LOG_FUNCTION_NOARGS, and ReceiveMessages().

Referenced by ns3::NullMessageSimulatorImpl::HandleArrivingMessagesBlocking().

◆ ReceiveMessagesNonBlocking()

void ns3::NullMessageMpiInterface::ReceiveMessagesNonBlocking ( )
static

Non-blocking check for received messages complete.

Will receive all messages that are queued up locally.

Definition at line 284 of file null-message-mpi-interface.cc.

References NS_LOG_FUNCTION_NOARGS, and ReceiveMessages().

Referenced by ns3::NullMessageSimulatorImpl::HandleArrivingMessagesNonBlocking().

◆ SendNullMessage()

void ns3::NullMessageMpiInterface::SendNullMessage ( const Time guaranteeUpdate,
Ptr< RemoteChannelBundle bundle 
)
static

Send a Null Message to across the specified bundle.

Parameters
guaranteeUpdateguarantee update time for the Null Message the destination bundle for the Null Message.

Guarantee update time is the lower bound time on the next possible event from this MPI task to the remote MPI task across the bundle. Remote task may execute events up to time.

Null Messages are sent when a packet has not been sent across this bundle in order to allow time advancement on the remote MPI task.

Internal:
The Null Message MPI buffer format is based on the format for sending a packet with several fields set to 0 to signal that it is a Null Message. Overloading the normal packet format simplifies receive logic.

uint64_t 0 must be zero for Null Message uint64_t guarantee time uint32_t 0 must be zero for Null Message uint32_t 0 must be zero for Null Message

Definition at line 243 of file null-message-mpi-interface.cc.

References g_enabled, g_pendingTx, ns3::Time::GetInteger(), ns3::Time::GetTimeStep(), NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::NullMessageSimulatorImpl::NullMessageEventHandler(), and ns3::RemoteChannelBundle::Send().

◆ SendPacket()

void ns3::NullMessageMpiInterface::SendPacket ( Ptr< Packet p,
const Time rxTime,
uint32_t  node,
uint32_t  dev 
)
virtual
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.

Internal:
The MPI buffer format packs a delivery information and the serialized packet.

uint64_t time the packed should be delivered uint64_t guarantee time for the Null Message algorithm. uint32_t node id of destination unit32_t dev id on destination uint8_t[] serialized packet

Implements ns3::ParallelCommunicationInterface.

Definition at line 200 of file null-message-mpi-interface.cc.

References ns3::NullMessageSimulatorImpl::CalculateGuaranteeTime(), g_enabled, g_pendingTx, ns3::NullMessageSimulatorImpl::GetInstance(), ns3::Time::GetInteger(), ns3::NodeList::GetNode(), ns3::Packet::GetSerializedSize(), ns3::Node::GetSystemId(), ns3::Time::GetTimeStep(), NS_ASSERT, NS_LOG_FUNCTION, ns3::NullMessageSimulatorImpl::RescheduleNullMessageEvent(), and ns3::Packet::Serialize().

◆ TestSendComplete()

void ns3::NullMessageMpiInterface::TestSendComplete ( )
static

Member Data Documentation

◆ g_enabled

bool ns3::NullMessageMpiInterface::g_enabled = false
staticprivate

◆ g_initialized

bool ns3::NullMessageMpiInterface::g_initialized = false
staticprivate

Definition at line 211 of file null-message-mpi-interface.h.

Referenced by Disable(), Enable(), and IsEnabled().

◆ g_numNeighbors

uint32_t ns3::NullMessageMpiInterface::g_numNeighbors = 0
staticprivate

◆ g_pendingTx

std::list< NullMessageSentBuffer > ns3::NullMessageMpiInterface::g_pendingTx
staticprivate

◆ g_pRxBuffers

char ** ns3::NullMessageMpiInterface::g_pRxBuffers
staticprivate

◆ g_requests

MPI_Request * ns3::NullMessageMpiInterface::g_requests
staticprivate

◆ g_sid

uint32_t ns3::NullMessageMpiInterface::g_sid = 0
staticprivate

Definition at line 203 of file null-message-mpi-interface.h.

Referenced by Enable(), and GetSystemId().

◆ g_size

uint32_t ns3::NullMessageMpiInterface::g_size = 1
staticprivate

Definition at line 206 of file null-message-mpi-interface.h.

Referenced by Enable(), GetSize(), and InitializeSendReceiveBuffers().


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