A Discrete-Event Network Simulator
API
null-message-mpi-interface.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2013. Lawrence Livermore National Security, LLC.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Steven Smith <smith84@llnl.gov>
19  *
20  */
21 
22 #ifndef NS3_NULLMESSAGE_MPI_INTERFACE_H
23 #define NS3_NULLMESSAGE_MPI_INTERFACE_H
24 
26 
27 #include <ns3/nstime.h>
28 #include <ns3/buffer.h>
29 
30 #ifdef NS3_MPI
31 #include "mpi.h"
32 #else
33 typedef void* MPI_Request;
34 #endif
35 
36 #include <list>
37 
38 namespace ns3 {
39 
40 class RemoteChannelBundle;
41 class Packet;
42 
51 {
52 public:
55 
59  uint8_t* GetBuffer ();
63  void SetBuffer (uint8_t* buffer);
68 
69 private:
70 
74  uint8_t* m_buffer;
75 
80 };
81 
89 {
90 public:
91 
94 
98  virtual void Destroy ();
102  virtual uint32_t GetSystemId ();
106  virtual uint32_t GetSize ();
110  virtual bool IsEnabled ();
118  virtual void Enable (int* pargc, char*** pargv);
124  virtual void Disable ();
142  virtual void SendPacket (Ptr<Packet> p, const Time &rxTime, uint32_t node, uint32_t dev);
167  static void SendNullMessage (const Time& guaranteeUpdate, Ptr<RemoteChannelBundle> bundle);
172  static void ReceiveMessagesNonBlocking ();
177  static void ReceiveMessagesBlocking ();
181  static void TestSendComplete ();
182 
189  static void InitializeSendReceiveBuffers (void);
190 
191 private:
192 
200  static void ReceiveMessages (bool blocking = false);
201 
202  // System ID (rank) for this task
203  static uint32_t g_sid;
204 
205  // Size of the MPI COM_WORLD group.
206  static uint32_t g_size;
207 
208  // Number of neighbor tasks, tasks that this task shares a link with.
209  static uint32_t g_numNeighbors;
210 
211  static bool g_initialized;
212  static bool g_enabled;
213 
214  // Pending non-blocking receives
216 
217  // Data buffers for non-blocking receives
218  static char** g_pRxBuffers;
219 
220  // List of pending non-blocking sends
221  static std::list<NullMessageSentBuffer> g_pendingTx;
222 };
223 
224 } // namespace ns3
225 
226 #endif /* NS3_NULL_MESSAGE_MPI_INTERFACE_H */
virtual void Destroy()
Delete all buffers.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
static void ReceiveMessagesNonBlocking()
Non-blocking check for received messages complete.
Pure virtual base class for the interface between ns-3 and the parallel communication layer being use...
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
static void TestSendComplete()
Check for completed sends.
virtual void Enable(int *pargc, char ***pargv)
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
static void ReceiveMessages(bool blocking=false)
Check for received messages complete.
virtual void Disable()
Terminates the MPI environment by calling MPI_Finalize This function must be called after Destroy ()...
void * MPI_Request
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void ReceiveMessagesBlocking()
Blocking message receive.
NullMessageSentBuffer()
maximum MPI message size for easy buffer creation
uint8_t * m_buffer
Buffer for send.
Non-blocking send buffers for Null Message implementation.
static void InitializeSendReceiveBuffers(void)
Initialize send and receive buffers.
static std::list< NullMessageSentBuffer > g_pendingTx
MPI_Request m_request
MPI request posted for the send.
Interface between ns-3 and MPI for the Null Message distributed simulation implementation.