1 #ifndef DASH__UTIL__UNIT_LOCALITY_H__INCLUDED 2 #define DASH__UTIL__UNIT_LOCALITY_H__INCLUDED 4 #include <dash/util/Locality.h> 5 #include <dash/util/LocalityDomain.h> 6 #include <dash/util/Config.h> 8 #include <dash/algorithm/internal/String.h> 13 #include <dash/Exception.h> 14 #include <dash/Team.h> 18 #include <unordered_map> 44 _team->
dart_id(), unit, &_unit_locality),
50 team.
dart_id(),
".", &team_domain),
55 team_domain, _unit_locality->domain_tag, &_unit_domain),
60 node_locality = node_locality->
parent;
79 DASH_ASSERT(
nullptr != _unit_locality);
80 return _unit_locality->
hwinfo;
85 DASH_ASSERT(
nullptr != _unit_locality);
86 return _unit_locality->
hwinfo;
91 DASH_ASSERT(
nullptr != _unit_locality);
97 DASH_ASSERT(
nullptr != _unit_locality);
103 if (
nullptr == _team) {
111 return nullptr == _unit_locality
127 dash::util::Locality::Scope scope)
129 if (scope == dash::util::Locality::Scope::Node) {
130 return node_domain();
134 for (
int rlevel = _unit_locality->
hwinfo.num_scopes;
137 if (parent_domain ==
nullptr) {
140 "Unit domain is undefined");
143 static_cast<int>(scope)) {
146 parent_domain = parent_domain->
parent;
150 "Could not find parent domain of unit in scope " << scope);
153 inline std::string domain_tag()
const 155 DASH_ASSERT(
nullptr != _unit_locality);
159 inline std::string host()
const 161 DASH_ASSERT(
nullptr != _unit_locality);
165 inline void set_domain_tag(
166 const std::string & tag)
168 strcpy(_unit_domain->
domain_tag, tag.c_str());
171 inline void set_host(
172 const std::string & hostname)
174 strcpy(_unit_locality->
hwinfo.
host, hostname.c_str());
177 inline int num_cores()
const 179 DASH_ASSERT(
nullptr != _unit_locality);
183 inline int min_threads()
185 return (_unit_locality ==
nullptr)
189 inline int max_threads()
191 return (_unit_locality ==
nullptr)
195 inline int num_threads()
const 197 DASH_ASSERT(
nullptr != _unit_locality);
198 return (dash::util::Config::get<bool>(
"DASH_MAX_SMT")
203 inline int num_numa()
const 212 inline int numa_id()
const 214 return (
nullptr == _unit_locality ? -1 : _unit_locality->
hwinfo.numa_id);
217 inline int cpu_id()
const 219 return (
nullptr == _unit_locality ? -1 : _unit_locality->
hwinfo.
cpu_id);
222 inline int cpu_mhz()
const 224 DASH_ASSERT(
nullptr != _unit_locality);
228 inline int max_shmem_mbps()
const 230 DASH_ASSERT(
nullptr != _unit_locality);
234 inline int max_cpu_mhz()
236 return (_unit_locality ==
nullptr)
240 inline int min_cpu_mhz()
242 return (_unit_locality ==
nullptr)
246 inline int cache_line_size(
int cache_level)
248 return (_unit_locality ==
nullptr)
249 ? 64 : std::max<int>(
254 inline std::string hostname()
256 return (_unit_locality ==
nullptr) ?
"" : _unit_locality->
hwinfo.
host;
308 auto n_threads = num_cores();
309 if (dash::util::Config::get<bool>(
"DASH_DISABLE_THREADS")) {
312 }
else if (dash::util::Config::get<bool>(
"DASH_MAX_SMT")) {
314 n_threads *= max_threads();
317 n_threads *= min_threads();
319 if (dash::util::Config::is_set(
"DASH_MAX_UNIT_THREADS")) {
320 n_threads = std::min(dash::util::Config::get<int>(
321 "DASH_MAX_UNIT_THREADS"),
339 #endif // DASH__UTIL__UNIT_LOCALITY_H__INCLUDED constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
char host[((int)(256))]
Hostname of the domain's node or 0 if unspecified.
int max_cpu_mhz
Maximum clock frequency of CPUs in the domain.
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
Locality and topology information of a single unit.
dart_ret_t dart_unit_locality(dart_team_t team, dart_team_unit_t unit, dart_unit_locality_t **loc)
Locality information of the unit with the specified team-relative id.
This class is a simple memory pool which holds allocates elements of size ValueType.
int num_cores
Total number of CPUs in the associated domain.
Node-level locality scope, components may be heterogenous.
char domain_tag[((int)(32))]
Hierarchical domain identifier, represented as dot-separated list of relative indices on every level ...
struct dash::unit_id< dash::global_unit, dart_global_unit_t > global_unit_t
Unit ID to use for global IDs.
dart_hwinfo_t hwinfo
Hardware specification of the unit's affinity.
int num_domains
Number of subordinate domains.
A domain is a group of processing entities such as cores in a specific NUMA domain or a Intel MIC ent...
int num_domain_threads()
Number of threads currently available to the active unit.
int min_cpu_mhz
Minimum clock frequency of CPUs in the domain.
A Team instance specifies a subset of all available units.
dart_ret_t dart_domain_team_locality(dart_team_t team, const char *domain_tag, dart_domain_locality_t **team_domain_out)
Locality information of the team domain with the specified id tag.
dart_locality_scope_t scope
The domain's scope identifier.
int max_threads
Maximum number of CPU threads per core.
Locality of homogenous components in different NUMA domains.
dart_locality_scope_t scope
Locality scope of the domain.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
Wrapper of a single dart_domain_locality_t object.
int cache_line_sizes[((int)(5))]
Cache line sizes by cache level (L1, L2, L3).
Hardware locality information for a single locality domain.
dart_ret_t dart_domain_find(const dart_domain_locality_t *domain_in, const char *domain_tag, dart_domain_locality_t **subdomain_out)
Locality information of the subdomain with the specified id tag.
dart_locality_scope_pos_t scopes[((int)(12))]
Ancestor locality scopes in bottom-up hierarchical order.
static Team & Null()
The invariant Team instance representing an undefined team.
int min_threads
Minimum number of CPU threads per core.
int max_shmem_mbps
Maximum local shared memory bandwidth in MB/s.
static Team & All()
The invariant Team instance containing all available units.
struct dart_domain_locality_s * parent
Pointer to descriptor of parent domain or 0 if no parent domain is specified.
dart_team_unit_t unit
Unit ID relative to team.
int cpu_id
The unit's affine processing unit (SMP), unique identifier within a processing module.
dart_team_t dart_id() const
Index of this team relative to global team dash::Team::All().
Wrapper of a single dart_unit_locality_t object.