10476
|
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 |
|
|
22 |
#ifndef NS3_REMOTE_CHANNEL_BUNDLE_MANAGER
|
|
23 |
#define NS3_REMOTE_CHANNEL_BUNDLE_MANAGER
|
|
24 |
|
|
25 |
#include <ns3/nstime.h>
|
|
26 |
#include <ns3/ptr.h>
|
|
27 |
#include <map>
|
|
28 |
|
|
29 |
namespace ns3 {
|
|
30 |
|
|
31 |
class RemoteChannelBundle;
|
|
32 |
|
|
33 |
/*
|
|
34 |
* \ingroup mpi
|
|
35 |
*
|
|
36 |
* \brief Singleton for managing the RemoteChannelBundles for each process.
|
|
37 |
*
|
|
38 |
* Manages collective tasks associated with the bundle collection.
|
|
39 |
*/
|
|
40 |
class RemoteChannelBundleManager
|
|
41 |
{
|
|
42 |
|
|
43 |
public:
|
|
44 |
/**
|
|
45 |
* \return remote channel bundle for specified SystemId.
|
|
46 |
*/
|
|
47 |
static Ptr<RemoteChannelBundle> Find (uint32_t systemId);
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Add RemoteChannelBundle from this task to MPI task on other side of the link.
|
|
51 |
* Can not be invoked after InitializeNullMessageEvents has been invoked.
|
|
52 |
*/
|
|
53 |
static Ptr<RemoteChannelBundle> Add (uint32_t systemId);
|
|
54 |
|
|
55 |
/**
|
|
56 |
* \return number of remote channel bundles
|
|
57 |
*
|
|
58 |
*/
|
|
59 |
static uint32_t Size (void);
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Setup initial Null Message events for every RemoteChannelBundle.
|
|
63 |
* All RemoteChannelBundles should be added before this method is invoked.
|
|
64 |
*/
|
|
65 |
static void InitializeNullMessageEvents (void);
|
|
66 |
|
|
67 |
/**
|
|
68 |
* \return safe time across all remote channels.
|
|
69 |
*/
|
|
70 |
static Time GetSafeTime (void);
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Destroy the singleton.
|
|
74 |
*/
|
|
75 |
static void Destroy (void);
|
|
76 |
|
|
77 |
private:
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Private ctor to prevent creation outside of singleton pattern.
|
|
81 |
*/
|
|
82 |
RemoteChannelBundleManager ()
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
~RemoteChannelBundleManager ()
|
|
87 |
{
|
|
88 |
}
|
|
89 |
|
|
90 |
/*
|
|
91 |
* Container for all remote channel bundles for this task.
|
|
92 |
*
|
|
93 |
* Would be more efficient to use unordered_map when C++11 is adopted for NS3.
|
|
94 |
*/
|
|
95 |
typedef std::map<uint32_t, Ptr<RemoteChannelBundle> > RemoteChannelMap;
|
|
96 |
static RemoteChannelMap g_remoteChannelBundles;
|
|
97 |
|
|
98 |
/*
|
|
99 |
* Protect manager class from being initialized twice or incorrect
|
|
100 |
* ordering of method calls.
|
|
101 |
*/
|
|
102 |
static bool g_initialized;
|
|
103 |
};
|
|
104 |
|
|
105 |
} // namespace ns3
|
|
106 |
|
|
107 |
#endif
|