|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
34 #include "ns3/mpi-receiver.h"
36 #include "ns3/node-list.h"
37 #include "ns3/net-device.h"
38 #include "ns3/nstime.h"
39 #include "ns3/simulator.h"
144 static TypeId tid =
TypeId (
"ns3::NullMessageMpiInterface")
146 .SetGroupName (
"Mpi")
202 MPI_Init (pargc, pargv);
246 for (uint32_t rank = 0; rank <
g_size; ++rank)
272 std::list<NullMessageSentBuffer>::reverse_iterator iter =
g_pendingTx.rbegin ();
275 uint32_t bufferSize = serializedSize + ( 2 *
sizeof (uint64_t) ) + ( 2 *
sizeof (uint32_t) );
276 uint8_t* buffer =
new uint8_t[bufferSize];
277 iter->SetBuffer (buffer);
280 uint64_t* pTime =
reinterpret_cast <uint64_t *
> (buffer);
286 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
290 p->
Serialize (
reinterpret_cast<uint8_t *
> (pData), serializedSize);
292 MPI_Isend (
reinterpret_cast<void *
> (iter->GetBuffer ()), bufferSize, MPI_CHAR, nodeSysId,
307 std::list<NullMessageSentBuffer>::reverse_iterator iter =
g_pendingTx.rbegin ();
309 uint32_t bufferSize = 2 *
sizeof (uint64_t) + 2 *
sizeof (uint32_t);
310 uint8_t* buffer =
new uint8_t[bufferSize];
311 iter->SetBuffer (buffer);
313 uint64_t* pTime =
reinterpret_cast <uint64_t *
> (buffer);
316 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
321 uint32_t nodeSysId = bundle->GetSystemId ();
323 MPI_Isend (
reinterpret_cast<void *
> (iter->GetBuffer ()), bufferSize, MPI_CHAR, nodeSysId,
363 int messageReceived = 0;
381 MPI_Get_count (&status, MPI_CHAR, &count);
384 uint64_t* pTime =
reinterpret_cast<uint64_t *
> (
g_pRxBuffers[index]);
385 uint64_t time = *pTime++;
386 uint64_t guaranteeUpdate = *pTime++;
388 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
389 uint32_t node = *pData++;
390 uint32_t dev = *pData++;
395 if (rxTime >
Time (0))
397 count -=
sizeof (time) +
sizeof (guaranteeUpdate) +
sizeof (node) +
sizeof (dev);
399 Ptr<Packet> p = Create<Packet> (
reinterpret_cast<uint8_t *
> (pData), count,
true);
405 for (uint32_t i = 0; i < nDevices; ++i)
426 bundle->SetGuaranteeTime (
Time (guaranteeUpdate));
449 std::list<NullMessageSentBuffer>::iterator iter =
g_pendingTx.begin ();
454 MPI_Test (iter->GetRequest (), &flag, &status);
455 std::list<NullMessageSentBuffer>::iterator current = iter;
471 for (std::list<NullMessageSentBuffer>::iterator iter =
g_pendingTx.begin ();
475 MPI_Cancel (iter->GetRequest ());
476 MPI_Request_free (iter->GetRequest ());
505 MPI_Initialized (&flag);
512 NS_FATAL_ERROR (
"Cannot disable MPI environment without Initializing it first");
521 NS_FATAL_ERROR (
"Cannot disable MPI environment without Initializing it first");
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static uint32_t g_size
Size of the MPI COM_WORLD group.
Non-blocking send buffers for Null Message implementation.
Declaration of classes ns3::NullMessageSentBuffer and ns3::NullMessageMpiInterface.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Declaration of class ns3::RemoteChannelBundle.
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void ReceiveMessagesBlocking()
Blocking message receive.
uint32_t GetId(void) const
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void TestSendComplete()
Check for completed sends.
uint8_t * m_buffer
Buffer for send.
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
static char ** g_pRxBuffers
Data buffers for non-blocking receives.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
static bool g_freeCommunicator
Did we create the communicator? Have to free it.
static void ReceiveMessages(bool blocking=false)
Check for received messages complete.
virtual void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
void Receive(Ptr< Packet > p)
Direct an incoming packet to the device Receive() method.
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
Get the bundle corresponding to a remote rank.
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
static uint32_t g_sid
System ID (rank) for this task.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
static MPI_Request * g_requests
Pending non-blocking receives.
void RescheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
static NullMessageSimulatorImpl * GetInstance(void)
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static void InitializeSendReceiveBuffers(void)
Initialize send and receive buffers.
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
static uint32_t g_numNeighbors
Number of neighbor tasks, tasks that this task shares a link with.
A base class which provides memory management and object aggregation.
virtual MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
uint32_t GetSystemId(void) const
~NullMessageMpiInterface()
Time CalculateGuaranteeTime(uint32_t systemId)
Simulation virtual time values and global simulation resolution.
MPI_Request m_request
MPI request posted for the send.
static std::size_t Size(void)
Get the number of ns-3 channels in this bundle.
void SetBuffer(uint8_t *buffer)
virtual uint32_t GetSystemId()
Get the id number of this rank.
MPI_Request * GetRequest()
NullMessageMpiInterface()
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
virtual uint32_t GetSize()
Get the number of ranks used by ns-3.
const uint32_t NULL_MESSAGE_MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation
static TypeId GetTypeId(void)
Register this type.
static std::list< NullMessageSentBuffer > g_pendingTx
List of pending non-blocking sends.
uint32_t Serialize(uint8_t *buffer, uint32_t maxSize) const
Serialize a packet, tags, and metadata into a byte buffer.
uint32_t GetSerializedSize(void) const
Returns number of bytes required for packet serialization.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Declaration of class ns3::RemoteChannelBundleManager.
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
virtual bool IsEnabled()
Returns enabled state of parallel environment.
uint32_t GetNDevices(void) const
virtual void Disable()
Clean up the ns-3 parallel communications interface.
Class to aggregate to a NetDevice if it supports MPI capability.
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
static bool g_enabled
Has this interface been enabled.
virtual uint32_t GetIfIndex(void) const =0
static Ptr< Node > GetNode(uint32_t n)
Declaration of class ns3::NullMessageSimulatorImpl.
virtual void Destroy()
Deletes storage used by the parallel environment.