View | Details | Raw Unified | Return to bug 1454
Collapse All | Expand All

(-)a/model/cooja-loader-factory.cc (-1 / +8 lines)
 Lines 3-8    Link Here 
3
#include "elf-cache.h"
3
#include "elf-cache.h"
4
#include "elf-dependencies.h"
4
#include "elf-dependencies.h"
5
#include "ns3/log.h"
5
#include "ns3/log.h"
6
#ifdef DCE_MPI
7
#include "ns3/mpi-interface.h"
8
#endif
6
#include <string.h>
9
#include <string.h>
7
#include <dlfcn.h>
10
#include <dlfcn.h>
8
#include <elf.h>
11
#include <elf.h>
 Lines 74-80    Link Here 
74
};
77
};
75
78
76
SharedModules::SharedModules ()
79
SharedModules::SharedModules ()
77
  : cache ("elf-cache", 0)
80
#ifdef DCE_MPI
81
: cache ("elf-cache", MpiInterface::GetSystemId ())
82
#else
83
: cache ("elf-cache", 0)
84
#endif
78
{}
85
{}
79
86
80
SharedModules::~SharedModules ()
87
SharedModules::~SharedModules ()
(-)a/model/copy-loader-factory.cc (+6 lines)
 Lines 2-7    Link Here 
2
#include "elf-cache.h"
2
#include "elf-cache.h"
3
#include "elf-dependencies.h"
3
#include "elf-dependencies.h"
4
#include "ns3/log.h"
4
#include "ns3/log.h"
5
#include "ns3/mpi-interface.h"
5
6
6
NS_LOG_COMPONENT_DEFINE ("CopyLoaderFactory");
7
NS_LOG_COMPONENT_DEFINE ("CopyLoaderFactory");
7
8
 Lines 175-181    Link Here 
175
uint32_t
176
uint32_t
176
CopyLoaderFactory::AllocateUid (void)
177
CopyLoaderFactory::AllocateUid (void)
177
{
178
{
179
#ifdef DCE_MPI
180
  // 2^16 processes maximum per different system id.
181
  static uint32_t uid = MpiInterface::GetSystemId () * ( 1 << 16 );
182
#else
178
  static uint32_t uid = 0;
183
  static uint32_t uid = 0;
184
#endif
179
  uid++;
185
  uid++;
180
  return uid;
186
  return uid;
181
}
187
}
(-)4c90fdff71a0 (+114 lines)
Added Link Here 
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
17
#include "ns3/core-module.h"
18
#include "ns3/network-module.h"
19
#include "ns3/internet-module.h"
20
#include "ns3/point-to-point-module.h"
21
#include "ns3/applications-module.h"
22
#include "ns3/dce-module.h"
23
#include "ns3/mpi-interface.h"
24
25
using namespace ns3;
26
27
// Run Hint :  $ mpirun -np 2 dce-mpi-udp
28
29
int 
30
main (int argc, char *argv[])
31
{
32
  // Distributed simulation setup
33
  MpiInterface::Enable (&argc, &argv);
34
  GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::DistributedSimulatorImpl"));
35
36
  uint32_t systemId = MpiInterface::GetSystemId ();
37
  uint32_t systemCount = MpiInterface::GetSize ();
38
39
40
  // Check for valid distributed parameters.
41
  // Must have 2 and only 2 Logical Processors (LPs)
42
43
  if (systemCount != 2)
44
    {
45
      std::cout << "This simulation requires 2 and only 2 logical processors." << std::endl;
46
      return 1;
47
    }
48
49
  //-------------------------------------------------
50
51
52
  CommandLine cmd;
53
  cmd.Parse (argc, argv);
54
55
  NodeContainer nodes;
56
  Ptr<Node> node1 = CreateObject<Node> (0); // <------ for MPI, it goes to run in core_1 (process 1)
57
  Ptr<Node> node2 = CreateObject<Node> (1); // <------ for MPI,                   "   _2          2
58
  nodes.Add (node1);
59
  nodes.Add (node2);
60
61
  InternetStackHelper stack;
62
  stack.Install (nodes);
63
64
  PointToPointHelper pointToPoint;
65
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
66
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms"));
67
68
  NetDeviceContainer devices;
69
  devices = pointToPoint.Install (nodes);
70
71
  Ipv4AddressHelper address;
72
  address.SetBase ("10.1.1.0", "255.255.255.252");
73
  Ipv4InterfaceContainer interfaces = address.Assign (devices);
74
75
  // setup ip routes
76
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
77
78
  DceManagerHelper dceManager;
79
  dceManager.Install (nodes);
80
81
  DceApplicationHelper dce;
82
  ApplicationContainer apps;
83
84
  dce.SetStackSize (1<<20);
85
86
  if (0==systemId)
87
    {
88
      dce.SetBinary ("udp-server");
89
      dce.ResetArguments();
90
      apps = dce.Install (node1);
91
      apps.Start (Seconds (4.0));
92
    }
93
94
  if (1==systemId)
95
    {
96
      dce.SetBinary ("udp-client");
97
      dce.ResetArguments();
98
      dce.AddArgument ("10.1.1.1");
99
      apps = dce.Install (node2);
100
      apps.Start (Seconds (4.5));
101
    }
102
103
104
  Simulator::Stop (Seconds(1050.0));
105
  Simulator::Run ();
106
  Simulator::Destroy ();
107
108
  //-------------------------------------------------
109
110
  // Exit the MPI execution environment
111
  MpiInterface::Disable ();
112
  return 0;
113
114
}
(-)4c90fdff71a0 (+15 lines)
Added Link Here 
1
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3
import ns3waf
4
import Options
5
6
def configure(conf):
7
    ns3waf.check_modules(conf, ['core', 'internet', 'point-to-point', 'mpi'], mandatory = True)
8
9
def build(bld):
10
    if bld.env['MPI']:
11
         bld.build_a_script('dce', needed = ['core', 'internet', 'dce', 'point-to-point', 'mpi'],
12
		   		            target='bin/dce-mpi-udp',
13
				            source=['dce-mpi-udp.cc'],				            
14
				            )
15
(-)a/myscripts/ping/dce-ping.cc (-20 / +46 lines)
 Lines 8-13    Link Here 
8
#include "ns3/constant-position-mobility-model.h"
8
#include "ns3/constant-position-mobility-model.h"
9
#include "misc-tools.h"
9
#include "misc-tools.h"
10
10
11
#ifdef DCE_MPI
12
#include "ns3/mpi-interface.h"
13
#endif
14
11
using namespace ns3;
15
using namespace ns3;
12
16
13
// ===========================================================================
17
// ===========================================================================
 Lines 32-37    Link Here 
32
// ===========================================================================
36
// ===========================================================================
33
int main (int argc, char *argv[])
37
int main (int argc, char *argv[])
34
{
38
{
39
  uint32_t systemId = 0;
40
  uint32_t systemCount = 1;
41
#ifdef DCE_MPI
42
  // Distributed simulation setup
43
  MpiInterface::Enable (&argc, &argv);
44
  GlobalValue::Bind ("SimulatorImplementationType",
45
      StringValue ("ns3::DistributedSimulatorImpl"));
46
  systemId = MpiInterface::GetSystemId ();
47
  systemCount = MpiInterface::GetSize ();
48
#endif
49
35
  std::string animFile = "NetAnim.xml";
50
  std::string animFile = "NetAnim.xml";
36
  bool useKernel = 0;
51
  bool useKernel = 0;
37
  CommandLine cmd;
52
  CommandLine cmd;
 Lines 39-45    Link Here 
39
  cmd.Parse (argc, argv);
54
  cmd.Parse (argc, argv);
40
55
41
  NodeContainer nodes;
56
  NodeContainer nodes;
42
  nodes.Create (2);
57
  Ptr<Node> node1 = CreateObject<Node> (0 % systemCount); // Create node1 with system id 0
58
  Ptr<Node> node2 = CreateObject<Node> (1 % systemCount); // Create node2 with system id 1
59
  nodes.Add (node1);
60
  nodes.Add (node2);
43
61
44
  PointToPointHelper pointToPoint;
62
  PointToPointHelper pointToPoint;
45
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
63
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
 Lines 81-107    Link Here 
81
99
82
  dce.SetStackSize (1<<20);
100
  dce.SetStackSize (1<<20);
83
101
84
  // Launch ping on node 0
102
  if ( systemId == node1->GetSystemId () )
85
  dce.SetBinary ("ping");
103
    {
86
  dce.ResetArguments();
104
      // Launch ping on node 0
87
  dce.ResetEnvironment();
105
      dce.SetBinary ("ping");
88
  dce.AddArgument ("-c 10");
106
      dce.ResetArguments();
89
  dce.AddArgument ("-s 1000");
107
      dce.ResetEnvironment();
90
  dce.AddArgument ("10.1.1.2");
108
      dce.AddArgument ("-c 10");
109
      dce.AddArgument ("-s 1000");
110
      dce.AddArgument ("10.1.1.2");
91
111
92
  apps = dce.Install (nodes.Get (0));
112
      apps = dce.Install (node1);
93
  apps.Start (Seconds (1.0));
113
      apps.Start (Seconds (1.0));
114
    }
115
  if ( systemId == node2->GetSystemId ())
116
    {
117
      // Launch ping on node 1
118
      dce.SetBinary ("ping");
119
      dce.ResetArguments();
120
      dce.ResetEnvironment();
121
      dce.AddArgument ("-c 10");
122
      dce.AddArgument ("-s 1000");
123
      dce.AddArgument ("10.1.1.1");
94
124
95
  // Launch ping on node 1
125
      apps = dce.Install (node2);
96
  dce.SetBinary ("ping");
126
      apps.Start (Seconds (1.5));
97
  dce.ResetArguments();
127
    }
98
  dce.ResetEnvironment();
99
  dce.AddArgument ("-c 10");
100
  dce.AddArgument ("-s 1000");
101
  dce.AddArgument ("10.1.1.1");
102
103
  apps = dce.Install (nodes.Get (1));
104
  apps.Start (Seconds (1.5));
105
128
106
  setPos (nodes.Get (0), 1, 10, 0);
129
  setPos (nodes.Get (0), 1, 10, 0);
107
  setPos (nodes.Get (1), 50,10, 0);
130
  setPos (nodes.Get (1), 50,10, 0);
 Lines 117-122    Link Here 
117
  Simulator::Destroy ();
140
  Simulator::Destroy ();
118
141
119
  anim.StopAnimation ();
142
  anim.StopAnimation ();
143
#ifdef DCE_MPI
144
  MpiInterface::Disable ();
145
#endif
120
146
121
  return 0;
147
  return 0;
122
}
148
}
(-)a/utils/clone_and_compile_ns3_dce.sh (-2 / +8 lines)
 Lines 2-7    Link Here 
2
# this script checkout NS3 and DCE sources, and build them.
2
# this script checkout NS3 and DCE sources, and build them.
3
USE_KERNEL=NO
3
USE_KERNEL=NO
4
USE_VDL=NO
4
USE_VDL=NO
5
USE_MPI=NO
5
WAF_VDL=
6
WAF_VDL=
6
args=("$@")
7
args=("$@")
7
NB=$#
8
NB=$#
 Lines 15-20    Link Here 
15
    then 
16
    then 
16
       USE_VDL=YES
17
       USE_VDL=YES
17
    fi
18
    fi
19
    if [ ${args[${i}]} = '-m' ]
20
    then 
21
       USE_MPI=YES
22
       MPI_SWITCH=--enable-mpi
23
    fi
18
done 
24
done 
19
for i in patch hg make $WGET tar
25
for i in patch hg make $WGET tar
20
do
26
do
 Lines 46-52    Link Here 
46
hg revert -a
52
hg revert -a
47
patch -p1 <../ns-3-dce/utils/packet-socket-upgrade-exp.patch
53
patch -p1 <../ns-3-dce/utils/packet-socket-upgrade-exp.patch
48
patch -p1 <../ns-3-dce/utils/remove-default-simulator-asserts.patch
54
patch -p1 <../ns-3-dce/utils/remove-default-simulator-asserts.patch
49
./waf configure --prefix=`pwd`/../build --enable-tests
55
./waf configure --prefix=`pwd`/../build --enable-tests $MPI_SWITCH
50
./waf
56
./waf
51
./waf install
57
./waf install
52
cd ..
58
cd ..
 Lines 93-99    Link Here 
93
then
99
then
94
    WAF_KERNEL=--enable-kernel-stack=`pwd`/../ns-3-linux
100
    WAF_KERNEL=--enable-kernel-stack=`pwd`/../ns-3-linux
95
fi
101
fi
96
./waf configure --prefix=`pwd`/../build --verbose $WAF_KERNEL $WAF_VDL
102
./waf configure --prefix=`pwd`/../build --verbose $WAF_KERNEL $WAF_VDL $MPI_SWITCH
97
./waf
103
./waf
98
./waf install
104
./waf install
99
export LD_LIBRARY_PATH=$SAVE_LDLP:`pwd`/build/lib:`pwd`/build/bin:`pwd`/../build/lib
105
export LD_LIBRARY_PATH=$SAVE_LDLP:`pwd`/build/lib:`pwd`/build/bin:`pwd`/../build/lib
(-)a/wscript (-1 / +10 lines)
 Lines 18-24    Link Here 
18
                   help=('Enable the build of dce-runner.'),
18
                   help=('Enable the build of dce-runner.'),
19
                   dest='enable_vdl_loader', action='store_true',
19
                   dest='enable_vdl_loader', action='store_true',
20
                   default=False)               
20
                   default=False)               
21
	
21
    opt.add_option('--enable-mpi',
22
                   help=('Enable MPI and distributed simulation support'),
23
                   dest='enable_mpi', action='store_true',
24
                   default=False)
25
                   
22
def search_file(files):
26
def search_file(files):
23
    for f in files:
27
    for f in files:
24
        if os.path.isfile (f):
28
        if os.path.isfile (f):
 Lines 30-35    Link Here 
30
    ns3waf.check_modules(conf, ['point-to-point', 'tap-bridge', 'netanim'], mandatory = False)
34
    ns3waf.check_modules(conf, ['point-to-point', 'tap-bridge', 'netanim'], mandatory = False)
31
    ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)
35
    ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)
32
    ns3waf.check_modules(conf, ['point-to-point-layout'], mandatory = False)
36
    ns3waf.check_modules(conf, ['point-to-point-layout'], mandatory = False)
37
    ns3waf.check_modules(conf, ['mpi'], mandatory = False)
33
    conf.check_tool('compiler_cc')
38
    conf.check_tool('compiler_cc')
34
    conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H', mandatory=False)
39
    conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H', mandatory=False)
35
    conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H', mandatory=False)
40
    conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H', mandatory=False)
 Lines 38-43    Link Here 
38
    conf.check(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H', mandatory=False)
43
    conf.check(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H', mandatory=False)
39
    conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H', mandatory=False)
44
    conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H', mandatory=False)
40
45
46
    if Options.options.enable_mpi:
47
         conf.env.append_value ('DEFINES', 'DCE_MPI=1')
48
         conf.env['MPI'] = '1'
49
         
41
    conf.env.prepend_value('LINKFLAGS', '-Wl,--no-as-needed')
50
    conf.env.prepend_value('LINKFLAGS', '-Wl,--no-as-needed')
42
    conf.env.append_value('LINKFLAGS', '-pthread')
51
    conf.env.append_value('LINKFLAGS', '-pthread')
43
    conf.check (lib='dl', mandatory = True)
52
    conf.check (lib='dl', mandatory = True)

Return to bug 1454