Hardware Locality (hwloc) 2.11.2

memattrs.h
1/*
2 * Copyright © 2019-2024 Inria. All rights reserved.
3 * See COPYING in top-level directory.
4 */
5
10#ifndef HWLOC_MEMATTR_H
11#define HWLOC_MEMATTR_H
12
13#include "hwloc.h"
14
15#ifdef __cplusplus
16 extern "C" {
17#elif 0
18}
19#endif
20
76 enum hwloc_memattr_id_e {
88 HWLOC_MEMATTR_ID_CAPACITY = 0,
89
105 HWLOC_MEMATTR_ID_LOCALITY = 1,
106
120 HWLOC_MEMATTR_ID_BANDWIDTH = 2,
121
131 HWLOC_MEMATTR_ID_READ_BANDWIDTH = 4,
132
142 HWLOC_MEMATTR_ID_WRITE_BANDWIDTH = 5,
143
157 HWLOC_MEMATTR_ID_LATENCY = 3,
158
168 HWLOC_MEMATTR_ID_READ_LATENCY = 6,
169
179 HWLOC_MEMATTR_ID_WRITE_LATENCY = 7,
180
181 /* TODO persistence? */
182
183 HWLOC_MEMATTR_ID_MAX
187};
188
197 typedef unsigned hwloc_memattr_id_t;
198
204HWLOC_DECLSPEC int
205 hwloc_memattr_get_by_name(hwloc_topology_t topology,
206 const char *name,
207 hwloc_memattr_id_t *id);
208
209
211 enum hwloc_location_type_e {
213 HWLOC_LOCATION_TYPE_CPUSET = 1,
215 HWLOC_LOCATION_TYPE_OBJECT = 0
216};
217
219 struct hwloc_location {
221 enum hwloc_location_type_e type;
223 union hwloc_location_u {
225 hwloc_cpuset_t cpuset;
227 hwloc_obj_t object;
228 } location;
229};
230
231
233 enum hwloc_local_numanode_flag_e {
239 HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY = (1UL<<0),
240
246 HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY = (1UL<<1),
247
252 HWLOC_LOCAL_NUMANODE_FLAG_ALL = (1UL<<2)
253};
254
286HWLOC_DECLSPEC int
287 hwloc_get_local_numanode_objs(hwloc_topology_t topology,
288 struct hwloc_location *location,
289 unsigned *nr,
290 hwloc_obj_t *nodes,
291 unsigned long flags);
292
293
294
317HWLOC_DECLSPEC int
318 hwloc_memattr_get_value(hwloc_topology_t topology,
319 hwloc_memattr_id_t attribute,
320 hwloc_obj_t target_node,
321 struct hwloc_location *initiator,
322 unsigned long flags,
323 hwloc_uint64_t *value);
324
353HWLOC_DECLSPEC int
354 hwloc_memattr_get_best_target(hwloc_topology_t topology,
355 hwloc_memattr_id_t attribute,
356 struct hwloc_location *initiator,
357 unsigned long flags,
358 hwloc_obj_t *best_target, hwloc_uint64_t *value);
359
383HWLOC_DECLSPEC int
384 hwloc_memattr_get_best_initiator(hwloc_topology_t topology,
385 hwloc_memattr_id_t attribute,
386 hwloc_obj_t target_node,
387 unsigned long flags,
388 struct hwloc_location *best_initiator, hwloc_uint64_t *value);
389
428HWLOC_DECLSPEC int
429 hwloc_memattr_get_targets(hwloc_topology_t topology,
430 hwloc_memattr_id_t attribute,
431 struct hwloc_location *initiator,
432 unsigned long flags,
433 unsigned *nr, hwloc_obj_t *targets, hwloc_uint64_t *values);
434
468HWLOC_DECLSPEC int
469 hwloc_memattr_get_initiators(hwloc_topology_t topology,
470 hwloc_memattr_id_t attribute,
471 hwloc_obj_t target_node,
472 unsigned long flags,
473 unsigned *nr, struct hwloc_location *initiators, hwloc_uint64_t *values);
474
509HWLOC_DECLSPEC int
510 hwloc_memattr_get_name(hwloc_topology_t topology,
511 hwloc_memattr_id_t attribute,
512 const char **name);
513
523HWLOC_DECLSPEC int
524 hwloc_memattr_get_flags(hwloc_topology_t topology,
525 hwloc_memattr_id_t attribute,
526 unsigned long *flags);
527
531 enum hwloc_memattr_flag_e {
535 HWLOC_MEMATTR_FLAG_HIGHER_FIRST = (1UL<<0),
539 HWLOC_MEMATTR_FLAG_LOWER_FIRST = (1UL<<1),
543 HWLOC_MEMATTR_FLAG_NEED_INITIATOR = (1UL<<2)
544};
545
560HWLOC_DECLSPEC int
561 hwloc_memattr_register(hwloc_topology_t topology,
562 const char *name,
563 unsigned long flags,
564 hwloc_memattr_id_t *id);
565
591HWLOC_DECLSPEC int
592 hwloc_memattr_set_value(hwloc_topology_t topology,
593 hwloc_memattr_id_t attribute,
594 hwloc_obj_t target_node,
595 struct hwloc_location *initiator,
596 unsigned long flags,
597 hwloc_uint64_t value);
598
601#ifdef __cplusplus
602} /* extern "C" */
603#endif
604
605
606#endif /* HWLOC_MEMATTR_H */
hwloc_cpuset_t
hwloc_bitmap_t hwloc_cpuset_t
A CPU set is a bitmap whose bits are set according to CPU physical OS indexes.
Definition hwloc.h:161
hwloc_topology_t
struct hwloc_topology * hwloc_topology_t
Topology context.
Definition hwloc.h:742
hwloc_memattr_get_initiators
int hwloc_memattr_get_initiators(hwloc_topology_t topology, hwloc_memattr_id_t attribute, hwloc_obj_t target_node, unsigned long flags, unsigned *nr, struct hwloc_location *initiators, hwloc_uint64_t *values)
Return the initiators that have values for a given attribute for a specific target NUMA node.
hwloc_memattr_get_value
int hwloc_memattr_get_value(hwloc_topology_t topology, hwloc_memattr_id_t attribute, hwloc_obj_t target_node, struct hwloc_location *initiator, unsigned long flags, hwloc_uint64_t *value)
Return an attribute value for a specific target NUMA node.
hwloc_location_type_e
hwloc_location_type_e
Type of location.
Definition memattrs.h:211
hwloc_get_local_numanode_objs
int hwloc_get_local_numanode_objs(hwloc_topology_t topology, struct hwloc_location *location, unsigned *nr, hwloc_obj_t *nodes, unsigned long flags)
Return an array of local NUMA nodes.
hwloc_memattr_get_by_name
int hwloc_memattr_get_by_name(hwloc_topology_t topology, const char *name, hwloc_memattr_id_t *id)
Return the identifier of the memory attribute with the given name.
hwloc_memattr_get_best_target
int hwloc_memattr_get_best_target(hwloc_topology_t topology, hwloc_memattr_id_t attribute, struct hwloc_location *initiator, unsigned long flags, hwloc_obj_t *best_target, hwloc_uint64_t *value)
Return the best target NUMA node for the given attribute and initiator.
hwloc_memattr_id_e
hwloc_memattr_id_e
Predefined memory attribute IDs. See hwloc_memattr_id_t for the generic definition of IDs for predefi...
Definition memattrs.h:76
hwloc_local_numanode_flag_e
hwloc_local_numanode_flag_e
Flags for selecting target NUMA nodes.
Definition memattrs.h:233
hwloc_memattr_get_targets
int hwloc_memattr_get_targets(hwloc_topology_t topology, hwloc_memattr_id_t attribute, struct hwloc_location *initiator, unsigned long flags, unsigned *nr, hwloc_obj_t *targets, hwloc_uint64_t *values)
Return the target NUMA nodes that have some values for a given attribute.
hwloc_memattr_id_t
unsigned hwloc_memattr_id_t
A memory attribute identifier.
Definition memattrs.h:197
hwloc_memattr_get_best_initiator
int hwloc_memattr_get_best_initiator(hwloc_topology_t topology, hwloc_memattr_id_t attribute, hwloc_obj_t target_node, unsigned long flags, struct hwloc_location *best_initiator, hwloc_uint64_t *value)
Return the best initiator for the given attribute and target NUMA node.
HWLOC_LOCATION_TYPE_CPUSET
@ HWLOC_LOCATION_TYPE_CPUSET
Location is given as a cpuset, in the location cpuset union field.
Definition memattrs.h:213
HWLOC_LOCATION_TYPE_OBJECT
@ HWLOC_LOCATION_TYPE_OBJECT
Location is given as an object, in the location object union field.
Definition memattrs.h:215
HWLOC_MEMATTR_ID_BANDWIDTH
@ HWLOC_MEMATTR_ID_BANDWIDTH
The "Bandwidth" is returned in MiB/s, as seen from the given initiator location.
Definition memattrs.h:120
HWLOC_MEMATTR_ID_WRITE_BANDWIDTH
@ HWLOC_MEMATTR_ID_WRITE_BANDWIDTH
The "WriteBandwidth" is returned in MiB/s, as seen from the given initiator location.
Definition memattrs.h:142
HWLOC_MEMATTR_ID_READ_LATENCY
@ HWLOC_MEMATTR_ID_READ_LATENCY
The "ReadLatency" is returned as nanoseconds, as seen from the given initiator location.
Definition memattrs.h:168
HWLOC_MEMATTR_ID_LOCALITY
@ HWLOC_MEMATTR_ID_LOCALITY
The "Locality" is returned as the number of PUs in that locality (e.g. the weight of its cpuset).
Definition memattrs.h:105
HWLOC_MEMATTR_ID_CAPACITY
@ HWLOC_MEMATTR_ID_CAPACITY
The "Capacity" is returned in bytes (local_memory attribute in objects).
Definition memattrs.h:88
HWLOC_MEMATTR_ID_WRITE_LATENCY
@ HWLOC_MEMATTR_ID_WRITE_LATENCY
The "WriteLatency" is returned as nanoseconds, as seen from the given initiator location.
Definition memattrs.h:179
HWLOC_MEMATTR_ID_READ_BANDWIDTH
@ HWLOC_MEMATTR_ID_READ_BANDWIDTH
The "ReadBandwidth" is returned in MiB/s, as seen from the given initiator location.
Definition memattrs.h:131
HWLOC_MEMATTR_ID_LATENCY
@ HWLOC_MEMATTR_ID_LATENCY
The "Latency" is returned as nanoseconds, as seen from the given initiator location.
Definition memattrs.h:157
HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY
@ HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY
Select NUMA nodes whose locality is larger than the given cpuset. For instance, if a single PU (or it...
Definition memattrs.h:239
HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY
@ HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY
Select NUMA nodes whose locality is smaller than the given cpuset. For instance, if a package (or its...
Definition memattrs.h:246
HWLOC_LOCAL_NUMANODE_FLAG_ALL
@ HWLOC_LOCAL_NUMANODE_FLAG_ALL
Select all NUMA nodes in the topology. The initiator initiator is ignored.
Definition memattrs.h:252
hwloc_memattr_get_flags
int hwloc_memattr_get_flags(hwloc_topology_t topology, hwloc_memattr_id_t attribute, unsigned long *flags)
Return the flags of the given attribute.
hwloc_memattr_get_name
int hwloc_memattr_get_name(hwloc_topology_t topology, hwloc_memattr_id_t attribute, const char **name)
Return the name of a memory attribute.
hwloc_memattr_register
int hwloc_memattr_register(hwloc_topology_t topology, const char *name, unsigned long flags, hwloc_memattr_id_t *id)
Register a new memory attribute.
hwloc_memattr_flag_e
hwloc_memattr_flag_e
Memory attribute flags. Given to hwloc_memattr_register() and returned by hwloc_memattr_get_flags().
Definition memattrs.h:531
hwloc_memattr_set_value
int hwloc_memattr_set_value(hwloc_topology_t topology, hwloc_memattr_id_t attribute, hwloc_obj_t target_node, struct hwloc_location *initiator, unsigned long flags, hwloc_uint64_t value)
Set an attribute value for a specific target NUMA node.
HWLOC_MEMATTR_FLAG_LOWER_FIRST
@ HWLOC_MEMATTR_FLAG_LOWER_FIRST
The best nodes for this memory attribute are those with the lower values. For instance Latency.
Definition memattrs.h:539
HWLOC_MEMATTR_FLAG_NEED_INITIATOR
@ HWLOC_MEMATTR_FLAG_NEED_INITIATOR
The value returned for this memory attribute depends on the given initiator. For instance Bandwidth a...
Definition memattrs.h:543
HWLOC_MEMATTR_FLAG_HIGHER_FIRST
@ HWLOC_MEMATTR_FLAG_HIGHER_FIRST
The best nodes for this memory attribute are those with the higher values. For instance Bandwidth.
Definition memattrs.h:535
hwloc_obj
Structure of a topology object.
Definition hwloc.h:431
hwloc_location
Where to measure attributes from.
Definition memattrs.h:219
hwloc_location::location
union hwloc_location::hwloc_location_u location
hwloc_location::type
enum hwloc_location_type_e type
Type of location.
Definition memattrs.h:221
hwloc_location::hwloc_location_u
Actual location.
Definition memattrs.h:223
hwloc_location::hwloc_location_u::cpuset
hwloc_cpuset_t cpuset
Location as a cpuset, when the location type is HWLOC_LOCATION_TYPE_CPUSET.
Definition memattrs.h:225
hwloc_location::hwloc_location_u::object
hwloc_obj_t object
Location as an object, when the location type is HWLOC_LOCATION_TYPE_OBJECT.
Definition memattrs.h:227