Hardware Locality (hwloc)  2.0.0
hwloc.h
1 /*
2  * Copyright © 2009 CNRS
3  * Copyright © 2009-2018 Inria. All rights reserved.
4  * Copyright © 2009-2012 Université Bordeaux
5  * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
6  * See COPYING in top-level directory.
7  */
8 
9 /*=====================================================================
10  * PLEASE GO READ THE DOCUMENTATION!
11  * ------------------------------------------------
12  * $tarball_directory/doc/doxygen-doc/
13  * or
14  * http://www.open-mpi.org/projects/hwloc/doc/
15  *=====================================================================
16  *
17  * FAIR WARNING: Do NOT expect to be able to figure out all the
18  * subtleties of hwloc by simply reading function prototypes and
19  * constant descrptions here in this file.
20  *
21  * Hwloc has wonderful documentation in both PDF and HTML formats for
22  * your reading pleasure. The formal documentation explains a LOT of
23  * hwloc-specific concepts, provides definitions, and discusses the
24  * "big picture" for many of the things that you'll find here in this
25  * header file.
26  *
27  * The PDF/HTML documentation was generated via Doxygen; much of what
28  * you'll see in there is also here in this file. BUT THERE IS A LOT
29  * THAT IS IN THE PDF/HTML THAT IS ***NOT*** IN hwloc.h!
30  *
31  * There are entire paragraph-length descriptions, discussions, and
32  * pretty prictures to explain subtle corner cases, provide concrete
33  * examples, etc.
34  *
35  * Please, go read the documentation. :-)
36  *
37  * Moreover there are several examples of hwloc use under doc/examples
38  * in the source tree.
39  *
40  *=====================================================================*/
41 
53 #ifndef HWLOC_H
54 #define HWLOC_H
55 
56 #include <hwloc/autogen/config.h>
57 #include <sys/types.h>
58 #include <stdio.h>
59 #include <string.h>
60 #include <limits.h>
61 
62 /*
63  * Symbol transforms
64  */
65 #include <hwloc/rename.h>
66 
67 /*
68  * Bitmap definitions
69  */
70 
71 #include <hwloc/bitmap.h>
72 
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 
91 #define HWLOC_API_VERSION 0x00020000
92 
97 HWLOC_DECLSPEC unsigned hwloc_get_api_version(void);
98 
100 #define HWLOC_COMPONENT_ABI 5
101 
138 
156 
171 #define HWLOC_OBJ_TYPE_MIN HWLOC_OBJ_MACHINE
172 typedef enum {
272  HWLOC_OBJ_TYPE_MAX
274 
281 
287 
307 
327 HWLOC_DECLSPEC int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2) __hwloc_attribute_const;
328 
331 };
332 
341 union hwloc_obj_attr_u;
342 
347 struct hwloc_obj {
348  /* physical information */
350  char *subtype;
352  unsigned os_index;
357 #define HWLOC_UNKNOWN_INDEX (unsigned)-1
358 
359  char *name;
364  hwloc_uint64_t total_memory;
369  /* global position */
370  int depth;
385  unsigned logical_index;
392  /* cousins are all objects of the same type (and depth) across the entire topology */
396  /* children of the same parent are siblings, even if they may have different type and depth */
397  struct hwloc_obj *parent;
398  unsigned sibling_rank;
403  unsigned arity;
407  struct hwloc_obj **children;
423  unsigned memory_arity;
435  unsigned io_arity;
447  unsigned misc_arity;
456  /* cpusets and nodesets */
521  struct hwloc_info_s *infos;
522  unsigned infos_count;
524  /* misc */
525  void *userdata;
530  hwloc_uint64_t gp_index;
535 };
539 typedef struct hwloc_obj * hwloc_obj_t;
540 
545  hwloc_uint64_t local_memory;
546  unsigned page_types_len;
553  hwloc_uint64_t size;
554  hwloc_uint64_t count;
555  } * page_types;
556  } numanode;
557 
560  hwloc_uint64_t size;
561  unsigned depth;
562  unsigned linesize;
566  } cache;
569  unsigned depth;
571  unsigned kind;
572  unsigned subkind;
573  } group;
576  unsigned short domain;
577  unsigned char bus, dev, func;
578  unsigned short class_id;
579  unsigned short vendor_id, device_id, subvendor_id, subdevice_id;
580  unsigned char revision;
581  float linkspeed; /* in GB/s */
582  } pcidev;
585  union {
587  } upstream;
589  union {
590  struct {
591  unsigned short domain;
592  unsigned char secondary_bus, subordinate_bus;
593  } pci;
594  } downstream;
596  unsigned depth;
597  } bridge;
601  } osdev;
602 };
603 
608 struct hwloc_info_s {
609  char *name;
610  char *value;
611 };
612 
621 struct hwloc_topology;
626 typedef struct hwloc_topology * hwloc_topology_t;
627 
634 HWLOC_DECLSPEC int hwloc_topology_init (hwloc_topology_t *topologyp);
635 
656 HWLOC_DECLSPEC int hwloc_topology_load(hwloc_topology_t topology);
657 
662 HWLOC_DECLSPEC void hwloc_topology_destroy (hwloc_topology_t topology);
663 
674 HWLOC_DECLSPEC int hwloc_topology_dup(hwloc_topology_t *newtopology, hwloc_topology_t oldtopology);
675 
693 HWLOC_DECLSPEC int hwloc_topology_abi_check(hwloc_topology_t topology);
694 
706 HWLOC_DECLSPEC void hwloc_topology_check(hwloc_topology_t topology);
707 
728 HWLOC_DECLSPEC int hwloc_topology_get_depth(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
729 
753 HWLOC_DECLSPEC int hwloc_get_type_depth (hwloc_topology_t topology, hwloc_obj_type_t type);
754 
763 };
764 
784 HWLOC_DECLSPEC int hwloc_get_memory_parents_depth (hwloc_topology_t topology);
785 
795 static __hwloc_inline int
796 hwloc_get_type_or_below_depth (hwloc_topology_t topology, hwloc_obj_type_t type) __hwloc_attribute_pure;
797 
807 static __hwloc_inline int
808 hwloc_get_type_or_above_depth (hwloc_topology_t topology, hwloc_obj_type_t type) __hwloc_attribute_pure;
809 
816 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_get_depth_type (hwloc_topology_t topology, int depth) __hwloc_attribute_pure;
817 
820 HWLOC_DECLSPEC unsigned hwloc_get_nbobjs_by_depth (hwloc_topology_t topology, int depth) __hwloc_attribute_pure;
821 
827 static __hwloc_inline int
828 hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type) __hwloc_attribute_pure;
829 
834 static __hwloc_inline hwloc_obj_t
835 hwloc_get_root_obj (hwloc_topology_t topology) __hwloc_attribute_pure;
836 
838 HWLOC_DECLSPEC hwloc_obj_t hwloc_get_obj_by_depth (hwloc_topology_t topology, int depth, unsigned idx) __hwloc_attribute_pure;
839 
846 static __hwloc_inline hwloc_obj_t
847 hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx) __hwloc_attribute_pure;
848 
853 static __hwloc_inline hwloc_obj_t
854 hwloc_get_next_obj_by_depth (hwloc_topology_t topology, int depth, hwloc_obj_t prev);
855 
862 static __hwloc_inline hwloc_obj_t
864  hwloc_obj_t prev);
865 
882 HWLOC_DECLSPEC const char * hwloc_obj_type_string (hwloc_obj_type_t type) __hwloc_attribute_const;
883 
901 HWLOC_DECLSPEC int hwloc_obj_type_snprintf(char * __hwloc_restrict string, size_t size,
902  hwloc_obj_t obj,
903  int verbose);
904 
916 HWLOC_DECLSPEC int hwloc_obj_attr_snprintf(char * __hwloc_restrict string, size_t size,
917  hwloc_obj_t obj, const char * __hwloc_restrict separator,
918  int verbose);
919 
943 HWLOC_DECLSPEC int hwloc_type_sscanf(const char *string,
944  hwloc_obj_type_t *typep,
945  union hwloc_obj_attr_u *attrp, size_t attrsize);
946 
968 HWLOC_DECLSPEC int hwloc_type_sscanf_as_depth(const char *string,
969  hwloc_obj_type_t *typep,
970  hwloc_topology_t topology, int *depthp);
971 
987 static __hwloc_inline const char *
988 hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name) __hwloc_attribute_pure;
989 
1006 HWLOC_DECLSPEC int hwloc_obj_add_info(hwloc_obj_t obj, const char *name, const char *value);
1007 
1076 typedef enum {
1080 
1084 
1109 
1127 
1133 HWLOC_DECLSPEC int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
1134 
1140 HWLOC_DECLSPEC int hwloc_get_cpubind(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
1141 
1153 HWLOC_DECLSPEC int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags);
1154 
1166 HWLOC_DECLSPEC int hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
1167 
1168 #ifdef hwloc_thread_t
1169 
1176 HWLOC_DECLSPEC int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t thread, hwloc_const_cpuset_t set, int flags);
1177 #endif
1178 
1179 #ifdef hwloc_thread_t
1180 
1187 HWLOC_DECLSPEC int hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t thread, hwloc_cpuset_t set, int flags);
1188 #endif
1189 
1203 HWLOC_DECLSPEC int hwloc_get_last_cpu_location(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
1204 
1221 HWLOC_DECLSPEC int hwloc_get_proc_last_cpu_location(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
1222 
1302 typedef enum {
1311 
1322 
1326 
1335 
1342 
1351 
1365 typedef enum {
1371 
1376 
1384 
1390 
1403 
1415 
1431 HWLOC_DECLSPEC int hwloc_set_membind(hwloc_topology_t topology, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags);
1432 
1477 HWLOC_DECLSPEC int hwloc_get_membind(hwloc_topology_t topology, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags);
1478 
1491 HWLOC_DECLSPEC int hwloc_set_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags);
1492 
1532 HWLOC_DECLSPEC int hwloc_get_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags);
1533 
1544 HWLOC_DECLSPEC int hwloc_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags);
1545 
1573 HWLOC_DECLSPEC int hwloc_get_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags);
1574 
1594 HWLOC_DECLSPEC int hwloc_get_area_memlocation(hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, int flags);
1595 
1603 HWLOC_DECLSPEC void *hwloc_alloc(hwloc_topology_t topology, size_t len);
1604 
1619 HWLOC_DECLSPEC void *hwloc_alloc_membind(hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc;
1620 
1630 static __hwloc_inline void *
1631 hwloc_alloc_membind_policy(hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc;
1632 
1636 HWLOC_DECLSPEC int hwloc_free(hwloc_topology_t topology, void *addr, size_t len);
1637 
1674 HWLOC_DECLSPEC int hwloc_topology_set_pid(hwloc_topology_t __hwloc_restrict topology, hwloc_pid_t pid);
1675 
1704 HWLOC_DECLSPEC int hwloc_topology_set_synthetic(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict description);
1705 
1732 HWLOC_DECLSPEC int hwloc_topology_set_xml(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict xmlpath);
1733 
1760 HWLOC_DECLSPEC int hwloc_topology_set_xmlbuffer(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict buffer, int size);
1761 
1803 
1823 
1844 };
1845 
1855 HWLOC_DECLSPEC int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
1856 
1863 HWLOC_DECLSPEC unsigned long hwloc_topology_get_flags (hwloc_topology_t topology);
1864 
1872 HWLOC_DECLSPEC int hwloc_topology_is_thissystem(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
1873 
1877  unsigned char pu;
1879  unsigned char numa;
1881  unsigned char numa_memory;
1882 };
1883 
1891  unsigned char set_thisproc_cpubind;
1893  unsigned char get_thisproc_cpubind;
1895  unsigned char set_proc_cpubind;
1897  unsigned char get_proc_cpubind;
1899  unsigned char set_thisthread_cpubind;
1901  unsigned char get_thisthread_cpubind;
1903  unsigned char set_thread_cpubind;
1905  unsigned char get_thread_cpubind;
1912 };
1913 
1921  unsigned char set_thisproc_membind;
1923  unsigned char get_thisproc_membind;
1925  unsigned char set_proc_membind;
1927  unsigned char get_proc_membind;
1929  unsigned char set_thisthread_membind;
1931  unsigned char get_thisthread_membind;
1933  unsigned char set_area_membind;
1935  unsigned char get_area_membind;
1937  unsigned char alloc_membind;
1939  unsigned char firsttouch_membind;
1941  unsigned char bind_membind;
1943  unsigned char interleave_membind;
1945  unsigned char nexttouch_membind;
1947  unsigned char migrate_membind;
1949  unsigned char get_area_memlocation;
1950 };
1951 
1962 };
1963 
1973 HWLOC_DECLSPEC const struct hwloc_topology_support *hwloc_topology_get_support(hwloc_topology_t __hwloc_restrict topology);
1974 
1991 
1999 
2013 
2028 };
2029 
2033 
2037 
2042 HWLOC_DECLSPEC int hwloc_topology_set_all_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter);
2043 
2046 HWLOC_DECLSPEC int hwloc_topology_set_cache_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter);
2047 
2050 HWLOC_DECLSPEC int hwloc_topology_set_icache_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter);
2051 
2054 HWLOC_DECLSPEC int hwloc_topology_set_io_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter);
2055 
2066 HWLOC_DECLSPEC void hwloc_topology_set_userdata(hwloc_topology_t topology, const void *userdata);
2067 
2073 HWLOC_DECLSPEC void * hwloc_topology_get_userdata(hwloc_topology_t topology);
2074 
2090 
2096 
2102 };
2103 
2125 HWLOC_DECLSPEC int hwloc_topology_restrict(hwloc_topology_t __hwloc_restrict topology, hwloc_const_cpuset_t cpuset, unsigned long flags);
2126 
2148 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object(hwloc_topology_t topology, hwloc_obj_t parent, const char *name);
2149 
2170 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_alloc_group_object(hwloc_topology_t topology);
2171 
2205 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_group_object(hwloc_topology_t topology, hwloc_obj_t group);
2206 
2216 HWLOC_DECLSPEC int hwloc_obj_add_other_obj_sets(hwloc_obj_t dst, hwloc_obj_t src);
2217 
2222 #ifdef __cplusplus
2223 } /* extern "C" */
2224 #endif
2225 
2226 
2227 /* high-level helpers */
2228 #include <hwloc/helper.h>
2229 
2230 /* inline code of some functions above */
2231 #include <hwloc/inlines.h>
2232 
2233 /* exporting to XML or synthetic */
2234 #include <hwloc/export.h>
2235 
2236 /* distances */
2237 #include <hwloc/distances.h>
2238 
2239 /* topology diffs */
2240 #include <hwloc/diff.h>
2241 
2242 /* deprecated headers */
2243 #include <hwloc/deprecated.h>
2244 
2245 #endif /* HWLOC_H */
int hwloc_obj_add_info(hwloc_obj_t obj, const char *name, const char *value)
Add the given info name and value pair to the given object.
const char * hwloc_obj_type_string(hwloc_obj_type_t type)
Return a constant stringified object type.
struct hwloc_obj * parent
Parent, NULL if root (Machine object)
Definition: hwloc.h:397
static int hwloc_get_nbobjs_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the width of level type type.
Move Misc objects to ancestors if their parents are removed during restriction. If this flag is not s...
Definition: hwloc.h:2095
Operating system network device. For instance the "eth0" interface on Linux.
Definition: hwloc.h:295
unsigned char get_area_membind
Definition: hwloc.h:1935
unsigned char func
Definition: hwloc.h:577
struct hwloc_obj * prev_sibling
Previous object below the same parent (inside the same list of children).
Definition: hwloc.h:400
unsigned io_arity
Number of I/O children. These children are listed in io_first_child.
Definition: hwloc.h:435
Returned by get_membind() functions when multiple threads or parts of a memory area have differing me...
Definition: hwloc.h:1349
unsigned memory_arity
Number of Memory children. These children are listed in memory_first_child.
Definition: hwloc.h:423
unsigned long hwloc_topology_get_flags(hwloc_topology_t topology)
Get OR&#39;ed flags of a topology.
Object type-specific Attributes.
Definition: hwloc.h:542
int hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags)
Get the current physical binding of process pid.
int hwloc_topology_load(hwloc_topology_t topology)
Build the actual topology.
int hwloc_get_cpubind(hwloc_topology_t topology, hwloc_cpuset_t set, int flags)
Get current process or thread binding.
Flags describing actual PU binding support for this topology.
Definition: hwloc.h:1889
Level 4 Data (or Unified) Cache.
Definition: hwloc.h:200
Operating system co-processor device. For instance "mic0" for a Xeon Phi (MIC) on Linux...
Definition: hwloc.h:302
unsigned char get_area_memlocation
Definition: hwloc.h:1949
static int hwloc_get_type_or_below_depth(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the depth of objects of type type or below.
int hwloc_topology_set_icache_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter)
Set the filtering for all instruction cache object types.
hwloc_uint64_t total_memory
Total memory (in bytes) in NUMA nodes below this object.
Definition: hwloc.h:364
PCI-side of a bridge.
Definition: hwloc.h:285
Value returned by hwloc_compare_types() when types can not be compared.
Definition: hwloc.h:330
struct hwloc_topology_discovery_support * discovery
Definition: hwloc.h:1959
struct hwloc_topology_cpubind_support * cpubind
Definition: hwloc.h:1960
Move I/O objects to ancestors if their parents are removed during restriction. If this flag is not se...
Definition: hwloc.h:2101
int hwloc_get_memory_parents_depth(hwloc_topology_t topology)
Return the depth of parents where memory objects are attached.
void hwloc_topology_check(hwloc_topology_t topology)
Run internal checks on a topology structure.
unsigned char get_proc_last_cpu_location
Definition: hwloc.h:1909
int hwloc_topology_set_synthetic(hwloc_topology_t restrict topology, const char *restrict description)
Enable synthetic topology.
static void * hwloc_alloc_membind_policy(hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
Allocate some memory on NUMA memory nodes specified by set.
enum hwloc_obj_cache_type_e hwloc_obj_cache_type_t
Cache type.
void * hwloc_alloc_membind(hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
Allocate some memory on NUMA memory nodes specified by set.
void hwloc_topology_set_userdata(hwloc_topology_t topology, const void *userdata)
Set the topology-specific userdata pointer.
struct hwloc_obj * memory_first_child
First Memory child. NUMA nodes are listed here (memory_arity and memory_first_child) instead of in th...
Definition: hwloc.h:426
hwloc_obj_bridge_type_t downstream_type
Definition: hwloc.h:595
int hwloc_obj_type_snprintf(char *restrict string, size_t size, hwloc_obj_t obj, int verbose)
Stringify the type of a given topology object into a human-readable form.
struct hwloc_obj * misc_first_child
First Misc child. Misc objects are listed here (misc_arity and misc_first_child) instead of in the no...
Definition: hwloc.h:450
int hwloc_topology_set_io_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter)
Set the filtering for all I/O object types.
hwloc_obj_osdev_type_e
Type of a OS device.
Definition: hwloc.h:289
int hwloc_obj_attr_snprintf(char *restrict string, size_t size, hwloc_obj_t obj, const char *restrict separator, int verbose)
Stringify the attributes of a given topology object into a human-readable form.
PCI Device specific Object Attributes.
Definition: hwloc.h:575
Physical package. The physical package that usually gets inserted into a socket on the motherboard...
Definition: hwloc.h:179
Virtual depth for PCI device object level.
Definition: hwloc.h:760
int symmetric_subtree
Set if the subtree of normal objects below this object is symmetric, which means all normal children ...
Definition: hwloc.h:412
int hwloc_type_sscanf_as_depth(const char *string, hwloc_obj_type_t *typep, hwloc_topology_t topology, int *depthp)
Return an object type and its level depth from a type string.
Operating system openfabrics device. For instance the "mlx4_0" InfiniBand HCA, or "hfi1_0" Omni-Path ...
Definition: hwloc.h:297
hwloc_uint64_t local_memory
Local memory (in bytes)
Definition: hwloc.h:545
int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags)
Bind a process pid on cpus given in physical bitmap set.
hwloc_const_bitmap_t hwloc_const_nodeset_t
A non-modifiable hwloc_nodeset_t.
Definition: hwloc.h:155
Avoid any effect on memory binding.
Definition: hwloc.h:1125
Array of local memory page types, NULL if no local memory and page_types is 0.
Definition: hwloc.h:552
struct hwloc_obj * prev_cousin
Previous object of same type and depth.
Definition: hwloc.h:394
Virtual depth for Misc object.
Definition: hwloc.h:762
int hwloc_topology_set_all_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter)
Set the filtering for all object types.
const struct hwloc_bitmap_s * hwloc_const_bitmap_t
a non-modifiable hwloc_bitmap_t
Definition: bitmap.h:57
Structure of a topology object.
Definition: hwloc.h:347
int hwloc_topology_init(hwloc_topology_t *topologyp)
Allocate a topology context.
Bind all threads of the current (possibly) multithreaded process.
Definition: hwloc.h:1079
unsigned char numa_memory
Detecting the amount of memory in NUMA nodes is supported.
Definition: hwloc.h:1881
float linkspeed
Definition: hwloc.h:581
Avoid any effect on CPU binding.
Definition: hwloc.h:1402
Machine. The root object type. A set of processors and memory with cache coherency.
Definition: hwloc.h:173
struct hwloc_topology_membind_support * membind
Definition: hwloc.h:1961
unsigned char get_thisproc_cpubind
Definition: hwloc.h:1893
int hwloc_topology_set_xmlbuffer(hwloc_topology_t restrict topology, const char *restrict buffer, int size)
Enable XML based topology using a memory buffer (instead of a file, as with hwloc_topology_set_xml())...
unsigned arity
Number of normal children. Memory, Misc and I/O children are not listed here but rather in their dedi...
Definition: hwloc.h:403
hwloc_obj_type_t
Definition: hwloc.h:172
int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags)
Bind current process or thread on cpus given in physical bitmap set.
unsigned char bind_membind
Definition: hwloc.h:1941
unsigned char get_thread_cpubind
Definition: hwloc.h:1905
hwloc_obj_t hwloc_topology_alloc_group_object(hwloc_topology_t topology)
Allocate a Group object to insert later with hwloc_topology_insert_group_object().
unsigned char set_thread_cpubind
Definition: hwloc.h:1903
Allocate each memory page individually on the local NUMA node of the thread that touches it...
Definition: hwloc.h:1321
unsigned short domain
Definition: hwloc.h:591
unsigned char migrate_membind
Definition: hwloc.h:1947
void * hwloc_topology_get_userdata(hwloc_topology_t topology)
Retrieve the topology-specific userdata pointer.
int hwloc_topology_is_thissystem(hwloc_topology_t restrict topology)
Does the topology context come from this system?
Assume that the selected backend provides the topology for the system on which we are running...
Definition: hwloc.h:1822
OS Device specific Object Attributes.
Definition: hwloc.h:599
int hwloc_free(hwloc_topology_t topology, void *addr, size_t len)
Free memory that was previously allocated by hwloc_alloc() or hwloc_alloc_membind().
unsigned char set_thisproc_cpubind
Definition: hwloc.h:1891
Reset the memory allocation policy to the system default. Depending on the operating system...
Definition: hwloc.h:1310
int hwloc_set_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
Set the default memory binding policy of the specified process to prefer the NUMA node(s) specified b...
struct hwloc_obj * last_child
Last normal child.
Definition: hwloc.h:409
static int hwloc_get_type_or_above_depth(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the depth of objects of type type or above.
unsigned char get_thisthread_cpubind
Definition: hwloc.h:1901
hwloc_const_bitmap_t hwloc_const_cpuset_t
A non-modifiable hwloc_cpuset_t.
Definition: hwloc.h:137
unsigned page_types_len
Size of array page_types.
Definition: hwloc.h:546
Group-specific Object Attributes.
Definition: hwloc.h:568
hwloc_membind_policy_t
Memory binding policy.
Definition: hwloc.h:1302
Allocate memory on the given nodes in an interleaved / round-robin manner. The precise layout of the ...
Definition: hwloc.h:1334
Ignore all objects of this type.
Definition: hwloc.h:1998
hwloc_uint64_t size
Size of pages.
Definition: hwloc.h:553
static hwloc_obj_t hwloc_get_root_obj(hwloc_topology_t topology)
Returns the top-object of the topology-tree.
NUMA node-specific Object Attributes.
Definition: hwloc.h:544
struct hwloc_obj * hwloc_obj_t
Convenience typedef; a pointer to a struct hwloc_obj.
Definition: hwloc.h:539
Level 3 Data (or Unified) Cache.
Definition: hwloc.h:199
int hwloc_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
Bind the already-allocated memory identified by (addr, len) to the NUMA node(s) specified by set...
Allocate memory on the specified nodes.
Definition: hwloc.h:1325
Level 1 instruction Cache (filtered out by default).
Definition: hwloc.h:203
Only keep likely-important objects of the given type.
Definition: hwloc.h:2027
char * value
Info value.
Definition: hwloc.h:610
Set of flags describing actual support for this topology.
Definition: hwloc.h:1958
unsigned depth
Depth of group object. It may change if intermediate Group objects are added.
Definition: hwloc.h:569
int hwloc_topology_set_type_filter(hwloc_topology_t topology, hwloc_obj_type_t type, enum hwloc_type_filter_e filter)
Set the filtering for the given object type.
int hwloc_topology_get_depth(hwloc_topology_t restrict topology)
Get the depth of the hierarchical tree of objects.
hwloc_nodeset_t nodeset
NUMA nodes covered by this object or containing this object.
Definition: hwloc.h:485
int hwloc_topology_get_type_filter(hwloc_topology_t topology, hwloc_obj_type_t type, enum hwloc_type_filter_e *filter)
Get the current filtering for the given object type.
unsigned hwloc_get_nbobjs_by_depth(hwloc_topology_t topology, int depth)
Returns the width of level at depth depth.
Flags describing actual discovery support for this topology.
Definition: hwloc.h:1875
Operating system device (filtered out by default). They are not added to the topology unless I/O disc...
Definition: hwloc.h:253
unsigned char firsttouch_membind
Definition: hwloc.h:1939
unsigned char set_thisthread_cpubind
Definition: hwloc.h:1899
unsigned char set_thisproc_membind
Definition: hwloc.h:1921
unsigned depth
Definition: hwloc.h:596
Level 3 instruction Cache (filtered out by default).
Definition: hwloc.h:205
unsigned char subordinate_bus
Definition: hwloc.h:592
Processing Unit, or (Logical) Processor. An execution unit (may share a core with some other logical ...
Definition: hwloc.h:188
unsigned hwloc_get_api_version(void)
Indicate at runtime which hwloc API version was used at build time.
hwloc_cpuset_t cpuset
CPUs covered by this object.
Definition: hwloc.h:457
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.
enum hwloc_obj_bridge_type_e hwloc_obj_bridge_type_t
Type of one side (upstream or downstream) of an I/O bridge.
Bridge specific Object Attribues.
Definition: hwloc.h:584
int hwloc_obj_add_other_obj_sets(hwloc_obj_t dst, hwloc_obj_t src)
Setup object cpusets/nodesets by OR&#39;ing another object&#39;s sets.
Set policy for a specific thread of the current process. This flag is mutually exclusive with HWLOC_M...
Definition: hwloc.h:1375
static const char * hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name)
Search the given key name in object infos and return the corresponding value.
unsigned kind
Internally-used kind of group.
Definition: hwloc.h:571
struct hwloc_info_s * infos
Array of stringified info type=name.
Definition: hwloc.h:521
unsigned subkind
Internally-used subkind to distinguish different levels of groups with same kind. ...
Definition: hwloc.h:572
unsigned short class_id
Definition: hwloc.h:578
Virtual depth for NUMA nodes.
Definition: hwloc.h:758
hwloc_obj_t hwloc_get_obj_by_depth(hwloc_topology_t topology, int depth, unsigned idx)
Returns the topology object at logical index idx from depth depth.
hwloc_obj_bridge_type_e
Type of one side (upstream or downstream) of an I/O bridge.
Definition: hwloc.h:283
struct hwloc_obj ** children
Normal children, children[0 .. arity -1].
Definition: hwloc.h:407
NUMA node. An object that contains memory that is directly and byte-accessible to the host processors...
Definition: hwloc.h:220
PCI device (filtered out by default). They are not added to the topology unless I/O discovery is enab...
Definition: hwloc.h:246
Flags describing actual memory binding support for this topology.
Definition: hwloc.h:1919
int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t thread, hwloc_const_cpuset_t set, int flags)
Bind a thread thread on cpus given in physical bitmap set.
Get the set of allowed resources from the local operating system even if the topology was loaded from...
Definition: hwloc.h:1843
Only ignore objects if their entire level does not bring any structure.
Definition: hwloc.h:2012
hwloc_compare_types_e
Definition: hwloc.h:329
Object info.
Definition: hwloc.h:608
Detect the whole system, ignore reservations.
Definition: hwloc.h:1802
hwloc_type_filter_e
Type filtering flags.
Definition: hwloc.h:1984
char * name
Object-specific name if any. Mostly used for identifying OS devices and Misc objects where a name str...
Definition: hwloc.h:359
hwloc_membind_flags_t
Memory binding flags.
Definition: hwloc.h:1365
void * hwloc_alloc(hwloc_topology_t topology, size_t len)
Allocate some memory.
struct hwloc_obj * next_cousin
Next object of same type and depth.
Definition: hwloc.h:393
Bind current thread of current process.
Definition: hwloc.h:1083
struct hwloc_bitmap_s * hwloc_bitmap_t
Set of bits represented as an opaque pointer to an internal bitmap.
Definition: bitmap.h:55
enum hwloc_obj_osdev_type_e hwloc_obj_osdev_type_t
Type of a OS device.
static hwloc_obj_t hwloc_get_obj_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
Returns the topology object at logical index idx with type type.
Level 2 instruction Cache (filtered out by default).
Definition: hwloc.h:204
unsigned char get_thisproc_last_cpu_location
Definition: hwloc.h:1907
struct hwloc_topology * hwloc_topology_t
Topology context.
Definition: hwloc.h:626
unsigned char interleave_membind
Definition: hwloc.h:1943
Definition: hwloc.h:1383
Level 5 Data (or Unified) Cache.
Definition: hwloc.h:201
unsigned char get_proc_membind
Definition: hwloc.h:1927
unsigned misc_arity
Number of Misc children. These children are listed in misc_first_child.
Definition: hwloc.h:447
unsigned char get_proc_cpubind
Definition: hwloc.h:1897
static hwloc_obj_t hwloc_get_next_obj_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, hwloc_obj_t prev)
Returns the next object of type type.
struct hwloc_obj * first_child
First normal child.
Definition: hwloc.h:408
struct hwloc_obj * io_first_child
First I/O child. Bridges, PCI and OS devices are listed here (io_arity and io_first_child) instead of...
Definition: hwloc.h:438
hwloc_topology_flags_e
Flags to be set onto a topology context before load.
Definition: hwloc.h:1780
unsigned char alloc_membind
Definition: hwloc.h:1937
int hwloc_compare_types(hwloc_obj_type_t type1, hwloc_obj_type_t type2)
Compare the depth of two object types.
For each page bound with this policy, by next time it is touched (and next time only), it is moved from its current location to the local NUMA node of the thread where the memory reference occurred (if it needs to be moved at all).
Definition: hwloc.h:1341
Objects of given type exist at different depth in the topology (only for Groups). ...
Definition: hwloc.h:757
unsigned char numa
Detecting the number of NUMA nodes is supported.
Definition: hwloc.h:1879
int hwloc_topology_dup(hwloc_topology_t *newtopology, hwloc_topology_t oldtopology)
Duplicate a topology.
int hwloc_get_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, hwloc_membind_policy_t *policy, int flags)
Query the default memory binding policy and physical locality of the specified process.
int depth
Vertical index in the hierarchy.
Definition: hwloc.h:370
hwloc_cpubind_flags_t
Process/Thread binding flags.
Definition: hwloc.h:1076
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:135
union hwloc_obj_attr_u * attr
Object type-specific Attributes, may be NULL if no attribute value was found.
Definition: hwloc.h:366
hwloc_cpuset_t complete_cpuset
The complete CPU set of logical processors of this object,.
Definition: hwloc.h:472
int hwloc_topology_restrict(hwloc_topology_t restrict topology, hwloc_const_cpuset_t cpuset, unsigned long flags)
Restrict the topology to the given CPU set.
hwloc_obj_t hwloc_topology_insert_misc_object(hwloc_topology_t topology, hwloc_obj_t parent, const char *name)
Add a MISC object as a leaf of the topology.
int hwloc_get_proc_last_cpu_location(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags)
Get the last physical CPU where a process ran.
hwloc_uint64_t count
Number of pages of this size.
Definition: hwloc.h:554
int hwloc_get_membind(hwloc_topology_t topology, hwloc_bitmap_t set, hwloc_membind_policy_t *policy, int flags)
Query the default memory binding policy and physical locality of the current process or thread...
unsigned char get_thisthread_membind
Definition: hwloc.h:1931
unsigned linesize
Cache-line size in bytes. 0 if unknown.
Definition: hwloc.h:562
hwloc_restrict_flags_e
Flags to be given to hwloc_topology_restrict().
Definition: hwloc.h:2084
struct hwloc_obj * next_sibling
Next object below the same parent (inside the same list of children).
Definition: hwloc.h:399
char * name
Info name.
Definition: hwloc.h:609
No object of given type exists in the topology.
Definition: hwloc.h:756
unsigned short domain
Definition: hwloc.h:576
Group objects. Objects which do not fit in the above but are detected by hwloc and are useful to take...
Definition: hwloc.h:207
static hwloc_obj_t hwloc_get_next_obj_by_depth(hwloc_topology_t topology, int depth, hwloc_obj_t prev)
Returns the next object at depth depth.
Instruction cache (filtered out by default).
Definition: hwloc.h:279
Data cache.
Definition: hwloc.h:278
Operating system dma engine device. For instance the "dma0chan0" DMA channel on Linux.
Definition: hwloc.h:300
int hwloc_get_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, hwloc_membind_policy_t *policy, int flags)
Query the CPUs near the physical NUMA node(s) and binding policy of the memory identified by (addr...
const struct hwloc_topology_support * hwloc_topology_get_support(hwloc_topology_t restrict topology)
Retrieve the topology support.
Miscellaneous objects (filtered out by default). Objects without particular meaning, that can e.g. be added by the application for its own use, or by hwloc for miscellaneous objects such as MemoryModule (DIMMs). These objects are not listed in the main children list, but rather in the dedicated misc children list. Misc objects may only have Misc objects as children, and those are in the dedicated misc children list as well. Misc objects have NULL CPU and node sets.
Definition: hwloc.h:261
hwloc_nodeset_t complete_nodeset
The complete NUMA node set of this object,.
Definition: hwloc.h:505
hwloc_obj_type_t type
Type of object.
Definition: hwloc.h:349
Operating system GPU device. For instance ":0.0" for a GL display, "card0" for a Linux DRM device...
Definition: hwloc.h:292
hwloc_obj_t hwloc_topology_insert_group_object(hwloc_topology_t topology, hwloc_obj_t group)
Add more structure to the topology by adding an intermediate Group.
unsigned char nexttouch_membind
Definition: hwloc.h:1945
Bridge (filtered out by default). Any bridge that connects the host or an I/O bus, to another I/O bus. They are not added to the topology unless I/O discovery is enabled with hwloc_topology_set_flags(). I/O objects are not listed in the main children list, but rather in the dedicated io children list. I/O objects have NULL CPU and node sets.
Definition: hwloc.h:237
hwloc_obj_cache_type_e
Cache type.
Definition: hwloc.h:276
int hwloc_topology_set_xml(hwloc_topology_t restrict topology, const char *restrict xmlpath)
Enable XML-file based topology.
Virtual depth for bridge object level.
Definition: hwloc.h:759
hwloc_obj_cache_type_t type
Cache type.
Definition: hwloc.h:565
hwloc_obj_type_t hwloc_get_depth_type(hwloc_topology_t topology, int depth)
Returns the type of objects at depth depth.
int hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t thread, hwloc_cpuset_t set, int flags)
Get the current physical binding of thread tid.
Core. A computation unit (may be shared by several logical processors).
Definition: hwloc.h:184
Host-side of a bridge, only possible upstream.
Definition: hwloc.h:284
int hwloc_set_membind(hwloc_topology_t topology, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
Set the default memory binding policy of the current process or thread to prefer the NUMA node(s) spe...
int hwloc_topology_abi_check(hwloc_topology_t topology)
Verify that the topology is compatible with the current hwloc library.
Consider the bitmap argument as a nodeset.
Definition: hwloc.h:1413
unsigned sibling_rank
Index in parent&#39;s children[] array. Or the index in parent&#39;s Memory, I/O or Misc children list...
Definition: hwloc.h:398
unsigned depth
Depth of cache (e.g., L1, L2, ...etc.)
Definition: hwloc.h:561
unsigned char set_thisthread_membind
Definition: hwloc.h:1929
hwloc_get_type_depth_e
Definition: hwloc.h:755
Unified cache.
Definition: hwloc.h:277
int hwloc_get_last_cpu_location(hwloc_topology_t topology, hwloc_cpuset_t set, int flags)
Get the last physical CPU where the current process or thread ran.
hwloc_uint64_t size
Size of cache in bytes.
Definition: hwloc.h:560
Keep all objects of this type.
Definition: hwloc.h:1990
void * userdata
Application-given private data pointer, initialized to NULL, use it as you wish. See hwloc_topology_s...
Definition: hwloc.h:525
int hwloc_topology_set_pid(hwloc_topology_t restrict topology, hwloc_pid_t pid)
Change which process the topology is viewed from.
unsigned short vendor_id
Definition: hwloc.h:579
unsigned infos_count
Size of infos array.
Definition: hwloc.h:522
unsigned char get_thisthread_last_cpu_location
Definition: hwloc.h:1911
hwloc_uint64_t gp_index
Global persistent index. Generated by hwloc, unique across the topology (contrary to os_index) and pe...
Definition: hwloc.h:530
Request for strict binding from the OS.
Definition: hwloc.h:1108
void hwloc_topology_destroy(hwloc_topology_t topology)
Terminate and free a topology context.
int hwloc_topology_set_flags(hwloc_topology_t topology, unsigned long flags)
Set OR&#39;ed flags to non-yet-loaded topology.
int hwloc_topology_set_cache_types_filter(hwloc_topology_t topology, enum hwloc_type_filter_e filter)
Set the filtering for all cache object types.
Operating system block device. For instance "sda" on Linux.
Definition: hwloc.h:290
Cache-specific Object Attributes.
Definition: hwloc.h:559
Virtual depth for software device object level.
Definition: hwloc.h:761
unsigned char revision
Definition: hwloc.h:580
unsigned char set_proc_cpubind
Definition: hwloc.h:1895
int hwloc_get_type_depth(hwloc_topology_t topology, hwloc_obj_type_t type)
Returns the depth of objects of type type.
Set policy for all threads of the specified (possibly multithreaded) process. This flag is mutually e...
Definition: hwloc.h:1370
int hwloc_get_area_memlocation(hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, int flags)
Get the NUMA nodes where memory identified by (addr, len ) is physically allocated.
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:152
unsigned char set_area_membind
Definition: hwloc.h:1933
char * subtype
Subtype string to better describe the type field.
Definition: hwloc.h:350
hwloc_obj_bridge_type_t upstream_type
Definition: hwloc.h:588
unsigned os_index
OS-provided physical index number. It is not guaranteed unique across the entire machine, except for PUs and NUMA nodes. Set to HWLOC_UNKNOWN_INDEX if unknown or irrelevant for this object.
Definition: hwloc.h:352
unsigned char set_proc_membind
Definition: hwloc.h:1925
hwloc_obj_osdev_type_t type
Definition: hwloc.h:600
Level 2 Data (or Unified) Cache.
Definition: hwloc.h:198
Level 1 Data (or Unified) Cache.
Definition: hwloc.h:197
unsigned logical_index
Horizontal index in the whole list of similar objects, hence guaranteed unique across the entire mach...
Definition: hwloc.h:385
unsigned char pu
Detecting the number of PU objects is supported.
Definition: hwloc.h:1877
unsigned char get_thisproc_membind
Definition: hwloc.h:1923
Migrate existing allocated memory. If the memory cannot be migrated and the HWLOC_MEMBIND_STRICT flag...
Definition: hwloc.h:1389
Remove all objects that became CPU-less. By default, only objects that contain no PU and no memory ar...
Definition: hwloc.h:2089
int associativity
Ways of associativity, -1 if fully associative, 0 if unknown.
Definition: hwloc.h:563