Hardware Locality (hwloc) 2.12.0rc1

memattrs.h
1/*
2 * Copyright © 2019-2025 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
81 enum hwloc_memattr_id_e {
93 HWLOC_MEMATTR_ID_CAPACITY = 0,
94
110 HWLOC_MEMATTR_ID_LOCALITY = 1,
111
125 HWLOC_MEMATTR_ID_BANDWIDTH = 2,
126
136 HWLOC_MEMATTR_ID_READ_BANDWIDTH = 4,
137
147 HWLOC_MEMATTR_ID_WRITE_BANDWIDTH = 5,
148
162 HWLOC_MEMATTR_ID_LATENCY = 3,
163
173 HWLOC_MEMATTR_ID_READ_LATENCY = 6,
174
184 HWLOC_MEMATTR_ID_WRITE_LATENCY = 7,
185
186 /* TODO persistence? */
187
188 HWLOC_MEMATTR_ID_MAX
192};
193
202 typedef unsigned hwloc_memattr_id_t;
203
209HWLOC_DECLSPEC int
210 hwloc_memattr_get_by_name(hwloc_topology_t topology,
211 const char *name,
212 hwloc_memattr_id_t *id);
213
214
216 enum hwloc_location_type_e {
218 HWLOC_LOCATION_TYPE_CPUSET = 1,
220 HWLOC_LOCATION_TYPE_OBJECT = 0
221};
222
224 struct hwloc_location {
226 enum hwloc_location_type_e type;
228 union hwloc_location_u {
230 hwloc_cpuset_t cpuset;
232 hwloc_obj_t object;
233 } location;
234};
235
236
238 enum hwloc_local_numanode_flag_e {
244 HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY = (1UL<<0),
245
251 HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY = (1UL<<1),
252
257 HWLOC_LOCAL_NUMANODE_FLAG_ALL = (1UL<<2)
258};
259
291HWLOC_DECLSPEC int
292 hwloc_get_local_numanode_objs(hwloc_topology_t topology,
293 struct hwloc_location *location,
294 unsigned *nr,
295 hwloc_obj_t *nodes,
296 unsigned long flags);
297
345HWLOC_DECLSPEC int
346 hwloc_topology_get_default_nodeset(hwloc_topology_t topology,
347 hwloc_nodeset_t nodeset,
348 unsigned long flags);
349
372HWLOC_DECLSPEC int
373 hwloc_memattr_get_value(hwloc_topology_t topology,
374 hwloc_memattr_id_t attribute,
375 hwloc_obj_t target_node,
376 struct hwloc_location *initiator,
377 unsigned long flags,
378 hwloc_uint64_t *value);
379
408HWLOC_DECLSPEC int
409 hwloc_memattr_get_best_target(hwloc_topology_t topology,
410 hwloc_memattr_id_t attribute,
411 struct hwloc_location *initiator,
412 unsigned long flags,
413 hwloc_obj_t *best_target, hwloc_uint64_t *value);
414
438HWLOC_DECLSPEC int
439 hwloc_memattr_get_best_initiator(hwloc_topology_t topology,
440 hwloc_memattr_id_t attribute,
441 hwloc_obj_t target_node,
442 unsigned long flags,
443 struct hwloc_location *best_initiator, hwloc_uint64_t *value);
444
483HWLOC_DECLSPEC int
484 hwloc_memattr_get_targets(hwloc_topology_t topology,
485 hwloc_memattr_id_t attribute,
486 struct hwloc_location *initiator,
487 unsigned long flags,
488 unsigned *nr, hwloc_obj_t *targets, hwloc_uint64_t *values);
489
523HWLOC_DECLSPEC int
524 hwloc_memattr_get_initiators(hwloc_topology_t topology,
525 hwloc_memattr_id_t attribute,
526 hwloc_obj_t target_node,
527 unsigned long flags,
528 unsigned *nr, struct hwloc_location *initiators, hwloc_uint64_t *values);
529
564HWLOC_DECLSPEC int
565 hwloc_memattr_get_name(hwloc_topology_t topology,
566 hwloc_memattr_id_t attribute,
567 const char **name);
568
578HWLOC_DECLSPEC int
579 hwloc_memattr_get_flags(hwloc_topology_t topology,
580 hwloc_memattr_id_t attribute,
581 unsigned long *flags);
582
586 enum hwloc_memattr_flag_e {
590 HWLOC_MEMATTR_FLAG_HIGHER_FIRST = (1UL<<0),
594 HWLOC_MEMATTR_FLAG_LOWER_FIRST = (1UL<<1),
598 HWLOC_MEMATTR_FLAG_NEED_INITIATOR = (1UL<<2)
599};
600
615HWLOC_DECLSPEC int
616 hwloc_memattr_register(hwloc_topology_t topology,
617 const char *name,
618 unsigned long flags,
619 hwloc_memattr_id_t *id);
620
646HWLOC_DECLSPEC int
647 hwloc_memattr_set_value(hwloc_topology_t topology,
648 hwloc_memattr_id_t attribute,
649 hwloc_obj_t target_node,
650 struct hwloc_location *initiator,
651 unsigned long flags,
652 hwloc_uint64_t value);
653
656#ifdef __cplusplus
657} /* extern "C" */
658#endif
659
660
661#endif /* HWLOC_MEMATTR_H */
hwloc_nodeset_t
hwloc_bitmap_t hwloc_nodeset_t
A node set is a bitmap whose bits are set according to NUMA memory node physical OS indexes.
Definition hwloc.h:178
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:743
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:216
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:81
hwloc_local_numanode_flag_e
hwloc_local_numanode_flag_e
Flags for selecting target NUMA nodes.
Definition memattrs.h:238
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:202
hwloc_topology_get_default_nodeset
int hwloc_topology_get_default_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, unsigned long flags)
Return the set of default NUMA nodes.
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:218
HWLOC_LOCATION_TYPE_OBJECT
@ HWLOC_LOCATION_TYPE_OBJECT
Location is given as an object, in the location object union field.
Definition memattrs.h:220
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:125
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:147
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:173
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:110
HWLOC_MEMATTR_ID_CAPACITY
@ HWLOC_MEMATTR_ID_CAPACITY
The "Capacity" is returned in bytes (local_memory attribute in objects).
Definition memattrs.h:93
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:184
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:136
HWLOC_MEMATTR_ID_LATENCY
@ HWLOC_MEMATTR_ID_LATENCY
The "Latency" is returned as nanoseconds, as seen from the given initiator location.
Definition memattrs.h:162
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:244
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:251
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:257
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:586
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:594
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:598
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:590
hwloc_obj
Structure of a topology object.
Definition hwloc.h:432
hwloc_location
Where to measure attributes from.
Definition memattrs.h:224
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:226
hwloc_location::hwloc_location_u
Actual location.
Definition memattrs.h:228
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:230
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:232