A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mpi-interface.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: George Riley <riley@ece.gatech.edu>
17  */
18 
19 // This object contains static methods that provide an easy interface
20 // to the necessary MPI information.
21 
22 #ifndef NS3_MPI_INTERFACE_H
23 #define NS3_MPI_INTERFACE_H
24 
25 #include <stdint.h>
26 #include <list>
27 
28 #include "ns3/nstime.h"
29 #include "ns3/buffer.h"
30 
31 #if defined(NS3_OPENMPI)
32 struct ompi_request_t;
33 typedef struct ompi_request_t* MPI_Request;
34 #elif defined(NS3_MPICH)
35 typedef int MPI_Request;
36 #else
37 typedef void* MPI_Request;
38 #endif
39 
40 namespace ns3 {
41 
51 const uint32_t MAX_MPI_MSG_SIZE = 2000;
52 
59 {
60 public:
61  SentBuffer ();
62  ~SentBuffer ();
63 
67  uint8_t* GetBuffer ();
71  void SetBuffer (uint8_t* buffer);
75  MPI_Request* GetRequest ();
76 
77 private:
78  uint8_t* m_buffer;
79  MPI_Request m_request;
80 };
81 
82 class Packet;
83 
90 {
91 public:
95  static void Destroy ();
99  static uint32_t GetSystemId ();
103  static uint32_t GetSize ();
107  static bool IsEnabled ();
114  static void Enable (int* pargc, char*** pargv);
120  static void Disable ();
129  static void SendPacket (Ptr<Packet> p, const Time &rxTime, uint32_t node, uint32_t dev);
133  static void ReceiveMessages ();
137  static void TestSendComplete ();
141  static uint32_t GetRxCount ();
145  static uint32_t GetTxCount ();
146 
147 private:
148  static uint32_t m_sid;
149  static uint32_t m_size;
150 
151  // Total packets received
152  static uint32_t m_rxCount;
153 
154  // Total packets sent
155  static uint32_t m_txCount;
156  static bool m_initialized;
157  static bool m_enabled;
158 
159  // Pending non-blocking receives
160  static MPI_Request* m_requests;
161 
162  // Data buffers for non-blocking reads
163  static char** m_pRxBuffers;
164 
165  // List of pending non-blocking sends
166  static std::list<SentBuffer> m_pendingTx;
167 };
168 
169 } // namespace ns3
170 
171 #endif /* NS3_MPI_INTERFACE_H */
keep track of time unit.
Definition: nstime.h:149
static void Disable()
network packets
Definition: packet.h:203
static uint32_t GetTxCount()
static void Destroy()
static void Enable(int *pargc, char ***pargv)
static bool IsEnabled()
void SetBuffer(uint8_t *buffer)
static uint32_t GetRxCount()
uint8_t * GetBuffer()
static void ReceiveMessages()
static void TestSendComplete()
MPI_Request * GetRequest()
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
static uint32_t GetSystemId()
const uint32_t MAX_MPI_MSG_SIZE
Definition: mpi-interface.h:51
static uint32_t GetSize()