00001
00002
00003
00004
00005
00006
00014 #ifndef HWLOC_H
00015 #define HWLOC_H
00016
00017 #include <sys/types.h>
00018 #include <stdio.h>
00019 #include <limits.h>
00020
00021
00022
00023
00024
00025 #include <hwloc/cpuset.h>
00026
00027
00028
00033 struct hwloc_topology;
00038 typedef struct hwloc_topology * hwloc_topology_t;
00039
00054 typedef enum {
00055 HWLOC_OBJ_SYSTEM,
00060 HWLOC_OBJ_MACHINE,
00064 HWLOC_OBJ_NODE,
00068 HWLOC_OBJ_SOCKET,
00072 HWLOC_OBJ_CACHE,
00075 HWLOC_OBJ_CORE,
00079 HWLOC_OBJ_PROC,
00088 HWLOC_OBJ_MISC,
00095 } hwloc_obj_type_t;
00096
00109 int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2);
00110
00112 #define HWLOC_TYPE_UNORDERED INT_MAX
00113
00122 union hwloc_obj_attr_u;
00123
00128 struct hwloc_obj {
00129
00130 hwloc_obj_type_t type;
00131 signed os_index;
00132 char *name;
00135 union hwloc_obj_attr_u *attr;
00136
00137
00138 unsigned depth;
00139 unsigned logical_index;
00141 struct hwloc_obj *next_cousin;
00142 struct hwloc_obj *prev_cousin;
00144
00145 struct hwloc_obj *father;
00146 unsigned sibling_rank;
00147 struct hwloc_obj *next_sibling;
00148 struct hwloc_obj *prev_sibling;
00150
00151 unsigned arity;
00152 struct hwloc_obj **children;
00153 struct hwloc_obj *first_child;
00154 struct hwloc_obj *last_child;
00156
00157 void *userdata;
00159
00160 hwloc_cpuset_t cpuset;
00162 signed os_level;
00163 };
00164 typedef struct hwloc_obj * hwloc_obj_t;
00165
00167 union hwloc_obj_attr_u {
00169 struct hwloc_cache_attr_s {
00170 unsigned long memory_kB;
00171 unsigned depth;
00172 } cache;
00174 struct hwloc_memory_attr_s {
00175 unsigned long memory_kB;
00176 unsigned long huge_page_free;
00177 } node;
00179 struct hwloc_machine_attr_s {
00180 char *dmi_board_vendor;
00181 char *dmi_board_name;
00182 unsigned long memory_kB;
00183 unsigned long huge_page_free;
00184 unsigned long huge_page_size_kB;
00185 } machine;
00187 struct hwloc_machine_attr_s system;
00189 struct hwloc_misc_attr_s {
00190 unsigned depth;
00191 } misc;
00192 };
00193
00208 extern int hwloc_topology_init (hwloc_topology_t *topologyp);
00209
00222 extern int hwloc_topology_load(hwloc_topology_t topology);
00223
00228 extern void hwloc_topology_destroy (hwloc_topology_t topology);
00229
00234 extern void hwloc_topology_check(hwloc_topology_t topology);
00235
00266 extern int hwloc_topology_ignore_type(hwloc_topology_t topology, hwloc_obj_type_t type);
00267
00275 extern int hwloc_topology_ignore_type_keep_structure(hwloc_topology_t topology, hwloc_obj_type_t type);
00276
00282 extern int hwloc_topology_ignore_all_keep_structure(hwloc_topology_t topology);
00283
00288 enum hwloc_topology_flags_e {
00289
00290
00291
00292
00293
00294 HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM = (1<<0),
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = (1<<1),
00314 };
00315
00320 extern int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
00321
00335 extern int hwloc_topology_set_fsroot(hwloc_topology_t restrict topology, const char * restrict fsroot_path);
00336
00348 extern int hwloc_topology_set_synthetic(hwloc_topology_t restrict topology, const char * restrict description);
00349
00361 extern int hwloc_topology_set_xml(hwloc_topology_t restrict topology, const char * restrict xmlpath);
00362
00375 extern unsigned hwloc_topology_get_depth(hwloc_topology_t restrict topology);
00376
00386 extern int hwloc_get_type_depth (hwloc_topology_t topology, hwloc_obj_type_t type);
00387 #define HWLOC_TYPE_DEPTH_UNKNOWN -1
00388 #define HWLOC_TYPE_DEPTH_MULTIPLE -2
00391 extern hwloc_obj_type_t hwloc_get_depth_type (hwloc_topology_t topology, unsigned depth);
00392
00394 extern unsigned hwloc_get_nbobjs_by_depth (hwloc_topology_t topology, unsigned depth);
00395
00401 static inline int
00402 hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type)
00403 {
00404 int depth = hwloc_get_type_depth(topology, type);
00405 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00406 return 0;
00407 if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00408 return -1;
00409 return hwloc_get_nbobjs_by_depth(topology, depth);
00410 }
00411
00419 extern int hwloc_topology_is_thissystem(hwloc_topology_t restrict topology);
00420
00430 extern hwloc_obj_t hwloc_get_obj_by_depth (hwloc_topology_t topology, unsigned depth, unsigned idx);
00431
00438 static inline hwloc_obj_t
00439 hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
00440 {
00441 int depth = hwloc_get_type_depth(topology, type);
00442 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00443 return NULL;
00444 if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00445 return NULL;
00446 return hwloc_get_obj_by_depth(topology, depth, idx);
00447 }
00448
00458 extern const char * hwloc_obj_type_string (hwloc_obj_type_t type);
00459
00461 extern hwloc_obj_type_t hwloc_obj_type_of_string (const char * string);
00462
00476 extern int hwloc_obj_snprintf(char * restrict string, size_t size,
00477 hwloc_topology_t topology, hwloc_obj_t obj,
00478 const char * restrict indexprefix, int verbose);
00479
00483 extern int hwloc_obj_cpuset_snprintf(char * restrict str, size_t size, size_t nobj, const hwloc_obj_t * restrict objs);
00484
00530 typedef enum {
00531 HWLOC_CPUBIND_PROCESS = (1<<0),
00533 HWLOC_CPUBIND_THREAD = (1<<1),
00534 HWLOC_CPUBIND_STRICT = (1<<2),
00552 } hwloc_cpubind_policy_t;
00553
00556 extern int hwloc_set_cpubind(hwloc_topology_t topology, const hwloc_cpuset_t set,
00557 int policy);
00558
00566 extern int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, const hwloc_cpuset_t set, int policy);
00567
00575 #ifdef hwloc_thread_t
00576 extern int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, const hwloc_cpuset_t set, int policy);
00577 #endif
00578
00582
00583 #include <hwloc/helper.h>
00584
00585
00586 #endif