Updates after Faker's review
authorJosh Pelkey <jpelkey@gatech.edu>
Mon Nov 09 13:32:18 2009 -0500 (3 months ago)
changeset 5522b4da067ee22b
parent 5521 b303a7d65a95
child 5542 c327a4f5fef7
Updates after Faker's review
src/common/buffer.cc
src/common/buffer.h
src/common/packet-metadata.h
src/contrib/net-anim/point-to-point-grid-helper.cc
src/devices/point-to-point/point-to-point-remote-channel.cc
src/devices/point-to-point/point-to-point-remote-channel.h
src/helper/point-to-point-helper.cc
src/node/node.cc
src/simulator/default-simulator-impl.h
src/simulator/distributed-simulator-impl.cc
src/simulator/distributed-simulator-impl.h
src/simulator/mpi-interface.cc
src/simulator/mpi-interface.h
     1.1 --- a/src/common/buffer.cc	Mon Nov 09 13:31:27 2009 -0500
     1.2 +++ b/src/common/buffer.cc	Mon Nov 09 13:32:18 2009 -0500
     1.3 @@ -658,25 +658,25 @@
     1.4    NS_LOG_FUNCTION (this);
     1.5    NS_ASSERT (CheckInternalState ());
     1.6  
     1.7 -  Buffer tmp;
     1.8 +  Buffer tmpBuffer;
     1.9    uint32_t dataEnd = m_end - m_zeroAreaEnd;
    1.10 -  tmp.AddAtStart (dataEnd);
    1.11 -  tmp.Begin ().Write (m_data->m_data+m_zeroAreaStart,dataEnd);
    1.12 -  tmp.AddAtStart (4);
    1.13 -  tmp.Begin ().WriteU32 (dataEnd);
    1.14 +  tmpBuffer.AddAtStart (dataEnd);
    1.15 +  tmpBuffer.Begin ().Write (m_data->m_data+m_zeroAreaStart,dataEnd);
    1.16 +  tmpBuffer.AddAtStart (4);
    1.17 +  tmpBuffer.Begin ().WriteU32 (dataEnd);
    1.18  
    1.19    uint32_t dataStart = m_zeroAreaStart - m_start;
    1.20 -  tmp.AddAtStart (dataStart);
    1.21 -  tmp.Begin ().Write (m_data->m_data+m_start, dataStart);
    1.22 -  tmp.AddAtStart (4);
    1.23 -  tmp.Begin ().WriteU32 (dataStart);
    1.24 +  tmpBuffer.AddAtStart (dataStart);
    1.25 +  tmpBuffer.Begin ().Write (m_data->m_data+m_start, dataStart);
    1.26 +  tmpBuffer.AddAtStart (4);
    1.27 +  tmpBuffer.Begin ().WriteU32 (dataStart);
    1.28  
    1.29 -  tmp.AddAtStart (4);
    1.30 -  tmp.Begin ().WriteU32 (m_zeroAreaEnd - m_zeroAreaStart);
    1.31 +  tmpBuffer.AddAtStart (4);
    1.32 +  tmpBuffer.Begin ().WriteU32 (m_zeroAreaEnd - m_zeroAreaStart);
    1.33  
    1.34 -  NS_ASSERT (tmp.CheckInternalState ());
    1.35 +  NS_ASSERT (tmpBuffer.CheckInternalState ());
    1.36  
    1.37 -  return tmp;
    1.38 +  return tmpBuffer;
    1.39  }
    1.40  
    1.41  int32_t 
     2.1 --- a/src/common/buffer.h	Mon Nov 09 13:31:27 2009 -0500
     2.2 +++ b/src/common/buffer.h	Mon Nov 09 13:32:18 2009 -0500
     2.3 @@ -483,6 +483,19 @@
     2.4    Buffer::Iterator End (void) const;
     2.5  
     2.6    Buffer CreateFullCopy (void) const;
     2.7 +
     2.8 +  /**
     2.9 +   * \return a copy of the buffer without actually 
    2.10 +   * copying the zero byte data.  
    2.11 +   *
    2.12 +   * An integer number of the total zero byte data 
    2.13 +   * is stored at the beginning of this buffer.  
    2.14 +   * Following this, an integer number of the start 
    2.15 +   * buffer length, followed by a copy of this data 
    2.16 +   * is stored.  Finally, an integer number of the 
    2.17 +   * end buffer length, followed by a copy of this 
    2.18 +   * data is stored.
    2.19 +   */
    2.20    Buffer CreateLimitedCopy (void) const;
    2.21  
    2.22    int32_t GetCurrentStartOffset (void) const;
     3.1 --- a/src/common/packet-metadata.h	Mon Nov 09 13:31:27 2009 -0500
     3.2 +++ b/src/common/packet-metadata.h	Mon Nov 09 13:32:18 2009 -0500
     3.3 @@ -272,6 +272,7 @@
     3.4                        struct PacketMetadata::ExtraItem *extraItem) const;
     3.5    void DoAddHeader (uint32_t uid, uint32_t size);
     3.6  
     3.7 +
     3.8    static struct PacketMetadata::Data *Create (uint32_t size);
     3.9    static void Recycle (struct PacketMetadata::Data *data);
    3.10    static struct PacketMetadata::Data *Allocate (uint32_t n);
    3.11 @@ -281,7 +282,6 @@
    3.12    static bool m_enable;
    3.13    static bool m_enableChecking;
    3.14  
    3.15 -
    3.16    // set to true when adding metadata to a packet is skipped because
    3.17    // m_enable is false; used to detect enabling of metadata in the
    3.18    // middle of a simulation, which isn't allowed.
     4.1 --- a/src/contrib/net-anim/point-to-point-grid-helper.cc	Mon Nov 09 13:31:27 2009 -0500
     4.2 +++ b/src/contrib/net-anim/point-to-point-grid-helper.cc	Mon Nov 09 13:32:18 2009 -0500
     4.3 @@ -74,56 +74,57 @@
     4.4  }
     4.5  
     4.6  PointToPointGridHelper::PointToPointGridHelper (uint32_t nRows, 
     4.7 -                                                uint32_t nCols, PointToPointHelper pointToPoint, 
     4.8 +                                                uint32_t nCols, 
     4.9 +                                                PointToPointHelper pointToPoint, 
    4.10                                                  uint16_t mpiSize)
    4.11    : m_xSize (nCols), m_ySize (nRows)
    4.12  {
    4.13  #ifdef NS3_MPI
    4.14    for (uint32_t y = 0; y < nRows; ++y)
    4.15 -  {
    4.16 -    NodeContainer rowNodes;
    4.17 -    NetDeviceContainer rowDevices;
    4.18 -    NetDeviceContainer colDevices;
    4.19 +    {
    4.20 +      NodeContainer rowNodes;
    4.21 +      NetDeviceContainer rowDevices;
    4.22 +      NetDeviceContainer colDevices;
    4.23  
    4.24 -    for (uint32_t x = 0; x < nCols; ++x)
    4.25 -    {
    4.26 -      Ptr<Node> node = CreateObject<Node> ();
    4.27 -      // keep it simple for now, and 
    4.28 -      // split this up on to two 
    4.29 -      // processors
    4.30 -      if (x > m_xSize/2)
    4.31 -      {
    4.32 -        node->SetSystemId(1);
    4.33 -      }
    4.34 -      else
    4.35 -      {
    4.36 -        node->SetSystemId(0);
    4.37 -      }
    4.38 -      rowNodes.Add (node);
    4.39 +      for (uint32_t x = 0; x < nCols; ++x)
    4.40 +        {
    4.41 +          Ptr<Node> node = CreateObject<Node> ();
    4.42 +          // keep it simple for now, and 
    4.43 +          // split this up on to two 
    4.44 +          // processors
    4.45 +          if (x > m_xSize/2)
    4.46 +            {
    4.47 +              node->SetSystemId(1);
    4.48 +            }
    4.49 +          else
    4.50 +            {
    4.51 +              node->SetSystemId(0);
    4.52 +            }
    4.53 +          rowNodes.Add (node);
    4.54  
    4.55 -      // install p2p links across the row
    4.56 -      if (x > 0)
    4.57 -      {
    4.58 -        rowDevices.Add (pointToPoint.
    4.59 -            Install (rowNodes.Get (x-1), rowNodes.Get (x)));
    4.60 -      }
    4.61 +          // install p2p links across the row
    4.62 +          if (x > 0)
    4.63 +            {
    4.64 +              rowDevices.Add (pointToPoint.
    4.65 +                  Install (rowNodes.Get (x-1), rowNodes.Get (x)));
    4.66 +            }
    4.67  
    4.68 -      // install vertical p2p links
    4.69 +          // install vertical p2p links
    4.70 +          if (y > 0)
    4.71 +            {
    4.72 +              colDevices.Add(pointToPoint.
    4.73 +                         Install ((m_nodes.at (y-1)).Get (x), rowNodes.Get (x)));
    4.74 +            }
    4.75 +        }
    4.76 +
    4.77 +      m_nodes.push_back(rowNodes);
    4.78 +      m_rowDevices.push_back (rowDevices);
    4.79 +
    4.80        if (y > 0)
    4.81 -      {
    4.82 -        colDevices.Add(pointToPoint.
    4.83 -                      Install ((m_nodes.at (y-1)).Get (x), rowNodes.Get (x)));
    4.84 -      }
    4.85 +        {
    4.86 +          m_colDevices.push_back (colDevices);
    4.87 +        }
    4.88      }
    4.89 -
    4.90 -    m_nodes.push_back(rowNodes);
    4.91 -    m_rowDevices.push_back (rowDevices);
    4.92 -
    4.93 -    if (y > 0)
    4.94 -    {
    4.95 -      m_colDevices.push_back (colDevices);
    4.96 -    }
    4.97 -  }
    4.98  #else
    4.99     NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
   4.100  #endif
     5.1 --- a/src/devices/point-to-point/point-to-point-remote-channel.cc	Mon Nov 09 13:31:27 2009 -0500
     5.2 +++ b/src/devices/point-to-point/point-to-point-remote-channel.cc	Mon Nov 09 13:32:18 2009 -0500
     5.3 @@ -52,6 +52,10 @@
     5.4  PointToPointRemoteChannel::PointToPointRemoteChannel()
     5.5  {
     5.6  }
     5.7 +
     5.8 +PointToPointRemoteChannel::~PointToPointRemoteChannel()
     5.9 +{
    5.10 +}
    5.11    
    5.12  bool
    5.13  PointToPointRemoteChannel::TransmitStart(
     6.1 --- a/src/devices/point-to-point/point-to-point-remote-channel.h	Mon Nov 09 13:31:27 2009 -0500
     6.2 +++ b/src/devices/point-to-point/point-to-point-remote-channel.h	Mon Nov 09 13:32:18 2009 -0500
     6.3 @@ -33,6 +33,7 @@
     6.4    public:
     6.5      static TypeId GetTypeId (void);
     6.6      PointToPointRemoteChannel();
     6.7 +    ~PointToPointRemoteChannel();
     6.8      virtual bool TransmitStart (Ptr<Packet> p, Ptr<PointToPointNetDevice> src, Time txTime);
     6.9      
    6.10    protected:
     7.1 --- a/src/helper/point-to-point-helper.cc	Mon Nov 09 13:31:27 2009 -0500
     7.2 +++ b/src/helper/point-to-point-helper.cc	Mon Nov 09 13:32:18 2009 -0500
     7.3 @@ -214,7 +214,7 @@
     7.4      {
     7.5        uint32_t n1System = a->GetSystemId();
     7.6        uint32_t n2System = b->GetSystemId();
     7.7 -      uint32_t rank = MPIInterface::rank;
     7.8 +      uint32_t rank = MPIInterface::Rank ();
     7.9        if (n1System != rank || n2System != rank) useNormalChannel = false;
    7.10      }
    7.11    if (useNormalChannel)
     8.1 --- a/src/node/node.cc	Mon Nov 09 13:31:27 2009 -0500
     8.2 +++ b/src/node/node.cc	Mon Nov 09 13:32:18 2009 -0500
     8.3 @@ -94,7 +94,7 @@
     8.4    return m_id;
     8.5  }
     8.6  
     8.7 -void Node::SetSystemId(uint32_t sid)
     8.8 +void Node::SetSystemId (uint32_t sid)
     8.9  {
    8.10    m_sid = sid;
    8.11  }
     9.1 --- a/src/simulator/default-simulator-impl.h	Mon Nov 09 13:31:27 2009 -0500
     9.2 +++ b/src/simulator/default-simulator-impl.h	Mon Nov 09 13:32:18 2009 -0500
     9.3 @@ -58,22 +58,23 @@
     9.4    virtual Time GetMaximumSimulationTime (void) const;
     9.5    virtual void SetScheduler (Ptr<Scheduler> scheduler);
     9.6    // System ID for this simulator instance.  Zero if not a distributed sim
     9.7 -  virtual uint32_t GetSystemId() const;
     9.8 +  virtual uint32_t GetSystemId () const;
     9.9  
    9.10  protected:
    9.11    void ProcessOneEvent (void);
    9.12    uint64_t NextTs (void) const;
    9.13 +  bool m_stop;
    9.14 +  Ptr<Scheduler> m_events;
    9.15 +  // number of events that have been inserted but not yet scheduled,
    9.16 +  // not counting the "destroy" events; this is used for validation
    9.17 +  int m_unscheduledEvents;
    9.18  
    9.19 +private:
    9.20    typedef std::list<EventId> DestroyEvents;
    9.21    DestroyEvents m_destroyEvents;
    9.22 -  bool m_stop;
    9.23 -  Ptr<Scheduler> m_events;
    9.24    uint32_t m_uid;
    9.25    uint32_t m_currentUid;
    9.26    uint64_t m_currentTs;
    9.27 -  // number of events that have been inserted but not yet scheduled,
    9.28 -  // not counting the "destroy" events; this is used for validation
    9.29 -  int m_unscheduledEvents;
    9.30  };
    9.31  
    9.32  } // namespace ns3
    10.1 --- a/src/simulator/distributed-simulator-impl.cc	Mon Nov 09 13:31:27 2009 -0500
    10.2 +++ b/src/simulator/distributed-simulator-impl.cc	Mon Nov 09 13:32:18 2009 -0500
    10.3 @@ -44,6 +44,33 @@
    10.4  
    10.5  NS_OBJECT_ENSURE_REGISTERED (DistributedSimulatorImpl);
    10.6  
    10.7 +LbtsMessage::~LbtsMessage ()
    10.8 +{
    10.9 +}
   10.10 +
   10.11 +Time
   10.12 +LbtsMessage::GetSmallestTime ()
   10.13 +{
   10.14 +  return m_smallestTime;
   10.15 +}
   10.16 +
   10.17 +uint32_t
   10.18 +LbtsMessage::GetTxCount ()
   10.19 +{
   10.20 +  return m_txCount;
   10.21 +}
   10.22 +
   10.23 +uint32_t
   10.24 +LbtsMessage::GetRxCount ()
   10.25 +{
   10.26 +  return m_rxCount;
   10.27 +}
   10.28 +uint32_t
   10.29 +LbtsMessage::GetMyId ()
   10.30 +{
   10.31 +  return m_myId;
   10.32 +}
   10.33 +
   10.34  Time DistributedSimulatorImpl::m_lookAhead = Seconds (0);
   10.35  
   10.36  TypeId
   10.37 @@ -63,7 +90,7 @@
   10.38    m_systemCount = MPIInterface::Size ();
   10.39  
   10.40    // Allocate the LBTS message buffer
   10.41 -  m_pLBTS = new LBTSMessage[m_systemCount];
   10.42 +  m_pLBTS = new LbtsMessage[m_systemCount];
   10.43    m_grantedTime = Seconds (0);
   10.44  #else
   10.45    NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
   10.46 @@ -163,25 +190,25 @@
   10.47            // And check for send completes
   10.48            MPIInterface::TestSendComplete ();
   10.49            // Finally calculate the lbts
   10.50 -          LBTSMessage lMsg (MPIInterface::rxCount, MPIInterface::txCount, m_myId, nextTime);
   10.51 +          LbtsMessage lMsg (MPIInterface::GetRxCount (), MPIInterface::GetTxCount (), m_myId, nextTime);
   10.52            m_pLBTS[m_myId] = lMsg;
   10.53 -          MPI_Allgather (&lMsg, sizeof (LBTSMessage), MPI_BYTE, m_pLBTS,
   10.54 -                        sizeof (LBTSMessage), MPI_BYTE, MPI_COMM_WORLD);
   10.55 -          Time smallestTime = m_pLBTS[0].smallestTime;
   10.56 +          MPI_Allgather (&lMsg, sizeof (LbtsMessage), MPI_BYTE, m_pLBTS,
   10.57 +                        sizeof (LbtsMessage), MPI_BYTE, MPI_COMM_WORLD);
   10.58 +          Time smallestTime = m_pLBTS[0].GetSmallestTime ();
   10.59            // The totRx and totTx counts insure there are no transient
   10.60            // messages;  If totRx != totTx, there are transients,
   10.61            // so we don't update the granted time.
   10.62 -          uint32_t totRx = m_pLBTS[0].rxCount;
   10.63 -          uint32_t totTx = m_pLBTS[0].txCount;
   10.64 +          uint32_t totRx = m_pLBTS[0].GetRxCount ();
   10.65 +          uint32_t totTx = m_pLBTS[0].GetTxCount ();
   10.66            
   10.67            for (uint32_t i = 1; i < m_systemCount; ++i)
   10.68              {
   10.69 -              if (m_pLBTS[i].smallestTime < smallestTime)
   10.70 +              if (m_pLBTS[i].GetSmallestTime () < smallestTime)
   10.71                  {
   10.72 -                  smallestTime = m_pLBTS[i].smallestTime;
   10.73 +                  smallestTime = m_pLBTS[i].GetSmallestTime ();
   10.74                  }
   10.75 -              totRx += m_pLBTS[i].rxCount;
   10.76 -              totTx += m_pLBTS[i].txCount;
   10.77 +              totRx += m_pLBTS[i].GetRxCount ();
   10.78 +              totTx += m_pLBTS[i].GetTxCount ();
   10.79                
   10.80              }
   10.81            if (totRx == totTx)
    11.1 --- a/src/simulator/distributed-simulator-impl.h	Mon Nov 09 13:31:27 2009 -0500
    11.2 +++ b/src/simulator/distributed-simulator-impl.h	Mon Nov 09 13:32:18 2009 -0500
    11.3 @@ -34,21 +34,29 @@
    11.4  namespace ns3 {
    11.5  
    11.6    // Structure used for all-reduce LBTS computation
    11.7 -class LBTSMessage
    11.8 +class LbtsMessage
    11.9  {
   11.10  public:
   11.11 -  LBTSMessage() 
   11.12 -    : txCount(0), rxCount(0), myId(0)
   11.13 +  LbtsMessage() 
   11.14 +    : m_txCount(0), m_rxCount(0), m_myId(0)
   11.15    {}
   11.16    
   11.17 -  LBTSMessage(uint32_t rxc, uint32_t txc, uint32_t id, const Time& t) 
   11.18 -    : txCount(txc), rxCount(rxc), myId(id), smallestTime(t)
   11.19 +  LbtsMessage(uint32_t rxc, uint32_t txc, uint32_t id, const Time& t) 
   11.20 +    : m_txCount(txc), m_rxCount(rxc), m_myId(id), m_smallestTime(t)
   11.21    {}
   11.22 -  
   11.23 -  uint32_t txCount;
   11.24 -  uint32_t rxCount;
   11.25 -  uint32_t myId;
   11.26 -  Time     smallestTime;
   11.27 +
   11.28 +  ~LbtsMessage ();
   11.29 +
   11.30 +  Time GetSmallestTime ();
   11.31 +  uint32_t GetTxCount ();
   11.32 +  uint32_t GetRxCount ();
   11.33 +  uint32_t GetMyId ();
   11.34 +
   11.35 +private:
   11.36 +  uint32_t m_txCount;
   11.37 +  uint32_t m_rxCount;
   11.38 +  uint32_t m_myId;
   11.39 +  Time     m_smallestTime;
   11.40  };
   11.41      
   11.42  class DistributedSimulatorImpl : public DefaultSimulatorImpl
   11.43 @@ -61,9 +69,9 @@
   11.44  
   11.45    void CalculateLookAhead (void);
   11.46    virtual void Run (void);
   11.47 -  virtual uint32_t GetSystemId() const;
   11.48 +  virtual uint32_t GetSystemId () const;
   11.49  private:
   11.50 -  LBTSMessage* m_pLBTS;       // Allocated once we know how many systems
   11.51 +  LbtsMessage* m_pLBTS;       // Allocated once we know how many systems
   11.52    uint32_t     m_myId;        // MPI Rank
   11.53    uint32_t     m_systemCount; // MPI Size
   11.54    Time         m_grantedTime; // Last LBTS 
    12.1 --- a/src/simulator/mpi-interface.cc	Mon Nov 09 13:31:27 2009 -0500
    12.2 +++ b/src/simulator/mpi-interface.cc	Mon Nov 09 13:32:18 2009 -0500
    12.3 @@ -38,13 +38,31 @@
    12.4  using namespace std;
    12.5  
    12.6  namespace ns3 {
    12.7 -  
    12.8 -uint32_t         MPIInterface::rank = 0;
    12.9 -uint32_t         MPIInterface::size = 1;
   12.10 +
   12.11 +SentBuffer::~SentBuffer ()
   12.12 +{
   12.13 +}
   12.14 +
   12.15 +Buffer &
   12.16 +SentBuffer::GetBuffer ()
   12.17 +{
   12.18 +  return m_buffer;
   12.19 +}
   12.20 +
   12.21 +#ifdef NS3_MPI
   12.22 +MPI_Request*
   12.23 +SentBuffer::GetRequest ()
   12.24 +{
   12.25 +  return &m_request;
   12.26 +}
   12.27 +#endif
   12.28 +
   12.29 +uint32_t         MPIInterface::m_rank = 0;
   12.30 +uint32_t         MPIInterface::m_size = 1;
   12.31  bool             MPIInterface::m_initialized = false;
   12.32  bool             MPIInterface::m_enabled = false;
   12.33 -uint32_t         MPIInterface::rxCount = 0;
   12.34 -uint32_t         MPIInterface::txCount = 0;
   12.35 +uint32_t         MPIInterface::m_rxCount = 0;
   12.36 +uint32_t         MPIInterface::m_txCount = 0;
   12.37  list<SentBuffer> MPIInterface::m_pendingTx;
   12.38    
   12.39  #ifdef NS3_MPI
   12.40 @@ -53,6 +71,18 @@
   12.41  #endif
   12.42  
   12.43  uint32_t 
   12.44 +MPIInterface::GetRxCount ()
   12.45 +{
   12.46 +  return m_rxCount;
   12.47 +}
   12.48 +
   12.49 +uint32_t 
   12.50 +MPIInterface::GetTxCount ()
   12.51 +{
   12.52 +  return m_txCount;
   12.53 +}
   12.54 +
   12.55 +uint32_t 
   12.56  MPIInterface::Rank ()
   12.57  {
   12.58    if (!m_initialized)
   12.59 @@ -60,7 +90,7 @@
   12.60        Simulator::GetImplementation ();
   12.61        m_initialized = true;
   12.62      }
   12.63 -  return rank;
   12.64 +  return m_rank;
   12.65  }
   12.66  
   12.67  uint32_t 
   12.68 @@ -71,7 +101,7 @@
   12.69        Simulator::GetImplementation ();
   12.70        m_initialized = true;
   12.71      }
   12.72 -  return size;
   12.73 +  return m_size;
   12.74  }
   12.75  
   12.76  bool 
   12.77 @@ -92,13 +122,13 @@
   12.78    // Initialize the MPI interface
   12.79    MPI_Init (pargc, pargv);
   12.80    MPI_Barrier (MPI_COMM_WORLD);
   12.81 -  MPI_Comm_rank (MPI_COMM_WORLD, (int*)&rank);
   12.82 -  MPI_Comm_size (MPI_COMM_WORLD, (int*)&size);
   12.83 +  MPI_Comm_rank (MPI_COMM_WORLD, (int*)&m_rank);
   12.84 +  MPI_Comm_size (MPI_COMM_WORLD, (int*)&m_size);
   12.85    m_enabled = true;
   12.86    m_initialized = true;
   12.87    // Post a non-blocking receive for all peers
   12.88 -  m_pRxBuffers = new char*[size];
   12.89 -  m_requests = new MPI_Request[size];
   12.90 +  m_pRxBuffers = new char*[m_size];
   12.91 +  m_requests = new MPI_Request[m_size];
   12.92    for (uint32_t i = 0; i < Size (); ++i)
   12.93      {
   12.94        m_pRxBuffers[i] = new char[MAX_MPI_MSG_SIZE];
   12.95 @@ -119,13 +149,13 @@
   12.96    list<SentBuffer>::reverse_iterator i = m_pendingTx.rbegin (); // Points to the last element
   12.97    
   12.98    // Serialize the packet  
   12.99 -  i->buffer = p->SerializeForMpi ();
  12.100 +  i->GetBuffer () =  (p->SerializeForMpi ());
  12.101    
  12.102    // Add the time, dest node and dest device
  12.103    uint64_t t = rxTime.GetNanoSeconds ();
  12.104    
  12.105 -  i->buffer.AddAtStart (sizeof (t) + sizeof (node) + sizeof (dev));
  12.106 -  Buffer::Iterator it = i->buffer.Begin ();
  12.107 +  i->GetBuffer ().AddAtStart (sizeof (t) + sizeof (node) + sizeof (dev));
  12.108 +  Buffer::Iterator it = i->GetBuffer ().Begin ();
  12.109    it.WriteU64 (t);
  12.110    it.WriteU32 (node);
  12.111    it.WriteU32(dev);
  12.112 @@ -134,9 +164,11 @@
  12.113    Ptr<Node> destNode = NodeList::GetNode (node);
  12.114    uint32_t nodeSysId = destNode->GetSystemId ();
  12.115    
  12.116 -  MPI_Isend ((void*)i->buffer.PeekData (), i->buffer.GetSize (), MPI_CHAR, nodeSysId, 
  12.117 -            0, MPI_COMM_WORLD, &(i->request));
  12.118 -  txCount++;
  12.119 +  MPI_Isend ((void*)i->GetBuffer ().PeekData (), i->GetBuffer ().GetSize (), MPI_CHAR, nodeSysId, 
  12.120 +            0, MPI_COMM_WORLD, (i->GetRequest ()));
  12.121 +  m_txCount++;
  12.122 +#else
  12.123 +  NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
  12.124  #endif
  12.125  }
  12.126    
  12.127 @@ -154,7 +186,7 @@
  12.128        if (!flag) break; // No more messages
  12.129        int count;
  12.130        MPI_Get_count (&status, MPI_CHAR, &count);
  12.131 -      rxCount++; // Count this receive
  12.132 +      m_rxCount++; // Count this receive
  12.133  
  12.134        // Get the meta data first
  12.135        uint64_t* pTime = (uint64_t*)m_pRxBuffers[index];
  12.136 @@ -204,6 +236,8 @@
  12.137        MPI_Irecv (m_pRxBuffers[index], MAX_MPI_MSG_SIZE, MPI_CHAR, MPI_ANY_SOURCE, 0,
  12.138                  MPI_COMM_WORLD, &m_requests[index]);
  12.139      }
  12.140 +#else
  12.141 +  NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
  12.142  #endif
  12.143  }
  12.144  
  12.145 @@ -216,7 +250,7 @@
  12.146      {
  12.147        MPI_Status status;
  12.148        int flag = 0;
  12.149 -      MPI_Test (&i->request, &flag, &status);
  12.150 +      MPI_Test (i->GetRequest (), &flag, &status);
  12.151        list<SentBuffer>::iterator current = i; // Save current for erasing
  12.152        i++;                                    // Advance to next
  12.153        if (flag)
  12.154 @@ -224,7 +258,9 @@
  12.155            m_pendingTx.erase (current);
  12.156          }
  12.157      }
  12.158 -  #endif
  12.159 +#else
  12.160 +  NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
  12.161 +#endif
  12.162  }
  12.163        
  12.164  } // namespace ns3
    13.1 --- a/src/simulator/mpi-interface.h	Mon Nov 09 13:31:27 2009 -0500
    13.2 +++ b/src/simulator/mpi-interface.h	Mon Nov 09 13:32:18 2009 -0500
    13.3 @@ -39,11 +39,17 @@
    13.4  class SentBuffer {
    13.5  public:
    13.6    SentBuffer() {}
    13.7 -  SentBuffer(Buffer b) : buffer(b) {}
    13.8 -public:    
    13.9 -  Buffer      buffer;
   13.10 +  SentBuffer(Buffer b) : m_buffer(b) {}
   13.11 +  ~SentBuffer ();
   13.12 +  Buffer & GetBuffer ();
   13.13  #ifdef NS3_MPI
   13.14 -  MPI_Request request;
   13.15 +  MPI_Request* GetRequest ();
   13.16 +#endif
   13.17 +
   13.18 +private:    
   13.19 +  Buffer m_buffer;
   13.20 +#ifdef NS3_MPI
   13.21 +  MPI_Request m_request;
   13.22  #endif
   13.23  };
   13.24  
   13.25 @@ -61,13 +67,14 @@
   13.26    static void     SendPacket(Ptr<Packet>, const Time&, uint32_t, uint32_t);
   13.27    static void     ReceiveMessages();  // Check for received messages complete
   13.28    static void     TestSendComplete(); // Check for completed sends
   13.29 +  static uint32_t GetRxCount ();
   13.30 +  static uint32_t GetTxCount ();
   13.31    
   13.32 -public:
   13.33 -  static uint32_t rank;
   13.34 -  static uint32_t size;
   13.35 -  static uint32_t rxCount;   // Total packets received
   13.36 -  static uint32_t txCount;   // Total packets sent
   13.37  private:
   13.38 +  static uint32_t m_rank;
   13.39 +  static uint32_t m_size;
   13.40 +  static uint32_t m_rxCount;   // Total packets received
   13.41 +  static uint32_t m_txCount;   // Total packets sent
   13.42    static bool     m_initialized;
   13.43    static bool     m_enabled;
   13.44  #ifdef NS3_MPI
   13.45 @@ -79,6 +86,4 @@
   13.46    
   13.47  } // namespace ns3
   13.48  
   13.49 -#endif
   13.50 -
   13.51 -
   13.52 +#endif /* NS3_MPI_INTERFACE_H */