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"
94 static TypeId tid =
TypeId (
"ns3::GrantedTimeWindowMpiInterface")
106 for (uint32_t i = 0; i <
GetSize (); ++i)
169 MPI_Init (pargc, pargv);
170 MPI_Barrier (MPI_COMM_WORLD);
171 MPI_Comm_rank (MPI_COMM_WORLD, reinterpret_cast <int *> (&
m_sid));
172 MPI_Comm_size (MPI_COMM_WORLD, reinterpret_cast <int *> (&
m_size));
178 for (uint32_t i = 0; i <
GetSize (); ++i)
185 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
197 std::list<SentBuffer>::reverse_iterator i =
m_pendingTx.rbegin ();
200 uint8_t* buffer =
new uint8_t[serializedSize + 16];
201 i->SetBuffer (buffer);
204 uint64_t* pTime = reinterpret_cast <uint64_t *> (buffer);
206 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
210 p->
Serialize (reinterpret_cast<uint8_t *> (pData), serializedSize);
216 MPI_Isend (reinterpret_cast<void *> (i->GetBuffer ()), serializedSize + 16, MPI_CHAR, nodeSysId,
217 0, MPI_COMM_WORLD, (i->GetRequest ()));
220 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
243 MPI_Get_count (&status, MPI_CHAR, &count);
247 uint64_t* pTime =
reinterpret_cast<uint64_t *
> (
m_pRxBuffers[index]);
248 uint64_t time = *pTime++;
249 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
250 uint32_t node = *pData++;
251 uint32_t dev = *pData++;
255 count -=
sizeof (time) +
sizeof (node) +
sizeof (dev);
257 Ptr<Packet> p = Create<Packet> (
reinterpret_cast<uint8_t *
> (pData), count,
true);
263 for (uint32_t i = 0; i < nDevices; ++i)
266 if (pThisDev->GetIfIndex () == dev)
284 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
294 std::list<SentBuffer>::iterator i =
m_pendingTx.begin ();
299 MPI_Test (i->GetRequest (), &flag, &status);
300 std::list<SentBuffer>::iterator current = i;
308 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
319 MPI_Initialized (&flag);
328 NS_FATAL_ERROR (
"Cannot disable MPI environment without Initializing it first");
331 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static Ptr< SimulatorImpl > GetImplementation(void)
Get the SimulatorImpl singleton.
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)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static uint32_t GetTxCount()
#define NS_FATAL_ERROR(msg)
Fatal error handling.
#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
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
Retrieve the index-th NetDevice associated to this node.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetTimeStep(void) const
int64_t GetInteger(void) const
static uint32_t m_txCount
static Time Now(void)
Return the current simulation virtual 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
Returns number of bytes required for packet serialization.
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.