Hardware Locality (hwloc)  master-20230831.0905.git364652f8b
Enumerations | Functions
Converting between Object Types and Attributes, and Strings

Enumerations

enum  hwloc_obj_snprintf_flag_e {
  HWLOC_OBJ_SNPRINTF_FLAG_LONG_NAMES, HWLOC_OBJ_SNPRINTF_FLAG_MORE_ATTRS, HWLOC_OBJ_SNPRINTF_FLAG_NO_UNITS, HWLOC_OBJ_SNPRINTF_FLAG_UNITS_1000,
  HWLOC_OBJ_SNPRINTF_FLAG_OLD_VERBOSE
}
 

Functions

const char * hwloc_obj_type_string (hwloc_obj_type_t type)
 
int hwloc_obj_type_snprintf (char *restrict string, size_t size, hwloc_obj_t obj, unsigned long flags)
 
int hwloc_obj_attr_snprintf (char *restrict string, size_t size, hwloc_obj_t obj, const char *restrict separator, unsigned long flags)
 
int hwloc_type_sscanf (const char *string, hwloc_obj_type_t *typep, union hwloc_obj_attr_u *attrp, size_t attrsize)
 

Detailed Description

Enumeration Type Documentation

◆ hwloc_obj_snprintf_flag_e

Flags to be given to hwloc_obj_type_snprintf() and hwloc_obj_attr_snprintf().

Enumerator
HWLOC_OBJ_SNPRINTF_FLAG_LONG_NAMES 

Use long type names such as L2Cache instead of L2.

HWLOC_OBJ_SNPRINTF_FLAG_MORE_ATTRS 

Display additional attributes such as cache associativity, PCI link speed, and total memory.

HWLOC_OBJ_SNPRINTF_FLAG_NO_UNITS 

Display memory sizes in bytes without units.

HWLOC_OBJ_SNPRINTF_FLAG_UNITS_1000 

Display memory sizes in KB, MB, GB, etc i.e. divide by 1000 instead of 1024 for KiB, MiB, GiB, etc.

HWLOC_OBJ_SNPRINTF_FLAG_OLD_VERBOSE 

Backward compatibility with hwloc 2.x verbose mode, shows additional attributes, and memory sizes with KB unit but KiB values.

Function Documentation

◆ hwloc_obj_attr_snprintf()

int hwloc_obj_attr_snprintf ( char *restrict  string,
size_t  size,
hwloc_obj_t  obj,
const char *restrict  separator,
unsigned long  flags 
)

Stringify the attributes of a given topology object into a human-readable form.

Attribute values are separated by separator.

Only the major attributes are printed in non-verbose mode.

If size is 0, string may safely be NULL.

Flags flags is a OR'ed set of hwloc_obj_snprintf_flag_e. By default, only important attributes such as memory and cache sizes are shown. Sizes are reported in units such as GiB or KiB.

Returns
the number of characters that were actually written if not truncating, or that would have been written (not including the ending \0).

◆ hwloc_obj_type_snprintf()

int hwloc_obj_type_snprintf ( char *restrict  string,
size_t  size,
hwloc_obj_t  obj,
unsigned long  flags 
)

Stringify the type of a given topology object into a human-readable form.

Contrary to hwloc_obj_type_string(), this function includes object-specific attributes (such as the Group depth, the Bridge type, or OS device type) in the output, and it requires the caller to provide the output buffer.

The output is guaranteed to be the same for all objects of a same topology level.

The output string may be parsed back by hwloc_type_sscanf().

If size is 0, string may safely be NULL.

Flags flags is a OR'ed set of hwloc_obj_snprintf_flag_e. By default, short names are used.

Returns
the number of characters that were actually written if not truncating, or that would have been written (not including the ending \0).

◆ hwloc_obj_type_string()

const char* hwloc_obj_type_string ( hwloc_obj_type_t  type)

Return a constant stringified object type.

This function is the basic way to convert a generic type into a string. The output string may be parsed back by hwloc_type_sscanf().

hwloc_obj_type_snprintf() may return a more precise output for a specific object, but it requires the caller to provide the output buffer.

Returns
A constant string containing the object type name or "Unknown".

◆ hwloc_type_sscanf()

int hwloc_type_sscanf ( const char *  string,
hwloc_obj_type_t typep,
union hwloc_obj_attr_u attrp,
size_t  attrsize 
)

Return an object type and attributes from a type string.

Convert strings such as "Package" or "L1iCache" into the corresponding types. Matching is case-insensitive, and only the first letters are actually required to match.

The matched object type is set in typep (which cannot be NULL).

Type-specific attributes, for instance Cache type, Cache depth, Group depth, Bridge type or OS Device type may be returned in attrp. Attributes that are not specified in the string (for instance "Group" without a depth, or "L2Cache" without a cache type) are set to -1.

attrp is only filled if not NULL and if its size specified in attrsize is large enough. It should be at least as large as union hwloc_obj_attr_u.

Returns
0 if a type was correctly identified, otherwise -1.
Note
This function is guaranteed to match any string returned by hwloc_obj_type_string() or hwloc_obj_type_snprintf().