24#include "ns3/net-device.h"
25#include "ns3/node-list.h"
27#include "ns3/nstime.h"
28#include "ns3/simulator.h"
187 MPI_Init(pargc, pargv);
258 uint32_t nodeSysId = destNode->GetSystemId();
264 uint32_t serializedSize = p->GetSerializedSize();
265 uint32_t bufferSize = serializedSize + (2 *
sizeof(uint64_t)) + (2 *
sizeof(
uint32_t));
266 auto buffer =
new uint8_t[bufferSize];
267 iter->SetBuffer(buffer);
270 auto pTime =
reinterpret_cast<uint64_t*
>(buffer);
273 Time guarantee_update =
277 auto pData =
reinterpret_cast<uint32_t*
>(pTime);
281 p->Serialize(
reinterpret_cast<uint8_t*
>(pData), serializedSize);
283 MPI_Isend(
reinterpret_cast<void*
>(iter->GetBuffer()),
289 (iter->GetRequest()));
307 auto buffer =
new uint8_t[bufferSize];
308 iter->SetBuffer(buffer);
310 auto pTime =
reinterpret_cast<uint64_t*
>(buffer);
313 auto pData =
reinterpret_cast<uint32_t*
>(pTime);
318 uint32_t nodeSysId = bundle->GetSystemId();
320 MPI_Isend(
reinterpret_cast<void*
>(iter->GetBuffer()),
326 (iter->GetRequest()));
364 int messageReceived = 0;
382 MPI_Get_count(&status, MPI_CHAR, &count);
385 auto pTime =
reinterpret_cast<uint64_t*
>(
g_pRxBuffers[index]);
386 uint64_t time = *pTime++;
387 uint64_t guaranteeUpdate = *pTime++;
389 auto pData =
reinterpret_cast<uint32_t*
>(pTime);
396 if (rxTime >
Time(0))
398 count -=
sizeof(time) +
sizeof(guaranteeUpdate) +
sizeof(node) +
sizeof(dev);
409 if (pThisDev->GetIfIndex() == dev)
429 bundle->SetGuaranteeTime(
Time(guaranteeUpdate));
460 MPI_Test(iter->GetRequest(), &flag, &status);
479 MPI_Cancel(iter->GetRequest());
480 MPI_Request_free(iter->GetRequest());
507 MPI_Initialized(&flag);
514 NS_FATAL_ERROR(
"Cannot disable MPI environment without Initializing it first");
523 NS_FATAL_ERROR(
"Cannot disable MPI environment without Initializing it first");
Class to aggregate to a NetDevice if it supports MPI capability.
void Receive(Ptr< Packet > p)
Direct an incoming packet to the device Receive() method.
static Ptr< Node > GetNode(uint32_t n)
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
void Destroy() override
Deletes storage used by the parallel environment.
static void ReceiveMessagesBlocking()
Blocking message receive.
void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev) override
Send a packet to a remote node.
bool IsEnabled() override
Returns enabled state of parallel environment.
uint32_t GetSize() override
Get the number of ranks used by ns-3.
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
static TypeId GetTypeId()
Register this type.
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
~NullMessageMpiInterface() override
NullMessageMpiInterface()
MPI_Comm GetCommunicator() override
Return the communicator used to run ns-3.
static MPI_Request * g_requests
Pending non-blocking receives.
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
static void TestSendComplete()
Check for completed sends.
static void ReceiveMessages(bool blocking=false)
Check for received messages complete.
void Enable(int *pargc, char ***pargv) override
Setup the parallel communication interface.
static bool g_enabled
Has this interface been enabled.
static char ** g_pRxBuffers
Data buffers for non-blocking receives.
static void InitializeSendReceiveBuffers()
Initialize send and receive buffers.
static uint32_t g_sid
System ID (rank) for this task.
static uint32_t g_size
Size of the MPI COM_WORLD group.
void Disable() override
Clean up the ns-3 parallel communications interface.
static std::list< NullMessageSentBuffer > g_pendingTx
List of pending non-blocking sends.
static bool g_freeCommunicator
Did we create the communicator? Have to free it.
uint32_t GetSystemId() override
Get the id number of this rank.
static uint32_t g_numNeighbors
Number of neighbor tasks, tasks that this task shares a link with.
Non-blocking send buffers for Null Message implementation.
MPI_Request m_request
MPI request posted for the send.
MPI_Request * GetRequest()
void SetBuffer(uint8_t *buffer)
uint8_t * m_buffer
Buffer for send.
static NullMessageSimulatorImpl * GetInstance()
Time CalculateGuaranteeTime(uint32_t systemId)
void RescheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
Get the bundle corresponding to a remote rank.
static std::size_t Size()
Get the number of ns-3 channels in this bundle.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
int64_t GetInteger() const
Get the raw time value, in the current resolution unit.
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
int nDevices
Number of end device nodes to create.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
ns3::MpiReceiver declaration, provides an interface to aggregate to MPI-compatible NetDevices.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const uint32_t NULL_MESSAGE_MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation
Declaration of classes ns3::NullMessageSentBuffer and ns3::NullMessageMpiInterface.
Declaration of class ns3::NullMessageSimulatorImpl.
Declaration of class ns3::RemoteChannelBundleManager.
Declaration of class ns3::RemoteChannelBundle.