---
name: "hwloc_memattr_set_value"
section: "3"
platform: "linux"
package: "hwloc"
version: "2.15.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_memattrs_manage"
---

# hwloc\_memattr\_set\_value(3)

Managing memory attributes

Part of [hwlocality\_memattrs\_manage(3)](/hwlocality_memattrs_manage/3.md).

## NAME

hwlocality\_memattrs\_manage - Managing memory attributes

## SYNOPSIS

### Enumerations

enum **hwloc\_memattr\_flag\_e** { **HWLOC\_MEMATTR\_FLAG\_HIGHER\_FIRST** = (1UL\<\<0), **HWLOC\_MEMATTR\_FLAG\_LOWER\_FIRST** = (1UL\<\<1), **HWLOC\_MEMATTR\_FLAG\_NEED\_INITIATOR** = (1UL\<\<2) }\

### Functions

int **hwloc\_memattr\_get\_name** (**hwloc\_topology\_t** topology, **hwloc\_memattr\_id\_t** attribute, const char \*\*name)\
 int **hwloc\_memattr\_get\_flags** (**hwloc\_topology\_t** topology, **hwloc\_memattr\_id\_t** attribute, unsigned long \*flags)\
 int **hwloc\_memattr\_register** (**hwloc\_topology\_t** topology, const char \*name, unsigned long flags, **hwloc\_memattr\_id\_t** \*id)\
 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)\

## Detailed Description

Memory attribues are identified by an ID (**hwloc\_memattr\_id\_t**) and a name. **hwloc\_memattr\_get\_name()** and **hwloc\_memattr\_get\_by\_name()** convert between them (or return error if the attribute does not exist).

The set of valid **hwloc\_memattr\_id\_t** is a contigous set starting at 0. It first contains predefined attributes, as listed in **hwloc\_memattr\_id\_e** (from 0 to HWLOC\_MEMATTR\_ID\_MAX-1). Then custom attributes may be dynamically registered with **hwloc\_memattr\_register()**. They will get the following IDs (HWLOC\_MEMATTR\_ID\_MAX for the first one, etc.).

To iterate over all valid attributes (either predefined or dynamically registered custom ones), one may iterate over IDs starting from 0 until **hwloc\_memattr\_get\_name()** or **hwloc\_memattr\_get\_flags()** returns an error.

The values for an existing attribute or for custom dynamically registered ones may be set or modified with **hwloc\_memattr\_set\_value()**.

## Enumeration Type Documentation

### enum hwloc\_memattr\_flag\_e

Memory attribute flags. Given to **hwloc\_memattr\_register()** and returned by **hwloc\_memattr\_get\_flags()**.

**Enumerator**

- ***HWLOC\_MEMATTR\_FLAG\_HIGHER\_FIRST***

  The best nodes for this memory attribute are those with the higher values. For instance Bandwidth.

- ***HWLOC\_MEMATTR\_FLAG\_LOWER\_FIRST***

  The best nodes for this memory attribute are those with the lower values. For instance Latency.

- ***HWLOC\_MEMATTR\_FLAG\_NEED\_INITIATOR***

  The value returned for this memory attribute depends on the given initiator. For instance Bandwidth and Latency, but not Capacity.

## Function Documentation

### int hwloc\_memattr\_get\_flags (hwloc\_topology\_t topology, hwloc\_memattr\_id\_t attribute, unsigned long \* flags)

Return the flags of the given attribute. Flags are a OR'ed set of **hwloc\_memattr\_flag\_e**.

The output pointer flags cannot be NULL.

**Returns**

0 on success.

\-1 with errno set to EINVAL if the attribute does not exist.

### int hwloc\_memattr\_get\_name (hwloc\_topology\_t topology, hwloc\_memattr\_id\_t attribute, const char \*\* name)

Return the name of a memory attribute. The output pointer name cannot be NULL.

**Returns**

0 on success.

\-1 with errno set to EINVAL if the attribute does not exist.

### int hwloc\_memattr\_register (hwloc\_topology\_t topology, const char \* name, unsigned long flags, hwloc\_memattr\_id\_t \* id)

Register a new memory attribute. Add a new custom memory attribute. Flags are a OR'ed set of **hwloc\_memattr\_flag\_e**. It must contain one of **HWLOC\_MEMATTR\_FLAG\_HIGHER\_FIRST** or **HWLOC\_MEMATTR\_FLAG\_LOWER\_FIRST** but not both.

The new attribute id is immediately after the last existing attribute ID (which is either the ID of the last registered attribute if any, or the ID of the last predefined attribute in **hwloc\_memattr\_id\_e**).

**Returns**

0 on success.

\-1 with errno set to EINVAL if an invalid set of flags is given.

\-1 with errno set to EBUSY if another attribute already uses this name.

### 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. If the attribute does not relate to a specific initiator (it does not have the flag **HWLOC\_MEMATTR\_FLAG\_NEED\_INITIATOR**), location initiator is ignored and may be NULL.

The initiator will be copied into the topology, the caller should free anything allocated to store the initiator, for instance the cpuset.

target\_node cannot be NULL.

attribute cannot be **HWLOC\_MEMATTR\_ID\_CAPACITY** or **HWLOC\_MEMATTR\_ID\_LOCALITY**.

flags must be 0 for now.

**Note**

The initiator initiator should be of type **HWLOC\_LOCATION\_TYPE\_CPUSET** when referring to accesses performed by CPU cores. **HWLOC\_LOCATION\_TYPE\_OBJECT** is currently unused internally by hwloc, but users may for instance use it to provide custom information about host memory accesses performed by GPUs.

**Returns**

0 on success or -1 on error.

## Author

Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
