| 1 |
.TH "hwlocality_memattrs" 3 "Version 2.14.0" "Hardware Locality (hwloc)" \" -*- nroff -*- |
| 2 |
.ad l |
| 3 |
.nh |
| 4 |
.SH NAME |
| 5 |
hwlocality_memattrs \- Comparing memory node attributes for finding where to allocate on |
| 6 |
.SH SYNOPSIS |
| 7 |
.br |
| 8 |
.PP |
| 9 |
.SS "Data Structures" |
| 10 |
|
| 11 |
.in +1c |
| 12 |
.ti -1c |
| 13 |
.RI "struct \fBhwloc_location\fP" |
| 14 |
.br |
| 15 |
.in -1c |
| 16 |
.SS "Typedefs" |
| 17 |
|
| 18 |
.in +1c |
| 19 |
.ti -1c |
| 20 |
.RI "typedef unsigned \fBhwloc_memattr_id_t\fP" |
| 21 |
.br |
| 22 |
.in -1c |
| 23 |
.SS "Enumerations" |
| 24 |
|
| 25 |
.in +1c |
| 26 |
.ti -1c |
| 27 |
.RI "enum \fBhwloc_memattr_id_e\fP { \fBHWLOC_MEMATTR_ID_CAPACITY\fP, \fBHWLOC_MEMATTR_ID_LOCALITY\fP, \fBHWLOC_MEMATTR_ID_BANDWIDTH\fP, \fBHWLOC_MEMATTR_ID_READ_BANDWIDTH\fP, \fBHWLOC_MEMATTR_ID_WRITE_BANDWIDTH\fP, \fBHWLOC_MEMATTR_ID_LATENCY\fP, \fBHWLOC_MEMATTR_ID_READ_LATENCY\fP, \fBHWLOC_MEMATTR_ID_WRITE_LATENCY\fP, \fBHWLOC_MEMATTR_ID_MAX\fP }" |
| 28 |
.br |
| 29 |
.ti -1c |
| 30 |
.RI "enum \fBhwloc_location_type_e\fP { \fBHWLOC_LOCATION_TYPE_CPUSET\fP, \fBHWLOC_LOCATION_TYPE_OBJECT\fP }" |
| 31 |
.br |
| 32 |
.ti -1c |
| 33 |
.RI "enum \fBhwloc_local_numanode_flag_e\fP { \fBHWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY\fP, \fBHWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY\fP, \fBHWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY\fP, \fBHWLOC_LOCAL_NUMANODE_FLAG_ALL\fP }" |
| 34 |
.br |
| 35 |
.in -1c |
| 36 |
.SS "Functions" |
| 37 |
|
| 38 |
.in +1c |
| 39 |
.ti -1c |
| 40 |
.RI "int \fBhwloc_memattr_get_by_name\fP (\fBhwloc_topology_t\fP topology, const char *name, \fBhwloc_memattr_id_t\fP *id)" |
| 41 |
.br |
| 42 |
.ti -1c |
| 43 |
.RI "int \fBhwloc_get_local_numanode_objs\fP (\fBhwloc_topology_t\fP topology, struct \fBhwloc_location\fP *location, unsigned *nr, \fBhwloc_obj_t\fP *nodes, unsigned long flags)" |
| 44 |
.br |
| 45 |
.ti -1c |
| 46 |
.RI "int \fBhwloc_topology_get_default_nodeset\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_nodeset_t\fP nodeset, unsigned long flags)" |
| 47 |
.br |
| 48 |
.ti -1c |
| 49 |
.RI "int \fBhwloc_memattr_get_value\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, \fBhwloc_obj_t\fP target_node, struct \fBhwloc_location\fP *initiator, unsigned long flags, hwloc_uint64_t *value)" |
| 50 |
.br |
| 51 |
.ti -1c |
| 52 |
.RI "int \fBhwloc_memattr_get_best_target\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, struct \fBhwloc_location\fP *initiator, unsigned long flags, \fBhwloc_obj_t\fP *best_target, hwloc_uint64_t *value)" |
| 53 |
.br |
| 54 |
.ti -1c |
| 55 |
.RI "int \fBhwloc_memattr_get_best_initiator\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, \fBhwloc_obj_t\fP target_node, unsigned long flags, struct \fBhwloc_location\fP *best_initiator, hwloc_uint64_t *value)" |
| 56 |
.br |
| 57 |
.ti -1c |
| 58 |
.RI "int \fBhwloc_memattr_get_targets\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, struct \fBhwloc_location\fP *initiator, unsigned long flags, unsigned *nr, \fBhwloc_obj_t\fP *targets, hwloc_uint64_t *values)" |
| 59 |
.br |
| 60 |
.ti -1c |
| 61 |
.RI "int \fBhwloc_memattr_get_initiators\fP (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, \fBhwloc_obj_t\fP target_node, unsigned long flags, unsigned *nr, struct \fBhwloc_location\fP *initiators, hwloc_uint64_t *values)" |
| 62 |
.br |
| 63 |
.in -1c |
| 64 |
.SH "Detailed Description" |
| 65 |
.PP |
| 66 |
Platforms with heterogeneous memory require ways to decide whether a buffer should be allocated on "fast" memory (such as HBM), "normal" memory (DDR) or even "slow" but large-capacity memory (non-volatile memory)\&. These memory nodes are called "Targets" while the CPU accessing them is called the "Initiator"\&. Access performance depends on their locality (NUMA platforms) as well as the intrinsic performance of the targets (heterogeneous platforms)\&. |
| 67 |
|
| 68 |
.PP |
| 69 |
The following attributes describe the performance of memory accesses from an Initiator to a memory Target, for instance their latency or bandwidth\&. Initiators performing these memory accesses are usually some PUs or Cores (described as a CPU set)\&. Hence a Core may choose where to allocate a memory buffer by comparing the attributes of different target memory nodes nearby\&. |
| 70 |
|
| 71 |
.PP |
| 72 |
There are also some attributes that are system-wide\&. Their value does not depend on a specific initiator performing an access\&. The memory node Capacity is an example of such attribute without initiator\&. |
| 73 |
|
| 74 |
.PP |
| 75 |
One way to use this API is to start with a cpuset describing the Cores where a program is bound\&. The best target NUMA node for allocating memory in this program on these Cores may be obtained by passing this cpuset as an initiator to \fBhwloc_memattr_get_best_target()\fP with the relevant memory attribute\&. For instance, if the code is latency limited, use the Latency attribute\&. |
| 76 |
|
| 77 |
.PP |
| 78 |
A more flexible approach consists in getting the list of local NUMA nodes by passing this cpuset to \fBhwloc_get_local_numanode_objs()\fP\&. Attribute values for these nodes, if any, may then be obtained with \fBhwloc_memattr_get_value()\fP and manually compared with the desired criteria\&. |
| 79 |
|
| 80 |
.PP |
| 81 |
Memory attributes are also used internally to build Memory Tiers which provide an easy way to distinguish NUMA nodes of different kinds, as explained in \fBHeterogeneous Memory\fP\&. |
| 82 |
|
| 83 |
.PP |
| 84 |
Beside tiers, hwloc defines a set of "default" nodes where normal memory allocations should be made from (see \fBhwloc_topology_get_default_nodeset()\fP)\&. This is also useful for dividing the machine into a set of non-overlapping NUMA domains, for instance for binding tasks per domain\&. |
| 85 |
|
| 86 |
.PP |
| 87 |
\fBSee also\fP |
| 88 |
.RS 4 |
| 89 |
An example is available in doc/examples/memory-attributes\&.c in the source tree\&. |
| 90 |
.RE |
| 91 |
.PP |
| 92 |
\fBNote\fP |
| 93 |
.RS 4 |
| 94 |
The API also supports specific objects as initiator, but it is currently not used internally by hwloc\&. Users may for instance use it to provide custom performance values for host memory accesses performed by GPUs\&. |
| 95 |
|
| 96 |
.PP |
| 97 |
The interface actually also accepts targets that are not NUMA nodes\&. |
| 98 |
.RE |
| 99 |
.PP |
| 100 |
|
| 101 |
.SH "Typedef Documentation" |
| 102 |
.PP |
| 103 |
.SS "typedef unsigned \fBhwloc_memattr_id_t\fP" |
| 104 |
|
| 105 |
.PP |
| 106 |
A memory attribute identifier\&. hwloc predefines some commonly-used attributes in \fBhwloc_memattr_id_e\fP\&. One may then dynamically register custom ones with \fBhwloc_memattr_register()\fP, they will be assigned IDs immediately after the predefined ones\&. See \fBManaging memory attributes\fP for more information about existing attribute IDs\&. |
| 107 |
.SH "Enumeration Type Documentation" |
| 108 |
.PP |
| 109 |
.SS "enum \fBhwloc_local_numanode_flag_e\fP" |
| 110 |
|
| 111 |
.PP |
| 112 |
Flags for selecting target NUMA nodes\&. |
| 113 |
.PP |
| 114 |
\fBEnumerator\fP |
| 115 |
.in +1c |
| 116 |
.TP |
| 117 |
\f(BIHWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY \fP |
| 118 |
Select NUMA nodes whose locality is larger than the given cpuset\&. For instance, if a single PU (or its cpuset) is given in \fRinitiator\fP, select all nodes close to the package that contains this PU\&. |
| 119 |
.TP |
| 120 |
\f(BIHWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY \fP |
| 121 |
Select NUMA nodes whose locality is smaller than the given cpuset\&. For instance, if a package (or its cpuset) is given in \fRinitiator\fP, also select nodes that are attached to only a half of that package\&. |
| 122 |
.TP |
| 123 |
\f(BIHWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY \fP |
| 124 |
Select NUMA nodes whose locality intersects the given cpuset\&. This includes larger and smaller localities as well as localities that are partially included\&. For instance, if the locality is one core of both packages, a NUMA node local to one package is neither larger nor smaller than this locality, but it intersects it\&. |
| 125 |
.TP |
| 126 |
\f(BIHWLOC_LOCAL_NUMANODE_FLAG_ALL \fP |
| 127 |
Select all NUMA nodes in the topology\&. The initiator \fRinitiator\fP is ignored\&. |
| 128 |
.SS "enum \fBhwloc_location_type_e\fP" |
| 129 |
|
| 130 |
.PP |
| 131 |
Type of location\&. |
| 132 |
.PP |
| 133 |
\fBEnumerator\fP |
| 134 |
.in +1c |
| 135 |
.TP |
| 136 |
\f(BIHWLOC_LOCATION_TYPE_CPUSET \fP |
| 137 |
Location is given as a cpuset, in the location cpuset union field\&. |
| 138 |
.TP |
| 139 |
\f(BIHWLOC_LOCATION_TYPE_OBJECT \fP |
| 140 |
Location is given as an object, in the location object union field\&. |
| 141 |
.SS "enum \fBhwloc_memattr_id_e\fP" |
| 142 |
|
| 143 |
.PP |
| 144 |
Predefined memory attribute IDs\&. See \fBhwloc_memattr_id_t\fP for the generic definition of IDs for predefined or custom attributes\&. |
| 145 |
.PP |
| 146 |
\fBEnumerator\fP |
| 147 |
.in +1c |
| 148 |
.TP |
| 149 |
\f(BIHWLOC_MEMATTR_ID_CAPACITY \fP |
| 150 |
The "Capacity" is returned in bytes (local_memory attribute in objects)\&. Best capacity nodes are nodes with \fBhigher capacity\fP\&. |
| 151 |
|
| 152 |
.PP |
| 153 |
No initiator is involved when looking at this attribute\&. The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_HIGHER_FIRST\fP\&. |
| 154 |
|
| 155 |
.PP |
| 156 |
Capacity values may not be modified using \fBhwloc_memattr_set_value()\fP\&. |
| 157 |
.TP |
| 158 |
\f(BIHWLOC_MEMATTR_ID_LOCALITY \fP |
| 159 |
The "Locality" is returned as the number of PUs in that locality (e\&.g\&. the weight of its cpuset)\&. Best locality nodes are nodes with \fBsmaller locality\fP (nodes that are local to very few PUs)\&. Poor locality nodes are nodes with larger locality (nodes that are local to the entire machine)\&. |
| 160 |
|
| 161 |
.PP |
| 162 |
No initiator is involved when looking at this attribute\&. The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_HIGHER_FIRST\fP\&. |
| 163 |
|
| 164 |
.PP |
| 165 |
Locality values may not be modified using \fBhwloc_memattr_set_value()\fP\&. |
| 166 |
.TP |
| 167 |
\f(BIHWLOC_MEMATTR_ID_BANDWIDTH \fP |
| 168 |
The "Bandwidth" is returned in MiB/s, as seen from the given initiator location\&. Best bandwidth nodes are nodes with \fBhigher bandwidth\fP\&. |
| 169 |
|
| 170 |
.PP |
| 171 |
The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_HIGHER_FIRST\fP and \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP\&. |
| 172 |
|
| 173 |
.PP |
| 174 |
This is the average bandwidth for read and write accesses\&. If the platform provides individual read and write bandwidths but no explicit average value, hwloc computes and returns the average\&. |
| 175 |
.TP |
| 176 |
\f(BIHWLOC_MEMATTR_ID_READ_BANDWIDTH \fP |
| 177 |
The "ReadBandwidth" is returned in MiB/s, as seen from the given initiator location\&. Best bandwidth nodes are nodes with \fBhigher bandwidth\fP\&. |
| 178 |
|
| 179 |
.PP |
| 180 |
The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_HIGHER_FIRST\fP and \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP\&. |
| 181 |
.TP |
| 182 |
\f(BIHWLOC_MEMATTR_ID_WRITE_BANDWIDTH \fP |
| 183 |
The "WriteBandwidth" is returned in MiB/s, as seen from the given initiator location\&. Best bandwidth nodes are nodes with \fBhigher bandwidth\fP\&. |
| 184 |
|
| 185 |
.PP |
| 186 |
The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_HIGHER_FIRST\fP and \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP\&. |
| 187 |
.TP |
| 188 |
\f(BIHWLOC_MEMATTR_ID_LATENCY \fP |
| 189 |
The "Latency" is returned as nanoseconds, as seen from the given initiator location\&. Best latency nodes are nodes with \fBsmaller latency\fP\&. |
| 190 |
|
| 191 |
.PP |
| 192 |
The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_LOWER_FIRST\fP and \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP\&. |
| 193 |
|
| 194 |
.PP |
| 195 |
This is the average latency for read and write accesses\&. If the platform provides individual read and write latencies but no explicit average value, hwloc computes and returns the average\&. |
| 196 |
.TP |
| 197 |
\f(BIHWLOC_MEMATTR_ID_READ_LATENCY \fP |
| 198 |
The "ReadLatency" is returned as nanoseconds, as seen from the given initiator location\&. Best latency nodes are nodes with \fBsmaller latency\fP\&. |
| 199 |
|
| 200 |
.PP |
| 201 |
The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_LOWER_FIRST\fP and \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP\&. |
| 202 |
.TP |
| 203 |
\f(BIHWLOC_MEMATTR_ID_WRITE_LATENCY \fP |
| 204 |
The "WriteLatency" is returned as nanoseconds, as seen from the given initiator location\&. Best latency nodes are nodes with \fBsmaller latency\fP\&. |
| 205 |
|
| 206 |
.PP |
| 207 |
The corresponding attribute flags are \fBHWLOC_MEMATTR_FLAG_LOWER_FIRST\fP and \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP\&. |
| 208 |
.SH "Function Documentation" |
| 209 |
.PP |
| 210 |
.SS "int hwloc_get_local_numanode_objs (\fBhwloc_topology_t\fP topology, struct \fBhwloc_location\fP * location, unsigned * nr, \fBhwloc_obj_t\fP * nodes, unsigned long flags)" |
| 211 |
|
| 212 |
.PP |
| 213 |
Return an array of local NUMA nodes\&. By default only select the NUMA nodes whose locality is exactly the given \fRlocation\fP\&. More nodes may be selected if additional flags are given as a OR'ed set of \fBhwloc_local_numanode_flag_e\fP\&. |
| 214 |
|
| 215 |
.PP |
| 216 |
If \fRlocation\fP is given as an explicit object, its CPU set is used to find NUMA nodes with the corresponding locality\&. If the object does not have a CPU set (e\&.g\&. I/O object), the CPU parent (where the I/O object is attached) is used\&. |
| 217 |
|
| 218 |
.PP |
| 219 |
On input, \fRnr\fP points to the number of nodes that may be stored in the \fRnodes\fP array\&. On output, \fRnr\fP will be changed to the number of stored nodes, or the number of nodes that would have been stored if there were enough room\&. |
| 220 |
|
| 221 |
.PP |
| 222 |
\fBReturns\fP |
| 223 |
.RS 4 |
| 224 |
0 on success or -1 on error\&. |
| 225 |
.RE |
| 226 |
.PP |
| 227 |
\fBNote\fP |
| 228 |
.RS 4 |
| 229 |
Some of these NUMA nodes may not have any memory attribute values and hence not be reported as actual targets in other functions\&. |
| 230 |
|
| 231 |
.PP |
| 232 |
The number of NUMA nodes in the topology (obtained by \fBhwloc_bitmap_weight()\fP on the root object nodeset) may be used to allocate the \fRnodes\fP array\&. |
| 233 |
|
| 234 |
.PP |
| 235 |
When an object CPU set is given as locality, for instance a Package, and when flags contain both \fBHWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY\fP and \fBHWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY\fP, the returned array corresponds to the nodeset of that object\&. |
| 236 |
.RE |
| 237 |
.PP |
| 238 |
|
| 239 |
.SS "int hwloc_memattr_get_best_initiator (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, \fBhwloc_obj_t\fP target_node, unsigned long flags, struct \fBhwloc_location\fP * best_initiator, hwloc_uint64_t * value)" |
| 240 |
|
| 241 |
.PP |
| 242 |
Return the best initiator for the given attribute and target NUMA node\&. If \fRvalue\fP is non \fRNULL\fP, the corresponding value is returned there\&. |
| 243 |
|
| 244 |
.PP |
| 245 |
If multiple initiators have the same attribute values, only one is returned (and there is no way to clarify how that one is chosen)\&. Applications that want to detect initiators with identical/similar values, or that want to look at values for multiple attributes, should rather get all values using \fBhwloc_memattr_get_value()\fP and manually select the initiator they consider the best\&. |
| 246 |
|
| 247 |
.PP |
| 248 |
The returned initiator should not be modified or freed, it belongs to the topology\&. |
| 249 |
|
| 250 |
.PP |
| 251 |
\fRtarget_node\fP cannot be \fRNULL\fP\&. |
| 252 |
|
| 253 |
.PP |
| 254 |
\fRflags\fP must be \fR0\fP for now\&. |
| 255 |
|
| 256 |
.PP |
| 257 |
\fBReturns\fP |
| 258 |
.RS 4 |
| 259 |
0 on success\&. |
| 260 |
|
| 261 |
.PP |
| 262 |
-1 with errno set to \fRENOENT\fP if there are no matching initiators\&. |
| 263 |
|
| 264 |
.PP |
| 265 |
-1 with errno set to \fREINVAL\fP if the attribute does not relate to a specific initiator (it does not have the flag \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP)\&. |
| 266 |
.RE |
| 267 |
.PP |
| 268 |
|
| 269 |
.SS "int hwloc_memattr_get_best_target (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, struct \fBhwloc_location\fP * initiator, unsigned long flags, \fBhwloc_obj_t\fP * best_target, hwloc_uint64_t * value)" |
| 270 |
|
| 271 |
.PP |
| 272 |
Return the best target NUMA node for the given attribute and initiator\&. If the attribute does not relate to a specific initiator (it does not have the flag \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP), location \fRinitiator\fP is ignored and may be \fRNULL\fP\&. |
| 273 |
|
| 274 |
.PP |
| 275 |
If \fRvalue\fP is non \fRNULL\fP, the corresponding value is returned there\&. |
| 276 |
|
| 277 |
.PP |
| 278 |
If multiple targets have the same attribute values, only one is returned (and there is no way to clarify how that one is chosen)\&. Applications that want to detect targets with identical/similar values, or that want to look at values for multiple attributes, should rather get all values using \fBhwloc_memattr_get_value()\fP and manually select the target they consider the best\&. |
| 279 |
|
| 280 |
.PP |
| 281 |
\fRflags\fP must be \fR0\fP for now\&. |
| 282 |
|
| 283 |
.PP |
| 284 |
\fBReturns\fP |
| 285 |
.RS 4 |
| 286 |
0 on success\&. |
| 287 |
|
| 288 |
.PP |
| 289 |
-1 with errno set to \fRENOENT\fP if there are no matching targets\&. |
| 290 |
|
| 291 |
.PP |
| 292 |
-1 with errno set to \fREINVAL\fP if flags are invalid, or no such attribute exists\&. |
| 293 |
.RE |
| 294 |
.PP |
| 295 |
\fBNote\fP |
| 296 |
.RS 4 |
| 297 |
The initiator \fRinitiator\fP should be of type \fBHWLOC_LOCATION_TYPE_CPUSET\fP when refering to accesses performed by CPU cores\&. \fBHWLOC_LOCATION_TYPE_OBJECT\fP is currently unused internally by hwloc, but users may for instance use it to provide custom information about host memory accesses performed by GPUs\&. |
| 298 |
.RE |
| 299 |
.PP |
| 300 |
|
| 301 |
.SS "int hwloc_memattr_get_by_name (\fBhwloc_topology_t\fP topology, const char * name, \fBhwloc_memattr_id_t\fP * id)" |
| 302 |
|
| 303 |
.PP |
| 304 |
Return the identifier of the memory attribute with the given name\&. |
| 305 |
.PP |
| 306 |
\fBReturns\fP |
| 307 |
.RS 4 |
| 308 |
0 on success\&. |
| 309 |
|
| 310 |
.PP |
| 311 |
-1 with errno set to \fREINVAL\fP if no such attribute exists\&. |
| 312 |
.RE |
| 313 |
.PP |
| 314 |
|
| 315 |
.SS "int hwloc_memattr_get_initiators (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, \fBhwloc_obj_t\fP target_node, unsigned long flags, unsigned * nr, struct \fBhwloc_location\fP * initiators, hwloc_uint64_t * values)" |
| 316 |
|
| 317 |
.PP |
| 318 |
Return the initiators that have values for a given attribute for a specific target NUMA node\&. Return initiators for the given attribute and target node in the \fRinitiators\fP array\&. If \fRvalues\fP is not \fRNULL\fP, the corresponding attribute values are stored in the array it points to\&. |
| 319 |
|
| 320 |
.PP |
| 321 |
On input, \fRnr\fP points to the number of initiators that may be stored in the array \fRinitiators\fP (and \fRvalues\fP)\&. On output, \fRnr\fP points to the number of initiators (and values) that were actually found, even if some of them couldn't be stored in the array\&. Initiators that couldn't be stored are ignored, but the function still returns success (\fR0\fP)\&. The caller may find out by comparing the value pointed by \fRnr\fP before and after the function call\&. |
| 322 |
|
| 323 |
.PP |
| 324 |
The returned initiators should not be modified or freed, they belong to the topology\&. |
| 325 |
|
| 326 |
.PP |
| 327 |
\fRtarget_node\fP cannot be \fRNULL\fP\&. |
| 328 |
|
| 329 |
.PP |
| 330 |
\fRflags\fP must be \fR0\fP for now\&. |
| 331 |
|
| 332 |
.PP |
| 333 |
If the attribute does not relate to a specific initiator (it does not have the flag \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP), no initiator is returned\&. |
| 334 |
|
| 335 |
.PP |
| 336 |
\fBReturns\fP |
| 337 |
.RS 4 |
| 338 |
0 on success or -1 on error\&. |
| 339 |
.RE |
| 340 |
.PP |
| 341 |
\fBNote\fP |
| 342 |
.RS 4 |
| 343 |
This function is meant for tools and debugging (listing internal information) rather than for application queries\&. Applications should rather select useful NUMA nodes with \fBhwloc_get_local_numanode_objs()\fP and then look at their attribute values for some relevant initiators\&. |
| 344 |
.RE |
| 345 |
.PP |
| 346 |
|
| 347 |
.SS "int hwloc_memattr_get_targets (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, struct \fBhwloc_location\fP * initiator, unsigned long flags, unsigned * nr, \fBhwloc_obj_t\fP * targets, hwloc_uint64_t * values)" |
| 348 |
|
| 349 |
.PP |
| 350 |
Return the target NUMA nodes that have some values for a given attribute\&. Return targets for the given attribute in the \fRtargets\fP array (for the given initiator if any)\&. If \fRvalues\fP is not \fRNULL\fP, the corresponding attribute values are stored in the array it points to\&. |
| 351 |
|
| 352 |
.PP |
| 353 |
On input, \fRnr\fP points to the number of targets that may be stored in the array \fRtargets\fP (and \fRvalues\fP)\&. On output, \fRnr\fP points to the number of targets (and values) that were actually found, even if some of them couldn't be stored in the array\&. Targets that couldn't be stored are ignored, but the function still returns success (\fR0\fP)\&. The caller may find out by comparing the value pointed by \fRnr\fP before and after the function call\&. |
| 354 |
|
| 355 |
.PP |
| 356 |
The returned targets should not be modified or freed, they belong to the topology\&. |
| 357 |
|
| 358 |
.PP |
| 359 |
Argument \fRinitiator\fP is ignored if the attribute does not relate to a specific initiator (it does not have the flag \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP)\&. Otherwise \fRinitiator\fP may be non \fRNULL\fP to report only targets that have a value for that initiator\&. |
| 360 |
|
| 361 |
.PP |
| 362 |
\fRflags\fP must be \fR0\fP for now\&. |
| 363 |
|
| 364 |
.PP |
| 365 |
\fBNote\fP |
| 366 |
.RS 4 |
| 367 |
This function is meant for tools and debugging (listing internal information) rather than for application queries\&. Applications should rather select useful NUMA nodes with \fBhwloc_get_local_numanode_objs()\fP and then look at their attribute values\&. |
| 368 |
.RE |
| 369 |
.PP |
| 370 |
\fBReturns\fP |
| 371 |
.RS 4 |
| 372 |
0 on success or -1 on error\&. |
| 373 |
.RE |
| 374 |
.PP |
| 375 |
\fBNote\fP |
| 376 |
.RS 4 |
| 377 |
The initiator \fRinitiator\fP should be of type \fBHWLOC_LOCATION_TYPE_CPUSET\fP when referring to accesses performed by CPU cores\&. \fBHWLOC_LOCATION_TYPE_OBJECT\fP is currently unused internally by hwloc, but users may for instance use it to provide custom information about host memory accesses performed by GPUs\&. |
| 378 |
.RE |
| 379 |
.PP |
| 380 |
|
| 381 |
.SS "int hwloc_memattr_get_value (\fBhwloc_topology_t\fP topology, \fBhwloc_memattr_id_t\fP attribute, \fBhwloc_obj_t\fP target_node, struct \fBhwloc_location\fP * initiator, unsigned long flags, hwloc_uint64_t * value)" |
| 382 |
|
| 383 |
.PP |
| 384 |
Return an attribute value for a specific target NUMA node\&. If the attribute does not relate to a specific initiator (it does not have the flag \fBHWLOC_MEMATTR_FLAG_NEED_INITIATOR\fP), location \fRinitiator\fP is ignored and may be \fRNULL\fP\&. |
| 385 |
|
| 386 |
.PP |
| 387 |
\fRtarget_node\fP cannot be \fRNULL\fP\&. If \fRattribute\fP is \fBHWLOC_MEMATTR_ID_CAPACITY\fP, \fRtarget_node\fP must be a NUMA node\&. If it is \fBHWLOC_MEMATTR_ID_LOCALITY\fP, \fRtarget_node\fP must have a CPU set\&. |
| 388 |
|
| 389 |
.PP |
| 390 |
\fRflags\fP must be \fR0\fP for now\&. |
| 391 |
|
| 392 |
.PP |
| 393 |
\fBReturns\fP |
| 394 |
.RS 4 |
| 395 |
0 on success\&. |
| 396 |
|
| 397 |
.PP |
| 398 |
-1 on error, for instance with errno set to \fREINVAL\fP if flags are invalid or no such attribute exists\&. |
| 399 |
.RE |
| 400 |
.PP |
| 401 |
\fBNote\fP |
| 402 |
.RS 4 |
| 403 |
The initiator \fRinitiator\fP should be of type \fBHWLOC_LOCATION_TYPE_CPUSET\fP when refering to accesses performed by CPU cores\&. \fBHWLOC_LOCATION_TYPE_OBJECT\fP is currently unused internally by hwloc, but users may for instance use it to provide custom information about host memory accesses performed by GPUs\&. |
| 404 |
.RE |
| 405 |
.PP |
| 406 |
|
| 407 |
.SS "int hwloc_topology_get_default_nodeset (\fBhwloc_topology_t\fP topology, \fBhwloc_nodeset_t\fP nodeset, unsigned long flags)" |
| 408 |
|
| 409 |
.PP |
| 410 |
Return the set of default NUMA nodes\&. In machines with heterogeneous memory, some NUMA nodes are considered the default ones, i\&.e\&. where basic allocations should be made from\&. These are usually DRAM nodes\&. |
| 411 |
|
| 412 |
.PP |
| 413 |
Other nodes may be reserved for specific use (I/O device memory, e\&.g\&. GPU memory), small but high performance (HBM), large but slow memory (NVM), etc\&. Buffers should usually not be allocated from there unless explicitly required\&. |
| 414 |
|
| 415 |
.PP |
| 416 |
This function fills \fRnodeset\fP with the bits of NUMA nodes considered default\&. |
| 417 |
|
| 418 |
.PP |
| 419 |
It is guaranteed that these nodes have non-intersecting CPU sets, i\&.e\&. cores may not have multiple local NUMA nodes anymore\&. Hence this may be used to iterate over the platform divided into separate NUMA localities, for instance for binding one task per NUMA domain\&. |
| 420 |
|
| 421 |
.PP |
| 422 |
Any core that had some local NUMA node(s) in the initial topology should still have one in the default nodeset\&. Corner cases where this would be wrong consist in asymmetric platforms with missing DRAM nodes, or topologies that were already restricted to less NUMA nodes\&. |
| 423 |
|
| 424 |
.PP |
| 425 |
The returned nodeset may be passed to \fBhwloc_topology_restrict()\fP with \fBHWLOC_RESTRICT_FLAG_BYNODESET\fP to remove all non-default nodes from the topology\&. The resulting topology will be easier to use when iterating over (now homogeneous) NUMA nodes\&. |
| 426 |
|
| 427 |
.PP |
| 428 |
The heuristics for finding default nodes relies on memory tiers and subtypes (see \fBHeterogeneous Memory\fP) as well as the assumption that hardware vendors list default nodes first in hardware tables\&. |
| 429 |
|
| 430 |
.PP |
| 431 |
\fRflags\fP must be \fR0\fP for now\&. |
| 432 |
|
| 433 |
.PP |
| 434 |
\fBReturns\fP |
| 435 |
.RS 4 |
| 436 |
0 on success\&. |
| 437 |
|
| 438 |
.PP |
| 439 |
-1 on error\&. |
| 440 |
.RE |
| 441 |
.PP |
| 442 |
\fBNote\fP |
| 443 |
.RS 4 |
| 444 |
The returned nodeset usually contains all nodes from a single memory tier, likely the DRAM one\&. |
| 445 |
|
| 446 |
.PP |
| 447 |
The returned nodeset is included in the list of available nodes returned by \fBhwloc_topology_get_topology_nodeset()\fP\&. It is strictly smaller if the machine has heterogeneous memory\&. |
| 448 |
|
| 449 |
.PP |
| 450 |
The heuristics may return a suboptimal set of nodes if hwloc could not guess memory types and/or if some default nodes were removed earlier from the topology (e\&.g\&. with \fBhwloc_topology_restrict()\fP)\&. |
| 451 |
.RE |
| 452 |
.PP |
| 453 |
|
| 454 |
.SH "Author" |
| 455 |
.PP |
| 456 |
Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code\&. |