32 #include "ns3/node-list.h"
33 #include "ns3/net-device.h"
34 #include "ns3/simulator.h"
35 #include "ns3/simulator-impl.h"
36 #include "ns3/nstime.h"
95 static TypeId tid =
TypeId (
"ns3::GrantedTimeWindowMpiInterface")
107 for (uint32_t i = 0; i <
GetSize (); ++i)
170 MPI_Init (pargc, pargv);
171 MPI_Barrier (MPI_COMM_WORLD);
172 MPI_Comm_rank (MPI_COMM_WORLD, reinterpret_cast <int *> (&
m_sid));
173 MPI_Comm_size (MPI_COMM_WORLD, reinterpret_cast <int *> (&
m_size));
179 for (uint32_t i = 0; i <
GetSize (); ++i)
186 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
198 std::list<SentBuffer>::reverse_iterator i =
m_pendingTx.rbegin ();
201 uint8_t* buffer =
new uint8_t[serializedSize + 16];
202 i->SetBuffer (buffer);
205 uint64_t* pTime = reinterpret_cast <uint64_t *> (buffer);
207 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
211 p->
Serialize (reinterpret_cast<uint8_t *> (pData), serializedSize);
217 MPI_Isend (reinterpret_cast<void *> (i->GetBuffer ()), serializedSize + 16, MPI_CHAR, nodeSysId,
218 0, MPI_COMM_WORLD, (i->GetRequest ()));
221 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
244 MPI_Get_count (&status, MPI_CHAR, &count);
248 uint64_t* pTime =
reinterpret_cast<uint64_t *
> (
m_pRxBuffers[index]);
249 uint64_t time = *pTime++;
250 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
251 uint32_t node = *pData++;
252 uint32_t dev = *pData++;
256 count -=
sizeof (time) +
sizeof (node) +
sizeof (dev);
258 Ptr<Packet> p = Create<Packet> (
reinterpret_cast<uint8_t *
> (pData), count,
true);
264 for (uint32_t i = 0; i < nDevices; ++i)
267 if (pThisDev->GetIfIndex () == dev)
285 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
295 std::list<SentBuffer>::iterator i =
m_pendingTx.begin ();
300 MPI_Test (i->GetRequest (), &flag, &status);
301 std::list<SentBuffer>::iterator
current = i;
309 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
320 MPI_Initialized (&flag);
329 NS_FATAL_ERROR (
"Cannot disable MPI environment without Initializing it first");
332 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
keep track of time values and allow control of global simulation resolution
#define NS_LOG_FUNCTION(parameters)
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
static Ptr< SimulatorImpl > GetImplementation(void)
static Ptr< Node > GetNode(uint32_t n)
static uint32_t GetRxCount()
static char ** m_pRxBuffers
uint32_t Serialize(uint8_t *buffer, uint32_t maxSize) const
Serialize a packet, tags, and metadata into a byte buffer.
static TypeId GetTypeId(void)
#define NS_ASSERT(condition)
static uint32_t GetTxCount()
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
virtual void Enable(int *pargc, char ***pargv)
virtual uint32_t GetSize()
uint32_t GetSystemId(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
static void TestSendComplete()
Check for completed sends.
virtual uint32_t GetSystemId()
static std::list< SentBuffer > m_pendingTx
void SetBuffer(uint8_t *buffer)
void Receive(Ptr< Packet > p)
Direct an incoming packet to the device Receive() method.
Ptr< NetDevice > GetDevice(uint32_t index) const
Tracks non-blocking sends.
Class to aggregate to a NetDevice if it supports MPI capability.
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
uint32_t GetNDevices(void) const
int64_t GetTimeStep(void) const
int64_t GetInteger(void) const
static uint32_t m_txCount
static Time Now(void)
Return the "current simulation time".
virtual void Disable()
Terminates the MPI environment by calling MPI_Finalize This function must be called after Destroy () ...
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
static bool m_initialized
MPI_Request * GetRequest()
uint32_t GetId(void) const
static void ReceiveMessages()
Check for received messages complete.
uint32_t GetSerializedSize(void) const
const uint32_t MAX_MPI_MSG_SIZE
maximum MPI message size for easy buffer creation
static uint32_t m_rxCount
static MPI_Request * m_requests
a base class which provides memory management and object aggregation
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
static uint32_t GetSize()
virtual void Destroy()
Delete all buffers.