A Discrete-Event Network Simulator
API
remote-channel-bundle-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2013. Lawrence Livermore National Security, LLC.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Steven Smith <smith84@llnl.gov>
19  *
20  */
21 
29 
30 #include "remote-channel-bundle.h"
32 
33 #include "ns3/simulator.h"
34 
35 namespace ns3 {
36 
39 
40 Ptr<RemoteChannelBundle>
42 {
43  ns3::RemoteChannelBundleManager::RemoteChannelMap::iterator kv = g_remoteChannelBundles.find (systemId);
44 
45  if ( kv == g_remoteChannelBundles.end ())
46  {
47  return 0;
48  }
49  else
50  {
51  return kv->second;
52  }
53 }
54 
57 {
59  NS_ASSERT (g_remoteChannelBundles.find (systemId) == g_remoteChannelBundles.end ());
60 
61  Ptr<RemoteChannelBundle> remoteChannelBundle = Create<RemoteChannelBundle> (systemId);
62 
63  g_remoteChannelBundles[systemId] = remoteChannelBundle;
64 
65  return remoteChannelBundle;
66 }
67 
68 std::size_t
70 {
71  return g_remoteChannelBundles.size();
72 }
73 
74 void
76 {
78 
79  for ( RemoteChannelMap::const_iterator iter = g_remoteChannelBundles.begin ();
80  iter != g_remoteChannelBundles.end ();
81  ++iter )
82  {
83  Ptr<RemoteChannelBundle> bundle = iter->second;
84  bundle->Send (bundle->GetDelay ());
85 
87  }
88 
89  g_initialized = true;
90 }
91 
92 Time
94 {
96 
98 
99  for (RemoteChannelMap::const_iterator kv = g_remoteChannelBundles.begin ();
100  kv != g_remoteChannelBundles.end ();
101  ++kv)
102  {
103  safeTime = Min (safeTime, kv->second->GetGuaranteeTime ());
104  }
105 
106  return safeTime;
107 }
108 
109 void
111 {
113 
114  g_remoteChannelBundles.clear();
115  g_initialized = false;
116 }
117 
118 } // namespace ns3
static NullMessageSimulatorImpl * GetInstance(void)
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
Get the bundle corresponding to a remote rank.
static std::size_t Size(void)
Get the number of ns-3 channels in this bundle.
static RemoteChannelMap g_remoteChannelBundles
The remote channel bundles.
static void InitializeNullMessageEvents(void)
Setup initial Null Message events for every RemoteChannelBundle.
static Ptr< RemoteChannelBundle > Add(uint32_t systemId)
Add RemoteChannelBundle from this task to MPI task on other side of the link.
std::unordered_map< uint32_t, Ptr< RemoteChannelBundle > > RemoteChannelMap
Container for all remote channel bundles for this task.
static Time GetSafeTime(void)
Get the safe time across all channels in this bundle.
static void Destroy(void)
Destroy the singleton.
static bool g_initialized
Protect manager class from being initialized twice or incorrect ordering of method calls.
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:293
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:218
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Declaration of class ns3::NullMessageSimulatorImpl.
Declaration of class ns3::RemoteChannelBundleManager.
Declaration of class ns3::RemoteChannelBundle.