Remove dependency on PointToPointNetDevice from MPI code; organize MPI model/ directory
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/pointer.h"
|
||||
#include "ns3/mpi-interface.h"
|
||||
#include "point-to-point-net-device.h"
|
||||
#include "point-to-point-channel.h"
|
||||
#include "ppp-header.h"
|
||||
@@ -561,6 +562,12 @@ PointToPointNetDevice::SupportsSendFrom (void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointNetDevice::DoMpiReceive (Ptr<Packet> p)
|
||||
{
|
||||
Receive (p);
|
||||
}
|
||||
|
||||
Address
|
||||
PointToPointNetDevice::GetRemote (void) const
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "ns3/data-rate.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/mpi-net-device.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -49,7 +50,7 @@ class ErrorModel;
|
||||
* include a queue, data rate, and interframe transmission gap (the
|
||||
* propagation delay is set in the PointToPointChannel).
|
||||
*/
|
||||
class PointToPointNetDevice : public NetDevice
|
||||
class PointToPointNetDevice : public NetDevice, public MpiNetDevice
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
@@ -179,6 +180,9 @@ public:
|
||||
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
|
||||
virtual bool SupportsSendFrom (void) const;
|
||||
|
||||
protected:
|
||||
void DoMpiReceive (Ptr<Packet> p);
|
||||
|
||||
private:
|
||||
|
||||
virtual void DoDispose (void);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
def build(bld):
|
||||
module = bld.create_ns3_module('point-to-point', ['network'])
|
||||
module = bld.create_ns3_module('point-to-point', ['network', 'mpi'])
|
||||
module.source = [
|
||||
'point-to-point-net-device.cc',
|
||||
'point-to-point-channel.cc',
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
#include <list>
|
||||
|
||||
#include "mpi-interface.h"
|
||||
#include "mpi-net-device.h"
|
||||
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/point-to-point-net-device.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/simulator-impl.h"
|
||||
#include "ns3/nstime.h"
|
||||
@@ -235,13 +236,13 @@ MpiInterface::ReceiveMessages ()
|
||||
// Find the correct node/device to schedule receive event
|
||||
Ptr<Node> pNode = NodeList::GetNode (node);
|
||||
uint32_t nDevices = pNode->GetNDevices ();
|
||||
Ptr<PointToPointNetDevice> pDev = 0;
|
||||
Ptr<MpiNetDevice> pMpiDev;
|
||||
for (uint32_t i = 0; i < nDevices; ++i)
|
||||
{
|
||||
Ptr<NetDevice> pThisDev = pNode->GetDevice (i);
|
||||
if (pThisDev->GetIfIndex () == dev)
|
||||
{
|
||||
pDev = DynamicCast<PointToPointNetDevice> (pThisDev);
|
||||
pDev = DynamicCast<MpiNetDevice> (pThisDev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -250,8 +251,8 @@ MpiInterface::ReceiveMessages ()
|
||||
|
||||
// Schedule the rx event
|
||||
Simulator::ScheduleWithContext (pNode->GetId (), rxTime - Simulator::Now (),
|
||||
&PointToPointNetDevice::Receive,
|
||||
pDev, p);
|
||||
&MpiNetDevice::Receive,
|
||||
pMpiDev, p);
|
||||
|
||||
// Re-queue the next read
|
||||
MPI_Irecv (m_pRxBuffers[index], MAX_MPI_MSG_SIZE, MPI_CHAR, MPI_ANY_SOURCE, 0,
|
||||
29
src/mpi/model/mpi-net-device.cc
Normal file
29
src/mpi/model/mpi-net-device.cc
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- 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>
|
||||
*/
|
||||
|
||||
#include "mpi-net-device.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void
|
||||
MpiNetDevice::MpiReceive (Ptr<Packet> p)
|
||||
{
|
||||
DoMpiReceive (p);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
50
src/mpi/model/mpi-net-device.h
Normal file
50
src/mpi/model/mpi-net-device.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* -*- 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>
|
||||
*/
|
||||
|
||||
// Provides a mixin interface to allow MPI-compatible NetDevices to inherit
|
||||
|
||||
#ifndef NS3_MPI_NET_DEVICE_H
|
||||
#define NS3_MPI_NET_DEVICE_H
|
||||
|
||||
#include "ns3/packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* Class to mixin to a NetDevice if it supports MPI capability
|
||||
*
|
||||
* Subclass must implement DoMpiReceive to direct it to the device's
|
||||
* normal Receive() method.
|
||||
*/
|
||||
class MpiNetDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
*
|
||||
* Receive a packet
|
||||
*
|
||||
* \param p Ptr to the received packet.
|
||||
*/
|
||||
void MpiReceive (Ptr<Packet> p);
|
||||
protected:
|
||||
virtual void DoMpiReceive (Ptr<Packet> p) = 0;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* NS3_MPI_NET_DEVICE_H */
|
||||
@@ -6,17 +6,19 @@ import Options
|
||||
|
||||
def build(bld):
|
||||
env = bld.env_of_name('default')
|
||||
sim = bld.create_ns3_module('mpi', ['core'])
|
||||
sim = bld.create_ns3_module('mpi', ['core', 'network'])
|
||||
sim.source = [
|
||||
'distributed-simulator-impl.cc',
|
||||
'mpi-interface.cc',
|
||||
'model/distributed-simulator-impl.cc',
|
||||
'model/mpi-interface.cc',
|
||||
'model/mpi-net-device.cc',
|
||||
]
|
||||
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
headers.module = 'mpi'
|
||||
headers.source = [
|
||||
'distributed-simulator-impl.h',
|
||||
'mpi-interface.h',
|
||||
'model/distributed-simulator-impl.h',
|
||||
'model/mpi-interface.h',
|
||||
'model/mpi-net-device.h',
|
||||
]
|
||||
|
||||
if env['ENABLE_MPI']:
|
||||
|
||||
Reference in New Issue
Block a user