12 #ifndef HWLOC_PRIVATE_H
13 #define HWLOC_PRIVATE_H
15 #include <private/autogen/config.h>
18 #include <private/debug.h>
19 #include <sys/types.h>
26 #ifdef HWLOC_HAVE_ATTRIBUTE_FORMAT
27 # if HWLOC_HAVE_ATTRIBUTE_FORMAT
28 # define __hwloc_attribute_format(type, str, arg) __attribute__((__format__(type, str, arg)))
30 # define __hwloc_attribute_format(type, str, arg)
33 # define __hwloc_attribute_format(type, str, arg)
36 enum hwloc_ignore_type_e {
37 HWLOC_IGNORE_TYPE_NEVER = 0,
38 HWLOC_IGNORE_TYPE_KEEP_STRUCTURE,
39 HWLOC_IGNORE_TYPE_ALWAYS
42 #define HWLOC_DEPTH_MAX 128
44 typedef enum hwloc_backend_e {
46 HWLOC_BACKEND_SYNTHETIC,
47 #ifdef HWLOC_LINUX_SYS
58 unsigned next_group_depth;
59 unsigned level_nbobjects[HWLOC_DEPTH_MAX];
60 struct hwloc_obj **levels[HWLOC_DEPTH_MAX];
68 unsigned bridge_nbobjects;
70 struct hwloc_obj *first_bridge, *last_bridge;
71 unsigned pcidev_nbobjects;
73 struct hwloc_obj *first_pcidev, *last_pcidev;
74 unsigned osdev_nbobjects;
76 struct hwloc_obj *first_osdev, *last_osdev;
125 hwloc_backend_t backend_type;
127 #ifdef HWLOC_LINUX_SYS
128 struct hwloc_backend_params_sysfs_s {
134 #if defined(HWLOC_OSF_SYS) || defined(HWLOC_COMPILE_PORTS)
135 struct hwloc_backend_params_osf {
141 #ifdef HWLOC_HAVE_LIBXML2
148 #define HWLOC_SYNTHETIC_MAX_DEPTH 128
149 unsigned arity[HWLOC_SYNTHETIC_MAX_DEPTH];
151 unsigned id[HWLOC_SYNTHETIC_MAX_DEPTH];
152 unsigned depth[HWLOC_SYNTHETIC_MAX_DEPTH];
158 extern void hwloc_setup_pu_level(
struct hwloc_topology *topology,
unsigned nb_pus);
159 extern int hwloc_get_sysctlbyname(
const char *name, int64_t *n);
160 extern int hwloc_get_sysctl(
int name[],
unsigned namelen,
int *n);
161 extern unsigned hwloc_fallback_nbprocessors(
struct hwloc_topology *topology);
163 #if defined(HWLOC_LINUX_SYS)
165 extern void hwloc_set_linux_hooks(
struct hwloc_topology *topology);
166 extern int hwloc_backend_sysfs_init(
struct hwloc_topology *topology,
const char *fsroot_path);
167 extern void hwloc_backend_sysfs_exit(
struct hwloc_topology *topology);
170 extern int hwloc_backend_xml_init(
struct hwloc_topology *topology,
const char *xmlpath,
const char *xmlbuffer,
int buflen);
171 extern void hwloc_xml_check_distances(
struct hwloc_topology *topology);
173 extern void hwloc_backend_xml_exit(
struct hwloc_topology *topology);
175 #ifdef HWLOC_SOLARIS_SYS
177 extern void hwloc_set_solaris_hooks(
struct hwloc_topology *topology);
192 extern void hwloc_set_windows_hooks(
struct hwloc_topology *topology);
195 #ifdef HWLOC_DARWIN_SYS
197 extern void hwloc_set_darwin_hooks(
struct hwloc_topology *topology);
200 #ifdef HWLOC_FREEBSD_SYS
202 extern void hwloc_set_freebsd_hooks(
struct hwloc_topology *topology);
205 #ifdef HWLOC_HPUX_SYS
207 extern void hwloc_set_hpux_hooks(
struct hwloc_topology *topology);
210 extern void hwloc_look_x86(
struct hwloc_topology *topology,
unsigned nbprocs);
212 #ifdef HWLOC_HAVE_LIBPCI
216 extern int hwloc_backend_synthetic_init(
struct hwloc_topology *topology,
const char *description);
217 extern void hwloc_backend_synthetic_exit(
struct hwloc_topology *topology);
218 extern void hwloc_look_synthetic (
struct hwloc_topology *topology);
239 typedef void (*hwloc_report_error_t)(
const char * msg,
int line);
240 extern void hwloc_report_os_error(
const char * msg,
int line);
241 extern int hwloc_hide_errors(
void);
245 extern int hwloc__insert_object_by_cpuset(
struct hwloc_topology *topology,
hwloc_obj_t obj, hwloc_report_error_t report_error);
261 extern void hwloc_add_uname_info(
struct hwloc_topology *topology);
263 #ifdef HWLOC_INSIDE_LIBHWLOC
265 static __hwloc_inline
char *
276 struct hwloc_obj *obj = malloc(
sizeof(*obj));
277 memset(obj, 0,
sizeof(*obj));
281 obj->
attr = malloc(
sizeof(*obj->
attr));
282 memset(obj->
attr, 0,
sizeof(*obj->
attr));
287 extern void hwloc_free_unlinked_object(
hwloc_obj_t obj);
289 #define hwloc_object_cpuset_from_array(l, _value, _array, _max) do { \
290 struct hwloc_obj *__l = (l); \
291 unsigned int *__a = (_array); \
293 __l->cpuset = hwloc_bitmap_alloc(); \
294 for(k=0; k<_max; k++) \
295 if (__a[k] == _value) \
296 hwloc_bitmap_set(__l->cpuset, k); \
302 static __hwloc_inline
void
303 hwloc_setup_level(
int procid_max,
unsigned num,
unsigned *osphysids,
unsigned *proc_physids,
struct hwloc_topology *topology,
hwloc_obj_type_t type)
310 for (j = 0; j < num; j++)
312 obj = hwloc_alloc_setup_object(type, osphysids[j]);
313 hwloc_object_cpuset_from_array(obj, j, proc_physids, procid_max);
314 hwloc_debug_2args_bitmap(
"%s %d has cpuset %s\n",
317 hwloc_insert_object_by_cpuset(topology, obj);
319 hwloc_debug(
"%s",
"\n");
337 static __hwloc_inline
void *
345 extern void hwloc_topology_distances_init(
struct hwloc_topology *topology);
346 extern void hwloc_topology_distances_clear(
struct hwloc_topology *topology);
347 extern void hwloc_topology_distances_destroy(
struct hwloc_topology *topology);
349 extern void hwloc_store_distances_from_env(
struct hwloc_topology *topology);
350 extern void hwloc_convert_distances_indexes_into_objects(
struct hwloc_topology *topology);
351 extern void hwloc_finalize_logical_distances(
struct hwloc_topology *topology);
352 extern void hwloc_restrict_distances(
struct hwloc_topology *topology,
unsigned long flags);
354 extern void hwloc_group_by_distances(
struct hwloc_topology *topology);
HWLOC_DECLSPEC const char * hwloc_obj_type_string(hwloc_obj_type_t type) __hwloc_attribute_const
Return a stringified topology object type.
Definition: traversal.c:175
signed os_level
OS-provided physical level, -1 if unknown or meaningless.
Definition: hwloc.h:344
unsigned os_index
OS-provided physical index number.
Definition: hwloc.h:332
Distances between objects.
Definition: hwloc.h:522
Definition: private.h:110
Request strict binding from the OS.
Definition: hwloc.h:1574
hwloc_obj_type_t type
Type of object.
Definition: hwloc.h:331
Sentinel value.
Definition: hwloc.h:243
hwloc_nodeset_t nodeset
NUMA nodes covered by this object or containing this object.
Definition: hwloc.h:409
Definition: private.h:126
Structure of a topology object.
Definition: hwloc.h:329
HWLOC_DECLSPEC int hwloc_bitmap_asprintf(char **strp, hwloc_const_bitmap_t bitmap)
Stringify a bitmap into a newly allocated string.
Definition: private.h:139
Definition: private.h:146
The bitmap API, for use in hwloc itself.
HWLOC_DECLSPEC void * hwloc_alloc(hwloc_topology_t topology, size_t len)
Allocate some memory.
Definition: bind.c:487
hwloc_obj_type_t
Type of topology object.
Definition: hwloc.h:164
hwloc_cpuset_t cpuset
CPUs covered by this object.
Definition: hwloc.h:366
hwloc_membind_policy_t
Memory binding policy.
Definition: hwloc.h:1479
union hwloc_obj_attr_u * attr
Object type-specific Attributes, may be NULL if no attribute value was found.
Definition: hwloc.h:337
struct hwloc_distances_s ** distances
Distances between all objects at same depth below this object.
Definition: hwloc.h:453
Set of flags describing actual support for this topology.
Definition: hwloc.h:905