37 #include "ns3/node-list.h"
38 #include "ns3/net-device.h"
39 #include "ns3/simulator.h"
40 #include "ns3/simulator-impl.h"
41 #include "ns3/nstime.h"
97 static TypeId tid =
TypeId (
"ns3::GrantedTimeWindowMpiInterface")
109 for (uint32_t i = 0; i <
GetSize (); ++i)
168 MPI_Init (pargc, pargv);
200 for (uint32_t i = 0; i <
GetSize (); ++i)
215 std::list<SentBuffer>::reverse_iterator i =
g_pendingTx.rbegin ();
218 uint8_t* buffer =
new uint8_t[serializedSize + 16];
219 i->SetBuffer (buffer);
222 uint64_t* pTime =
reinterpret_cast <uint64_t *
> (buffer);
224 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
228 p->
Serialize (
reinterpret_cast<uint8_t *
> (pData), serializedSize);
234 MPI_Isend (
reinterpret_cast<void *
> (i->GetBuffer ()), serializedSize + 16, MPI_CHAR, nodeSysId,
257 MPI_Get_count (&status, MPI_CHAR, &count);
261 uint64_t* pTime =
reinterpret_cast<uint64_t *
> (
g_pRxBuffers[index]);
262 uint64_t time = *pTime++;
263 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
264 uint32_t node = *pData++;
265 uint32_t dev = *pData++;
269 count -=
sizeof (time) +
sizeof (node) +
sizeof (dev);
271 Ptr<Packet> p = Create<Packet> (
reinterpret_cast<uint8_t *
> (pData), count,
true);
277 for (uint32_t i = 0; i < nDevices; ++i)
304 std::list<SentBuffer>::iterator i =
g_pendingTx.begin ();
309 MPI_Test (i->GetRequest (), &flag, &status);
310 std::list<SentBuffer>::iterator current = i;
334 MPI_Initialized (&flag);
341 NS_FATAL_ERROR (
"Cannot disable MPI environment without Initializing it first");
virtual void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
static void ReceiveMessages()
Check for received messages complete.
static uint32_t GetRxCount()
static TypeId GetTypeId(void)
Register this type.
static bool g_freeCommunicator
Did ns-3 create the communicator? Have to free it.
static void TestSendComplete()
Check for completed sends.
static bool g_mpiInitCalled
Has MPI Init been called by this interface.
static uint32_t g_size
Size of the MPI COM_WORLD group.
static bool g_enabled
Has this interface been enabled.
static uint32_t GetTxCount()
virtual void Disable()
Clean up the ns-3 parallel communications interface.
static std::list< SentBuffer > g_pendingTx
List of pending non-blocking sends.
virtual MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
virtual void Destroy()
Deletes storage used by the parallel environment.
virtual uint32_t GetSystemId()
Get the id number of this rank.
static MPI_Request * g_requests
Pending non-blocking receives.
static uint32_t g_rxCount
Total packets received.
static char ** g_pRxBuffers
Data buffers for non-blocking reads.
static uint32_t g_txCount
Total packets sent.
static MPI_Comm g_communicator
MPI communicator being used for ns-3 tasks.
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
virtual bool IsEnabled()
Returns enabled state of parallel environment.
static uint32_t g_sid
System ID (rank) for this task.
virtual uint32_t GetSize()
Get the number of ranks used by ns-3.
static uint32_t GetSize()
Get the number of ranks used by ns-3.
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.
virtual uint32_t GetIfIndex(void) const =0
uint32_t GetId(void) const
uint32_t GetNDevices(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
uint32_t GetSystemId(void) const
static Ptr< Node > GetNode(uint32_t n)
A base class which provides memory management and object aggregation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
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.
Tracks non-blocking sends.
MPI_Request m_request
The MPI request handle.
uint8_t * m_buffer
The buffer.
void SetBuffer(uint8_t *buffer)
MPI_Request * GetRequest()
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
int64_t GetInteger(void) 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.
Declaration of classes ns3::SentBuffer and ns3::GrantedTimeWindowMpiInterface.
#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.
Declaration of class ns3::MpiInterface.
ns3::MpiReciver 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 MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation