author | Tom Henderson <tomh@tomh.org> |
Mon, 28 Sep 2015 20:27:25 -0700 | |
changeset 11676 | 05ea1489e509 |
parent 11530 | 65ddfcaae79a |
permissions | -rw-r--r-- |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
2 |
/* |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
6 |
* |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
11 |
* |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
15 |
* |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
16 |
* Author: George Riley <riley@ece.gatech.edu> |
10476 | 17 |
* |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
18 |
*/ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
19 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
20 |
#include "distributed-simulator-impl.h" |
10476 | 21 |
#include "granted-time-window-mpi-interface.h" |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
22 |
#include "mpi-interface.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
23 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
24 |
#include "ns3/simulator.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
25 |
#include "ns3/scheduler.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
26 |
#include "ns3/event-impl.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
27 |
#include "ns3/channel.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
28 |
#include "ns3/node-container.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
29 |
#include "ns3/ptr.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
30 |
#include "ns3/pointer.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
31 |
#include "ns3/assert.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
32 |
#include "ns3/log.h" |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
33 |
|
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7803
diff
changeset
|
34 |
#include <cmath> |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
35 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
36 |
#ifdef NS3_MPI |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
37 |
#include <mpi.h> |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
38 |
#endif |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
39 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10845
diff
changeset
|
40 |
namespace ns3 { |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
41 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10845
diff
changeset
|
42 |
NS_LOG_COMPONENT_DEFINE ("DistributedSimulatorImpl"); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
43 |
|
10652
dc18deba4502
[doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10476
diff
changeset
|
44 |
NS_OBJECT_ENSURE_REGISTERED (DistributedSimulatorImpl); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
45 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
46 |
LbtsMessage::~LbtsMessage () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
47 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
48 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
49 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
50 |
Time |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
51 |
LbtsMessage::GetSmallestTime () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
52 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
53 |
return m_smallestTime; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
54 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
55 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
56 |
uint32_t |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
57 |
LbtsMessage::GetTxCount () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
58 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
59 |
return m_txCount; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
60 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
61 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
62 |
uint32_t |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
63 |
LbtsMessage::GetRxCount () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
64 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
65 |
return m_rxCount; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
66 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
67 |
uint32_t |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
68 |
LbtsMessage::GetMyId () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
69 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
70 |
return m_myId; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
71 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
72 |
|
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
73 |
bool |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
74 |
LbtsMessage::IsFinished () |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
75 |
{ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
76 |
return m_isFinished; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
77 |
} |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
78 |
|
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
79 |
Time DistributedSimulatorImpl::m_lookAhead = Seconds (-1); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
80 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
81 |
TypeId |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
82 |
DistributedSimulatorImpl::GetTypeId (void) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
83 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
84 |
static TypeId tid = TypeId ("ns3::DistributedSimulatorImpl") |
11432
d2656819dd54
Fix parents, group names, and missing constructors in GetTypeId definitions.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11375
diff
changeset
|
85 |
.SetParent<SimulatorImpl> () |
11375
6a0a66c48bc6
SetGroupName for mpi module
Tom Henderson <tomh@tomh.org>
parents:
11091
diff
changeset
|
86 |
.SetGroupName ("Mpi") |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
87 |
.AddConstructor<DistributedSimulatorImpl> () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
88 |
; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
89 |
return tid; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
90 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
91 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
92 |
DistributedSimulatorImpl::DistributedSimulatorImpl () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
93 |
{ |
10476 | 94 |
NS_LOG_FUNCTION (this); |
95 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
96 |
#ifdef NS3_MPI |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
97 |
m_myId = MpiInterface::GetSystemId (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
98 |
m_systemCount = MpiInterface::GetSize (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
99 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
100 |
// Allocate the LBTS message buffer |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
101 |
m_pLBTS = new LbtsMessage[m_systemCount]; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
102 |
m_grantedTime = Seconds (0); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
103 |
#else |
10218
97da49da2d6c
Fix compilation with Clang 3.2 and newer versions, including Apple Clang 5.0
Vedran Miletić <rivanvx@gmail.com>
parents:
10199
diff
changeset
|
104 |
NS_UNUSED (m_systemCount); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
105 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
106 |
#endif |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
107 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
108 |
m_stop = false; |
10476 | 109 |
m_globalFinished = false; |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
110 |
// uids are allocated from 4. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
111 |
// uid 0 is "invalid" events |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
112 |
// uid 1 is "now" events |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
113 |
// uid 2 is "destroy" events |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
114 |
m_uid = 4; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
115 |
// before ::Run is entered, the m_currentUid will be zero |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
116 |
m_currentUid = 0; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
117 |
m_currentTs = 0; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
118 |
m_currentContext = 0xffffffff; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
119 |
m_unscheduledEvents = 0; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
120 |
m_events = 0; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
121 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
122 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
123 |
DistributedSimulatorImpl::~DistributedSimulatorImpl () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
124 |
{ |
10476 | 125 |
NS_LOG_FUNCTION (this); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
126 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
127 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
128 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
129 |
DistributedSimulatorImpl::DoDispose (void) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
130 |
{ |
10476 | 131 |
NS_LOG_FUNCTION (this); |
132 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
133 |
while (!m_events->IsEmpty ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
134 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
135 |
Scheduler::Event next = m_events->RemoveNext (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
136 |
next.impl->Unref (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
137 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
138 |
m_events = 0; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
139 |
delete [] m_pLBTS; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
140 |
SimulatorImpl::DoDispose (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
141 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
142 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
143 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
144 |
DistributedSimulatorImpl::Destroy () |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
145 |
{ |
10476 | 146 |
NS_LOG_FUNCTION (this); |
147 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
148 |
while (!m_destroyEvents.empty ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
149 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
150 |
Ptr<EventImpl> ev = m_destroyEvents.front ().PeekEventImpl (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
151 |
m_destroyEvents.pop_front (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
152 |
NS_LOG_LOGIC ("handle destroy " << ev); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
153 |
if (!ev->IsCancelled ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
154 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
155 |
ev->Invoke (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
156 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
157 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
158 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
159 |
MpiInterface::Destroy (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
160 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
161 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
162 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
163 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
164 |
DistributedSimulatorImpl::CalculateLookAhead (void) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
165 |
{ |
10476 | 166 |
NS_LOG_FUNCTION (this); |
167 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
168 |
#ifdef NS3_MPI |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
169 |
if (MpiInterface::GetSize () <= 1) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
170 |
{ |
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
171 |
m_lookAhead = Seconds (0); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
172 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
173 |
else |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
174 |
{ |
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
175 |
if (m_lookAhead == Seconds (-1)) |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
176 |
{ |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
177 |
m_lookAhead = GetMaximumSimulationTime (); |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
178 |
} |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
179 |
// else it was already set by SetLookAhead |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
180 |
|
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
181 |
NodeContainer c = NodeContainer::GetGlobal (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
182 |
for (NodeContainer::Iterator iter = c.Begin (); iter != c.End (); ++iter) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
183 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
184 |
if ((*iter)->GetSystemId () != MpiInterface::GetSystemId ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
185 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
186 |
continue; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
187 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
188 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
189 |
for (uint32_t i = 0; i < (*iter)->GetNDevices (); ++i) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
190 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
191 |
Ptr<NetDevice> localNetDevice = (*iter)->GetDevice (i); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
192 |
// only works for p2p links currently |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
193 |
if (!localNetDevice->IsPointToPoint ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
194 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
195 |
continue; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
196 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
197 |
Ptr<Channel> channel = localNetDevice->GetChannel (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
198 |
if (channel == 0) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
199 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
200 |
continue; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
201 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
202 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
203 |
// grab the adjacent node |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
204 |
Ptr<Node> remoteNode; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
205 |
if (channel->GetDevice (0) == localNetDevice) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
206 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
207 |
remoteNode = (channel->GetDevice (1))->GetNode (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
208 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
209 |
else |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
210 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
211 |
remoteNode = (channel->GetDevice (0))->GetNode (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
212 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
213 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
214 |
// if it's not remote, don't consider it |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
215 |
if (remoteNode->GetSystemId () == MpiInterface::GetSystemId ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
216 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
217 |
continue; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
218 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
219 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
220 |
// compare delay on the channel with current value of |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
221 |
// m_lookAhead. if delay on channel is smaller, make |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
222 |
// it the new lookAhead. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
223 |
TimeValue delay; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
224 |
channel->GetAttribute ("Delay", delay); |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
225 |
|
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
226 |
if (delay.Get () < m_lookAhead) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
227 |
{ |
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
228 |
m_lookAhead = delay.Get (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
229 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
230 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
231 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
232 |
} |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
233 |
|
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
234 |
// m_lookAhead is now set |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
235 |
m_grantedTime = m_lookAhead; |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
236 |
|
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
237 |
/* |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
238 |
* Compute the maximum inter-task latency and use that value |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
239 |
* for tasks with no inter-task links. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
240 |
* |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
241 |
* Special processing for edge cases. For tasks that have no |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
242 |
* nodes need to determine a reasonable lookAhead value. Infinity |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
243 |
* would work correctly but introduces a performance issue; tasks |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
244 |
* with an infinite lookAhead would execute all their events |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
245 |
* before doing an AllGather resulting in very bad load balance |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
246 |
* during the first time window. Since all tasks participate in |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
247 |
* the AllGather it is desirable to have all the tasks advance in |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
248 |
* simulation time at a similar rate assuming roughly equal events |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
249 |
* per unit of simulation time in order to equalize the amount of |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
250 |
* work per time window. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
251 |
*/ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
252 |
long sendbuf; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
253 |
long recvbuf; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
254 |
|
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
255 |
/* Tasks with no inter-task links do not contribute to max */ |
10476 | 256 |
if (m_lookAhead == GetMaximumSimulationTime ()) |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
257 |
{ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
258 |
sendbuf = 0; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
259 |
} |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
260 |
else |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
261 |
{ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
262 |
sendbuf = m_lookAhead.GetInteger (); |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
263 |
} |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
264 |
|
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
265 |
MPI_Allreduce (&sendbuf, &recvbuf, 1, MPI_LONG, MPI_MAX, MPI_COMM_WORLD); |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
266 |
|
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
267 |
/* For nodes that did not compute a lookahead use max from ranks |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
268 |
* that did compute a value. An edge case occurs if all nodes have |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
269 |
* no inter-task links (max will be 0 in this case). Use infinity so all tasks |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
270 |
* will proceed without synchronization until a single AllGather |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
271 |
* occurs when all tasks have finished. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
272 |
*/ |
10476 | 273 |
if (m_lookAhead == GetMaximumSimulationTime () && recvbuf != 0) |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
274 |
{ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
275 |
m_lookAhead = Time (recvbuf); |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
276 |
m_grantedTime = m_lookAhead; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
277 |
} |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
278 |
|
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
279 |
#else |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
280 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
281 |
#endif |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
282 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
283 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
284 |
void |
10845
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
285 |
DistributedSimulatorImpl::SetMaximumLookAhead (const Time lookAhead) |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
286 |
{ |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
287 |
if (lookAhead > 0) |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
288 |
{ |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
289 |
NS_LOG_FUNCTION (this << lookAhead); |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
290 |
m_lookAhead = lookAhead; |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
291 |
} |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
292 |
else |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
293 |
{ |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
294 |
NS_LOG_WARN ("attempted to set look ahead negative: " << lookAhead); |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
295 |
} |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
296 |
} |
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
297 |
|
3fb3f627a6fa
Enable explicit setting of the maximum look ahead in distributed simulation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10652
diff
changeset
|
298 |
void |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
299 |
DistributedSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
300 |
{ |
10476 | 301 |
NS_LOG_FUNCTION (this << schedulerFactory); |
302 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
303 |
Ptr<Scheduler> scheduler = schedulerFactory.Create<Scheduler> (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
304 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
305 |
if (m_events != 0) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
306 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
307 |
while (!m_events->IsEmpty ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
308 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
309 |
Scheduler::Event next = m_events->RemoveNext (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
310 |
scheduler->Insert (next); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
311 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
312 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
313 |
m_events = scheduler; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
314 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
315 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
316 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
317 |
DistributedSimulatorImpl::ProcessOneEvent (void) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
318 |
{ |
10476 | 319 |
NS_LOG_FUNCTION (this); |
320 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
321 |
Scheduler::Event next = m_events->RemoveNext (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
322 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
323 |
NS_ASSERT (next.key.m_ts >= m_currentTs); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
324 |
m_unscheduledEvents--; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
325 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
326 |
NS_LOG_LOGIC ("handle " << next.key.m_ts); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
327 |
m_currentTs = next.key.m_ts; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
328 |
m_currentContext = next.key.m_context; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
329 |
m_currentUid = next.key.m_uid; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
330 |
next.impl->Invoke (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
331 |
next.impl->Unref (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
332 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
333 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
334 |
bool |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
335 |
DistributedSimulatorImpl::IsFinished (void) const |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
336 |
{ |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
337 |
return m_globalFinished; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
338 |
} |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
339 |
|
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
340 |
bool |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
341 |
DistributedSimulatorImpl::IsLocalFinished (void) const |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
342 |
{ |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
343 |
return m_events->IsEmpty () || m_stop; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
344 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
345 |
|
7803
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
346 |
uint64_t |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
347 |
DistributedSimulatorImpl::NextTs (void) const |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
348 |
{ |
10476 | 349 |
// If local MPI task is has no more events or stop was called |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
350 |
// next event time is infinity. |
10476 | 351 |
if (IsLocalFinished ()) |
352 |
{ |
|
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
353 |
return GetMaximumSimulationTime ().GetTimeStep (); |
10476 | 354 |
} |
355 |
else |
|
356 |
{ |
|
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
357 |
Scheduler::Event ev = m_events->PeekNext (); |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
358 |
return ev.key.m_ts; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
359 |
} |
7803
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
360 |
} |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
361 |
|
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
362 |
Time |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
363 |
DistributedSimulatorImpl::Next (void) const |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
364 |
{ |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
365 |
return TimeStep (NextTs ()); |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
366 |
} |
941d5f5910a5
bring back Next since it is used internally
Mathieu Lacage <mathieu.lacage@cutebugs.net>
parents:
7796
diff
changeset
|
367 |
|
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
368 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
369 |
DistributedSimulatorImpl::Run (void) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
370 |
{ |
10476 | 371 |
NS_LOG_FUNCTION (this); |
372 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
373 |
#ifdef NS3_MPI |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
374 |
CalculateLookAhead (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
375 |
m_stop = false; |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
376 |
while (!m_globalFinished) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
377 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
378 |
Time nextTime = Next (); |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
379 |
|
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
380 |
// If local event is beyond grantedTime then need to synchronize |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
381 |
// with other tasks to determine new time window. If local task |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
382 |
// is finished then continue to participate in allgather |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
383 |
// synchronizations with other tasks until all tasks have |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
384 |
// completed. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
385 |
if (nextTime > m_grantedTime || IsLocalFinished () ) |
10476 | 386 |
{ |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
387 |
// Can't process next event, calculate a new LBTS |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
388 |
// First receive any pending messages |
10476 | 389 |
GrantedTimeWindowMpiInterface::ReceiveMessages (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
390 |
// reset next time |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
391 |
nextTime = Next (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
392 |
// And check for send completes |
10476 | 393 |
GrantedTimeWindowMpiInterface::TestSendComplete (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
394 |
// Finally calculate the lbts |
10476 | 395 |
LbtsMessage lMsg (GrantedTimeWindowMpiInterface::GetRxCount (), GrantedTimeWindowMpiInterface::GetTxCount (), |
396 |
m_myId, IsLocalFinished (), nextTime); |
|
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
397 |
m_pLBTS[m_myId] = lMsg; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
398 |
MPI_Allgather (&lMsg, sizeof (LbtsMessage), MPI_BYTE, m_pLBTS, |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
399 |
sizeof (LbtsMessage), MPI_BYTE, MPI_COMM_WORLD); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
400 |
Time smallestTime = m_pLBTS[0].GetSmallestTime (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
401 |
// The totRx and totTx counts insure there are no transient |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
402 |
// messages; If totRx != totTx, there are transients, |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
403 |
// so we don't update the granted time. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
404 |
uint32_t totRx = m_pLBTS[0].GetRxCount (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
405 |
uint32_t totTx = m_pLBTS[0].GetTxCount (); |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
406 |
m_globalFinished = m_pLBTS[0].IsFinished (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
407 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
408 |
for (uint32_t i = 1; i < m_systemCount; ++i) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
409 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
410 |
if (m_pLBTS[i].GetSmallestTime () < smallestTime) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
411 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
412 |
smallestTime = m_pLBTS[i].GetSmallestTime (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
413 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
414 |
totRx += m_pLBTS[i].GetRxCount (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
415 |
totTx += m_pLBTS[i].GetTxCount (); |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
416 |
m_globalFinished &= m_pLBTS[i].IsFinished (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
417 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
418 |
if (totRx == totTx) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
419 |
{ |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
420 |
// If lookahead is infinite then granted time should be as well. |
10476 | 421 |
// Covers the edge case if all the tasks have no inter tasks |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
422 |
// links, prevents overflow of granted time. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
423 |
if (m_lookAhead == GetMaximumSimulationTime ()) |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
424 |
{ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
425 |
m_grantedTime = GetMaximumSimulationTime (); |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
426 |
} |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
427 |
else |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
428 |
{ |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
429 |
// Overflow is possible here if near end of representable time. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
430 |
m_grantedTime = smallestTime + m_lookAhead; |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
431 |
} |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
432 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
433 |
} |
10153
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
434 |
|
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
435 |
// Execute next event if it is within the current time window. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
436 |
// Local task may be completed. |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
437 |
if ( (nextTime <= m_grantedTime) && (!IsLocalFinished ()) ) |
4952c9e4573a
Bug 1753 Halting Issue with DistributedSimulatorImpl
Steven Smith <smith84@llnl.gov>
parents:
9894
diff
changeset
|
438 |
{ // Safe to process |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
439 |
ProcessOneEvent (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
440 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
441 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
442 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
443 |
// If the simulator stopped naturally by lack of events, make a |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
444 |
// consistency test to check that we didn't lose any events along the way. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
445 |
NS_ASSERT (!m_events->IsEmpty () || m_unscheduledEvents == 0); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
446 |
#else |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
447 |
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
448 |
#endif |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
449 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
450 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
451 |
uint32_t DistributedSimulatorImpl::GetSystemId () const |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
452 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
453 |
return m_myId; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
454 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
455 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
456 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
457 |
DistributedSimulatorImpl::Stop (void) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
458 |
{ |
10476 | 459 |
NS_LOG_FUNCTION (this); |
460 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
461 |
m_stop = true; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
462 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
463 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
464 |
void |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
465 |
DistributedSimulatorImpl::Stop (Time const &delay) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
466 |
{ |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
467 |
NS_LOG_FUNCTION (this << delay.GetTimeStep ()); |
10476 | 468 |
|
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
469 |
Simulator::Schedule (delay, &Simulator::Stop); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
470 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
471 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
472 |
// |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
473 |
// Schedule an event for a _relative_ time in the future. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
474 |
// |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
475 |
EventId |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
476 |
DistributedSimulatorImpl::Schedule (Time const &delay, EventImpl *event) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
477 |
{ |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
478 |
NS_LOG_FUNCTION (this << delay.GetTimeStep () << event); |
10476 | 479 |
|
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
480 |
Time tAbsolute = delay + TimeStep (m_currentTs); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
481 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
482 |
NS_ASSERT (tAbsolute.IsPositive ()); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
483 |
NS_ASSERT (tAbsolute >= TimeStep (m_currentTs)); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
484 |
Scheduler::Event ev; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
485 |
ev.impl = event; |
6291
8b3cd8b4d560
change casts to c++ style
Josh Pelkey <jpelkey@gatech.edu>
parents:
6113
diff
changeset
|
486 |
ev.key.m_ts = static_cast<uint64_t> (tAbsolute.GetTimeStep ()); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
487 |
ev.key.m_context = GetContext (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
488 |
ev.key.m_uid = m_uid; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
489 |
m_uid++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
490 |
m_unscheduledEvents++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
491 |
m_events->Insert (ev); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
492 |
return EventId (event, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
493 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
494 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
495 |
void |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
496 |
DistributedSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
497 |
{ |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
498 |
NS_LOG_FUNCTION (this << context << delay.GetTimeStep () << m_currentTs << event); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
499 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
500 |
Scheduler::Event ev; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
501 |
ev.impl = event; |
11530
65ddfcaae79a
Clarify that Time arguments to Schedule are all delays wrt Now.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
11432
diff
changeset
|
502 |
ev.key.m_ts = m_currentTs + delay.GetTimeStep (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
503 |
ev.key.m_context = context; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
504 |
ev.key.m_uid = m_uid; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
505 |
m_uid++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
506 |
m_unscheduledEvents++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
507 |
m_events->Insert (ev); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
508 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
509 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
510 |
EventId |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
511 |
DistributedSimulatorImpl::ScheduleNow (EventImpl *event) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
512 |
{ |
10476 | 513 |
NS_LOG_FUNCTION (this << event); |
514 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
515 |
Scheduler::Event ev; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
516 |
ev.impl = event; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
517 |
ev.key.m_ts = m_currentTs; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
518 |
ev.key.m_context = GetContext (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
519 |
ev.key.m_uid = m_uid; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
520 |
m_uid++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
521 |
m_unscheduledEvents++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
522 |
m_events->Insert (ev); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
523 |
return EventId (event, ev.key.m_ts, ev.key.m_context, ev.key.m_uid); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
524 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
525 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
526 |
EventId |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
527 |
DistributedSimulatorImpl::ScheduleDestroy (EventImpl *event) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
528 |
{ |
10476 | 529 |
NS_LOG_FUNCTION (this << event); |
530 |
||
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
531 |
EventId id (Ptr<EventImpl> (event, false), m_currentTs, 0xffffffff, 2); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
532 |
m_destroyEvents.push_back (id); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
533 |
m_uid++; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
534 |
return id; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
535 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
536 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
537 |
Time |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
538 |
DistributedSimulatorImpl::Now (void) const |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
539 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
540 |
return TimeStep (m_currentTs); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
541 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
542 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
543 |
Time |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
544 |
DistributedSimulatorImpl::GetDelayLeft (const EventId &id) const |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
545 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
546 |
if (IsExpired (id)) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
547 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
548 |
return TimeStep (0); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
549 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
550 |
else |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
551 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
552 |
return TimeStep (id.GetTs () - m_currentTs); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
553 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
554 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
555 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
556 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
557 |
DistributedSimulatorImpl::Remove (const EventId &id) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
558 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
559 |
if (id.GetUid () == 2) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
560 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
561 |
// destroy events. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
562 |
for (DestroyEvents::iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
563 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
564 |
if (*i == id) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
565 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
566 |
m_destroyEvents.erase (i); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
567 |
break; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
568 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
569 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
570 |
return; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
571 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
572 |
if (IsExpired (id)) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
573 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
574 |
return; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
575 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
576 |
Scheduler::Event event; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
577 |
event.impl = id.PeekEventImpl (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
578 |
event.key.m_ts = id.GetTs (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
579 |
event.key.m_context = id.GetContext (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
580 |
event.key.m_uid = id.GetUid (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
581 |
m_events->Remove (event); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
582 |
event.impl->Cancel (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
583 |
// whenever we remove an event from the event list, we have to unref it. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
584 |
event.impl->Unref (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
585 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
586 |
m_unscheduledEvents--; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
587 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
588 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
589 |
void |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
590 |
DistributedSimulatorImpl::Cancel (const EventId &id) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
591 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
592 |
if (!IsExpired (id)) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
593 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
594 |
id.PeekEventImpl ()->Cancel (); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
595 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
596 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
597 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
598 |
bool |
11091
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
599 |
DistributedSimulatorImpl::IsExpired (const EventId &id) const |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
600 |
{ |
11091
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
601 |
if (id.GetUid () == 2) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
602 |
{ |
11091
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
603 |
if (id.PeekEventImpl () == 0 |
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
604 |
|| id.PeekEventImpl ()->IsCancelled ()) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
605 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
606 |
return true; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
607 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
608 |
// destroy events. |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
609 |
for (DestroyEvents::const_iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
610 |
{ |
11091
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
611 |
if (*i == id) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
612 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
613 |
return false; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
614 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
615 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
616 |
return true; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
617 |
} |
11091
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
618 |
if (id.PeekEventImpl () == 0 |
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
619 |
|| id.GetTs () < m_currentTs |
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
620 |
|| (id.GetTs () == m_currentTs |
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
621 |
&& id.GetUid () <= m_currentUid) |
4bbd7b9a2889
Standardize EventId arguments as id.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
622 |
|| id.PeekEventImpl ()->IsCancelled ()) |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
623 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
624 |
return true; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
625 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
626 |
else |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
627 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
628 |
return false; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
629 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
630 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
631 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
632 |
Time |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
633 |
DistributedSimulatorImpl::GetMaximumSimulationTime (void) const |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
634 |
{ |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9063
diff
changeset
|
635 |
/// \todo I am fairly certain other compilers use other non-standard |
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9063
diff
changeset
|
636 |
/// post-fixes to indicate 64 bit constants. |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
637 |
return TimeStep (0x7fffffffffffffffLL); |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
638 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
639 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
640 |
uint32_t |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
641 |
DistributedSimulatorImpl::GetContext (void) const |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
642 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
643 |
return m_currentContext; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
644 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
645 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff
changeset
|
646 |
} // namespace ns3 |