Skip to content

Commit 3dbc02d

Browse files
committed
hwloc/memattrs.h: improve doc about return values
Refs #578 Signed-off-by: Brice Goglin <[email protected]>
1 parent 87c7992 commit 3dbc02d

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

include/hwloc/memattrs.h

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2019-2022 Inria. All rights reserved.
2+
* Copyright © 2019-2023 Inria. All rights reserved.
33
* See COPYING in top-level directory.
44
*/
55

@@ -178,6 +178,9 @@ enum hwloc_memattr_id_e {
178178
typedef unsigned hwloc_memattr_id_t;
179179

180180
/** \brief Return the identifier of the memory attribute with the given name.
181+
*
182+
* \return 0 on success.
183+
* \return -1 with errno set to \c EINVAL if no such attribute exists.
181184
*/
182185
HWLOC_DECLSPEC int
183186
hwloc_memattr_get_by_name(hwloc_topology_t topology,
@@ -247,6 +250,8 @@ enum hwloc_local_numanode_flag_e {
247250
* or the number of nodes that would have been stored if there were
248251
* enough room.
249252
*
253+
* \return 0 on success or -1 on error.
254+
*
250255
* \note Some of these NUMA nodes may not have any memory attribute
251256
* values and hence not be reported as actual targets in other functions.
252257
*
@@ -276,6 +281,10 @@ hwloc_get_local_numanode_objs(hwloc_topology_t topology,
276281
*
277282
* \p flags must be \c 0 for now.
278283
*
284+
* \return 0 on success.
285+
* \return -1 on error, for instance with errno set to \c EINVAL if flags
286+
* are invalid or no such attribute exists.
287+
*
279288
* \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
280289
* when refering to accesses performed by CPU cores.
281290
* ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
@@ -307,7 +316,10 @@ hwloc_memattr_get_value(hwloc_topology_t topology,
307316
*
308317
* \p flags must be \c 0 for now.
309318
*
310-
* If there are no matching targets, \c -1 is returned with \p errno set to \c ENOENT;
319+
* \return 0 on success.
320+
* \return -1 with errno set to \c ENOENT if there are no matching targets.
321+
* \return -1 with errno set to \c EINVAL if flags are invalid,
322+
* or no such attribute exists.
311323
*
312324
* \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
313325
* when refering to accesses performed by CPU cores.
@@ -323,10 +335,6 @@ hwloc_memattr_get_best_target(hwloc_topology_t topology,
323335
hwloc_obj_t *best_target, hwloc_uint64_t *value);
324336

325337
/** \brief Return the best initiator for the given attribute and target NUMA node.
326-
*
327-
* If the attribute does not relate to a specific initiator
328-
* (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
329-
* \c -1 is returned and \p errno is set to \c EINVAL.
330338
*
331339
* If \p value is non \c NULL, the corresponding value is returned there.
332340
*
@@ -342,7 +350,10 @@ hwloc_memattr_get_best_target(hwloc_topology_t topology,
342350
*
343351
* \p flags must be \c 0 for now.
344352
*
345-
* If there are no matching initiators, \c -1 is returned with \p errno set to \c ENOENT;
353+
* \return 0 on success.
354+
* \return -1 with errno set to \c ENOENT if there are no matching initiators.
355+
* \return -1 with errno set to \c EINVAL if the attribute does not relate to a specific initiator
356+
* (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR).
346357
*/
347358
HWLOC_DECLSPEC int
348359
hwloc_memattr_get_best_initiator(hwloc_topology_t topology,
@@ -359,6 +370,9 @@ hwloc_memattr_get_best_initiator(hwloc_topology_t topology,
359370
*/
360371

361372
/** \brief Return the name of a memory attribute.
373+
*
374+
* \return 0 on success.
375+
* \return -1 with errno set to \c EINVAL if the attribute does not exist.
362376
*/
363377
HWLOC_DECLSPEC int
364378
hwloc_memattr_get_name(hwloc_topology_t topology,
@@ -368,6 +382,9 @@ hwloc_memattr_get_name(hwloc_topology_t topology,
368382
/** \brief Return the flags of the given attribute.
369383
*
370384
* Flags are a OR'ed set of ::hwloc_memattr_flag_e.
385+
*
386+
* \return 0 on success.
387+
* \return -1 with errno set to \c EINVAL if the attribute does not exist.
371388
*/
372389
HWLOC_DECLSPEC int
373390
hwloc_memattr_get_flags(hwloc_topology_t topology,
@@ -397,6 +414,9 @@ enum hwloc_memattr_flag_e {
397414
* Add a specific memory attribute that is not defined in ::hwloc_memattr_id_e.
398415
* Flags are a OR'ed set of ::hwloc_memattr_flag_e. It must contain at least
399416
* one of ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST or ::HWLOC_MEMATTR_FLAG_LOWER_FIRST.
417+
*
418+
* \return 0 on success.
419+
* \return -1 with errno set to \c EBUSY if another attribute already uses this name.
400420
*/
401421
HWLOC_DECLSPEC int
402422
hwloc_memattr_register(hwloc_topology_t topology,
@@ -421,6 +441,8 @@ hwloc_memattr_register(hwloc_topology_t topology,
421441
* ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
422442
* but users may for instance use it to provide custom information about
423443
* host memory accesses performed by GPUs.
444+
*
445+
* \return 0 on success or -1 on error.
424446
*/
425447
HWLOC_DECLSPEC int
426448
hwloc_memattr_set_value(hwloc_topology_t topology,
@@ -460,6 +482,8 @@ hwloc_memattr_set_value(hwloc_topology_t topology,
460482
* NUMA nodes with hwloc_get_local_numanode_objs() and then look at their attribute
461483
* values.
462484
*
485+
* \return 0 on success or -1 on error.
486+
*
463487
* \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
464488
* when referring to accesses performed by CPU cores.
465489
* ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
@@ -497,6 +521,8 @@ hwloc_memattr_get_targets(hwloc_topology_t topology,
497521
* (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
498522
* no initiator is returned.
499523
*
524+
* \return 0 on success or -1 on error.
525+
*
500526
* \note This function is meant for tools and debugging (listing internal information)
501527
* rather than for application queries. Applications should rather select useful
502528
* NUMA nodes with hwloc_get_local_numanode_objs() and then look at their attribute

0 commit comments

Comments
 (0)