DASH  0.3.0
TeamLocality.h
1 #ifndef DASH__UTIL__TEAM_LOCALITY_H__INCLUDED
2 #define DASH__UTIL__TEAM_LOCALITY_H__INCLUDED
3 
4 #include <dash/util/Locality.h>
5 #include <dash/util/LocalityDomain.h>
6 #include <dash/util/UnitLocality.h>
7 
10 
11 #include <dash/algorithm/internal/String.h>
12 
13 #include <dash/Exception.h>
14 #include <dash/Team.h>
15 
16 #include <string>
17 #include <vector>
18 #include <unordered_map>
19 #include <utility>
20 #include <iterator>
21 #include <algorithm>
22 
23 
24 namespace dash {
25 namespace util {
26 
62 {
63 private:
64  typedef TeamLocality self_t;
65  typedef dash::util::Locality::Scope Scope_t;
67 
68 public:
75  dash::Team & team,
76  Scope_t scope = Scope_t::Global,
77  std::string domain_tag = ".");
78 
84  dash::Team & team,
85  LocalityDomain_t & domain);
86 
90  TeamLocality() = default;
91 
95  TeamLocality(const self_t & other) = default;
96 
100  self_t & operator=(const self_t & other) = default;
101 
105  inline const LocalityDomain_t & domain() const
106  {
107  return _domain;
108  }
109 
113  inline LocalityDomain_t & domain()
114  {
115  return _domain;
116  }
117 
118  //inline const dash::util::UnitLocality & unit_locality(
119  // team_unit_t unit) const
120  //{
121  // return _domain.unit_locality(unit);
122  //}
123  //
124  //inline dash::util::UnitLocality & unit_locality(
125  // team_unit_t unit)
126  //{
127  // return _domain.unit_locality(unit);
128  //}
129 
136  inline self_t & split(Scope_t scope, int num_split_parts = 0)
137  {
138  _domain.split(scope, num_split_parts);
139  return *this;
140  }
141 
145  inline self_t & split_groups()
146  {
147  _domain.split_groups();
148  return *this;
149  }
150 
154  inline std::vector<LocalityDomain_t::iterator> & groups()
155  {
156  return _domain.groups();
157  }
158 
162  inline const std::vector<LocalityDomain_t::iterator> & groups() const
163  {
164  return _domain.groups();
165  }
166 
170  inline std::vector<LocalityDomain_t> & parts()
171  {
172  return _domain.parts();
173  }
174 
178  inline const std::vector<LocalityDomain_t> & parts() const
179  {
180  return _domain.parts();
181  }
182 
183  inline size_t num_nodes() const
184  {
185  return _domain.size();
186  }
187 
188  inline size_t num_cores() const
189  {
190  return _domain.num_cores();
191  }
192 
193  inline dash::Team & team() const
194  {
195  return (nullptr == _team) ? dash::Team::Null() : *_team;
196  }
197 
198  inline const std::vector<global_unit_t> & global_units() const
199  {
200  return _domain.units();
201  }
202 
203  inline dash::util::UnitLocality unit_locality(
204  team_unit_t unit_id) const
205  {
206  return dash::util::UnitLocality(*_team, unit_id);
207  }
208 
209  inline dash::util::UnitLocality unit_locality(
210  global_unit_t unit_id) const
211  {
212  team_unit_t l_unit_id;
213  dart_team_unit_g2l(_team->dart_id(), unit_id, &l_unit_id);
214  return dash::util::UnitLocality(*_team, l_unit_id);
215  }
216 
217  inline LocalityDomain_t & group(
218  const std::vector<std::string> & group_subdomain_tags)
219  {
220  return _domain.group(group_subdomain_tags);
221  }
222 
223  inline self_t & select(
224  const std::vector<std::string> & domain_tags)
225  {
226  _domain.select(domain_tags);
227  return *this;
228  }
229 
230  inline self_t & exclude(
231  const std::vector<std::string> & domain_tags)
232  {
233  _domain.exclude(domain_tags);
234  return *this;
235  }
236 
237 private:
238  dash::Team * _team = nullptr;
240  Scope_t _scope = Scope_t::Undefined;
242  LocalityDomain_t _domain;
243 
244 }; // class TeamLocality
245 
246 } // namespace util
247 } // namespace dash
248 
249 #endif // DASH__UTIL__TEAM_LOCALITY_H__INCLUDED
const LocalityDomain_t & domain() const
The team locality domain descriptor.
Definition: TeamLocality.h:105
TeamLocality()=default
Default constructor.
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
const std::vector< LocalityDomain_t::iterator > & groups() const
Parts of the team locality that have been created in a previous split.
Definition: TeamLocality.h:162
std::vector< LocalityDomain_t::iterator > & groups()
Parts of the team locality that resulted from a previous split.
Definition: TeamLocality.h:154
self_t & split(Scope_t scope, int num_split_parts=0)
Split the team locality domain into the given number of parts on the specified locality scope...
Definition: TeamLocality.h:136
struct dash::unit_id< dash::global_unit, dart_global_unit_t > global_unit_t
Unit ID to use for global IDs.
Definition: Types.h:332
std::vector< LocalityDomain_t > & parts()
Parts of the team locality that resulted from a previous split.
Definition: TeamLocality.h:170
self_t & operator=(const self_t &other)=default
Assignment operator.
self_t & group(const std::vector< std::string > &group_subdomain_tags)
Add a group subdomain consisting of domains with the specified tags.
A Team instance specifies a subset of all available units.
Definition: Team.h:41
self_t & split_groups()
Split groups in locality domain into separate parts.
Definition: TeamLocality.h:145
self_t & split_groups()
Split groups in locality domain into separate parts.
Hierarchical locality domains of a specified team.
Definition: TeamLocality.h:61
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
Definition: Types.h:319
Wrapper of a single dart_domain_locality_t object.
const std::vector< LocalityDomain_t > & parts() const
Parts of the team locality that have been created in a previous split.
Definition: TeamLocality.h:178
static Team & Null()
The invariant Team instance representing an undefined team.
Definition: Team.h:229
dart_ret_t dart_team_unit_g2l(dart_team_t team, dart_global_unit_t globalid, dart_team_unit_t *localid)
Convert from a global to a local unit ID.
self_t & select(const std::vector< std::string > &subdomain_tags)
Remove subdomains that do not match one of the specified domain tags and are not a subdomain of a mat...
self_t & split(dash::util::Locality::Scope scope, int num_split_parts)
Split the team locality domain into the given number of parts on the specified locality scope...
self_t & exclude(const std::vector< std::string > &subdomain_tags)
Remove subdomains that match the specified domain tags or are a subdomain of a matched domain...
LocalityDomain_t & domain()
The team locality domain descriptor.
Definition: TeamLocality.h:113
dart_team_t dart_id() const
Index of this team relative to global team dash::Team::All().
Definition: Team.h:522
Wrapper of a single dart_unit_locality_t object.
Definition: UnitLocality.h:30