/usr/include/ns3/mpi-interface.h is in libns3-dev 3.13+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: George Riley <riley@ece.gatech.edu>
*/
// This object contains static methods that provide an easy interface
// to the necessary MPI information.
#ifndef NS3_MPI_INTERFACE_H
#define NS3_MPI_INTERFACE_H
#include <stdint.h>
#include <list>
#include "ns3/nstime.h"
#include "ns3/buffer.h"
#if defined(NS3_OPENMPI)
struct ompi_request_t;
typedef struct ompi_request_t* MPI_Request;
#elif defined(NS3_MPICH)
typedef int MPI_Request;
#else
typedef void* MPI_Request;
#endif
namespace ns3 {
/**
* \defgroup mpi MPI Distributed Simulation
*
*/
/**
* maximum MPI message size for easy
* buffer creation
*/
const uint32_t MAX_MPI_MSG_SIZE = 2000;
/**
* \ingroup mpi
*
* Define a class for tracking the non-block sends
*/
class SentBuffer
{
public:
SentBuffer ();
~SentBuffer ();
/**
* \return pointer to sent buffer
*/
uint8_t* GetBuffer ();
/**
* \param buffer pointer to sent buffer
*/
void SetBuffer (uint8_t* buffer);
/**
* \return MPI request
*/
MPI_Request* GetRequest ();
private:
uint8_t* m_buffer;
MPI_Request m_request;
};
class Packet;
/**
* \ingroup mpi
*
* Interface between ns-3 and MPI
*/
class MpiInterface
{
public:
/**
* Delete all buffers
*/
static void Destroy ();
/**
* \return MPI rank
*/
static uint32_t GetSystemId ();
/**
* \return MPI size (number of systems)
*/
static uint32_t GetSize ();
/**
* \return true if using MPI
*/
static bool IsEnabled ();
/**
* \param pargc number of command line arguments
* \param pargv command line arguments
*
* Sets up MPI interface
*/
static void Enable (int* pargc, char*** pargv);
/**
* Terminates the MPI environment by calling MPI_Finalize
* This function must be called after Destroy ()
* It also resets m_initialized, m_enabled
*/
static void Disable ();
/**
* \param p packet to send
* \param rxTime received time at destination node
* \param node destination node
* \param dev destination device
*
* Serialize and send a packet to the specified node and net device
*/
static void SendPacket (Ptr<Packet> p, const Time &rxTime, uint32_t node, uint32_t dev);
/**
* Check for received messages complete
*/
static void ReceiveMessages ();
/**
* Check for completed sends
*/
static void TestSendComplete ();
/**
* \return received count in packets
*/
static uint32_t GetRxCount ();
/**
* \return transmitted count in packets
*/
static uint32_t GetTxCount ();
private:
static uint32_t m_sid;
static uint32_t m_size;
// Total packets received
static uint32_t m_rxCount;
// Total packets sent
static uint32_t m_txCount;
static bool m_initialized;
static bool m_enabled;
// Pending non-blocking receives
static MPI_Request* m_requests;
// Data buffers for non-blocking reads
static char** m_pRxBuffers;
// List of pending non-blocking sends
static std::list<SentBuffer> m_pendingTx;
};
} // namespace ns3
#endif /* NS3_MPI_INTERFACE_H */
|