00001
00002
00003
00004
00005
00006
00014 #ifndef HWLOC_H
00015 #define HWLOC_H
00016
00017 #include <hwloc/config.h>
00018 #include <sys/types.h>
00019 #include <stdio.h>
00020 #include <limits.h>
00021 #ifdef HWLOC_HAVE_STDINT_H
00022 #include <stdint.h>
00023 #endif
00024
00025
00026
00027
00028 #include <hwloc/rename.h>
00029
00030
00031
00032
00033
00034 #include <hwloc/cpuset.h>
00035
00036
00037
00043 #define HWLOC_API_VERSION 0x00010000
00044
00053 struct hwloc_topology;
00058 typedef struct hwloc_topology * hwloc_topology_t;
00059
00074 typedef enum {
00075 HWLOC_OBJ_SYSTEM,
00080 HWLOC_OBJ_MACHINE,
00085 HWLOC_OBJ_NODE,
00089 HWLOC_OBJ_SOCKET,
00093 HWLOC_OBJ_CACHE,
00096 HWLOC_OBJ_CORE,
00100 HWLOC_OBJ_PU,
00109 HWLOC_OBJ_GROUP,
00121 HWLOC_OBJ_MISC
00125 } hwloc_obj_type_t;
00126
00144 HWLOC_DECLSPEC int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2) __hwloc_attribute_const;
00145
00146 enum hwloc_compare_types_e {
00147 HWLOC_TYPE_UNORDERED = INT_MAX
00148 };
00149
00158 union hwloc_obj_attr_u;
00159
00161 struct hwloc_obj_memory_s {
00162 uint64_t total_memory;
00163 uint64_t local_memory;
00165 unsigned page_types_len;
00171 struct hwloc_obj_memory_page_type_s {
00172 uint64_t size;
00173 uint64_t count;
00174 } * page_types;
00175 };
00176
00181 struct hwloc_obj {
00182
00183 hwloc_obj_type_t type;
00184 unsigned os_index;
00185 char *name;
00188 struct hwloc_obj_memory_s memory;
00189
00191 union hwloc_obj_attr_u *attr;
00192
00193
00194 unsigned depth;
00195 unsigned logical_index;
00197 signed os_level;
00199 struct hwloc_obj *next_cousin;
00200 struct hwloc_obj *prev_cousin;
00202
00203 struct hwloc_obj *parent;
00204 unsigned sibling_rank;
00205 struct hwloc_obj *next_sibling;
00206 struct hwloc_obj *prev_sibling;
00208
00209 unsigned arity;
00210 struct hwloc_obj **children;
00211 struct hwloc_obj *first_child;
00212 struct hwloc_obj *last_child;
00214
00215 void *userdata;
00217
00218 hwloc_cpuset_t cpuset;
00231 hwloc_cpuset_t complete_cpuset;
00242 hwloc_cpuset_t online_cpuset;
00250 hwloc_cpuset_t allowed_cpuset;
00261 hwloc_cpuset_t nodeset;
00273 hwloc_cpuset_t complete_nodeset;
00284 hwloc_cpuset_t allowed_nodeset;
00293 };
00297 typedef struct hwloc_obj * hwloc_obj_t;
00298
00300 union hwloc_obj_attr_u {
00302 struct hwloc_cache_attr_s {
00303 uint64_t size;
00304 unsigned depth;
00305 } cache;
00307 struct hwloc_machine_attr_s {
00308 char *dmi_board_vendor;
00309 char *dmi_board_name;
00310 } machine;
00312 struct hwloc_group_attr_s {
00313 unsigned depth;
00314 } group;
00315 };
00316
00331 HWLOC_DECLSPEC int hwloc_topology_init (hwloc_topology_t *topologyp);
00332
00345 HWLOC_DECLSPEC int hwloc_topology_load(hwloc_topology_t topology);
00346
00351 HWLOC_DECLSPEC void hwloc_topology_destroy (hwloc_topology_t topology);
00352
00357 HWLOC_DECLSPEC void hwloc_topology_check(hwloc_topology_t topology);
00358
00391 HWLOC_DECLSPEC int hwloc_topology_ignore_type(hwloc_topology_t topology, hwloc_obj_type_t type);
00392
00399 HWLOC_DECLSPEC int hwloc_topology_ignore_type_keep_structure(hwloc_topology_t topology, hwloc_obj_type_t type);
00400
00406 HWLOC_DECLSPEC int hwloc_topology_ignore_all_keep_structure(hwloc_topology_t topology);
00407
00412 enum hwloc_topology_flags_e {
00413 HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM = (1<<0),
00422 HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = (1<<1)
00441 };
00442
00447 HWLOC_DECLSPEC int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
00448
00462 HWLOC_DECLSPEC int hwloc_topology_set_fsroot(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict fsroot_path);
00463
00477 HWLOC_DECLSPEC int hwloc_topology_set_pid(hwloc_topology_t __hwloc_restrict topology, hwloc_pid_t pid);
00478
00492 HWLOC_DECLSPEC int hwloc_topology_set_synthetic(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict description);
00493
00505 HWLOC_DECLSPEC int hwloc_topology_set_xml(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict xmlpath);
00506
00508 struct hwloc_topology_discovery_support {
00510 unsigned char pu;
00511 };
00512
00514 struct hwloc_topology_cpubind_support {
00516 unsigned char set_thisproc_cpubind;
00518 unsigned char get_thisproc_cpubind;
00520 unsigned char set_proc_cpubind;
00522 unsigned char get_proc_cpubind;
00524 unsigned char set_thisthread_cpubind;
00526 unsigned char get_thisthread_cpubind;
00528 unsigned char set_thread_cpubind;
00530 unsigned char get_thread_cpubind;
00531 };
00532
00539 struct hwloc_topology_support {
00540 struct hwloc_topology_discovery_support *discovery;
00541 struct hwloc_topology_cpubind_support *cpubind;
00542 };
00543
00545 HWLOC_DECLSPEC const struct hwloc_topology_support *hwloc_topology_get_support(hwloc_topology_t __hwloc_restrict topology);
00546
00559 HWLOC_DECLSPEC void hwloc_topology_export_xml(hwloc_topology_t topology, const char *xmlpath);
00560
00570 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset, const char *name);
00571
00581 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name);
00582
00595 HWLOC_DECLSPEC unsigned hwloc_topology_get_depth(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
00596
00606 HWLOC_DECLSPEC int hwloc_get_type_depth (hwloc_topology_t topology, hwloc_obj_type_t type);
00607
00608 enum hwloc_get_type_depth_e {
00609 HWLOC_TYPE_DEPTH_UNKNOWN = -1,
00610 HWLOC_TYPE_DEPTH_MULTIPLE = -2
00611 };
00612
00617 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_get_depth_type (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
00618
00620 HWLOC_DECLSPEC unsigned hwloc_get_nbobjs_by_depth (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
00621
00627 static __hwloc_inline int __hwloc_attribute_pure
00628 hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type)
00629 {
00630 int depth = hwloc_get_type_depth(topology, type);
00631 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00632 return 0;
00633 if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00634 return -1;
00635 return hwloc_get_nbobjs_by_depth(topology, depth);
00636 }
00637
00645 HWLOC_DECLSPEC int hwloc_topology_is_thissystem(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
00646
00656 HWLOC_DECLSPEC hwloc_obj_t hwloc_get_obj_by_depth (hwloc_topology_t topology, unsigned depth, unsigned idx) __hwloc_attribute_pure;
00657
00664 static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure
00665 hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
00666 {
00667 int depth = hwloc_get_type_depth(topology, type);
00668 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00669 return NULL;
00670 if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00671 return NULL;
00672 return hwloc_get_obj_by_depth(topology, depth, idx);
00673 }
00674
00684 HWLOC_DECLSPEC const char * hwloc_obj_type_string (hwloc_obj_type_t type) __hwloc_attribute_const;
00685
00690 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_obj_type_of_string (const char * string) __hwloc_attribute_pure;
00691
00700 HWLOC_DECLSPEC int hwloc_obj_type_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj,
00701 int verbose);
00702
00712 HWLOC_DECLSPEC int hwloc_obj_attr_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj, const char * __hwloc_restrict separator,
00713 int verbose);
00714
00733 HWLOC_DECLSPEC int hwloc_obj_snprintf(char * __hwloc_restrict string, size_t size,
00734 hwloc_topology_t topology, hwloc_obj_t obj,
00735 const char * __hwloc_restrict indexprefix, int verbose);
00736
00740 HWLOC_DECLSPEC int hwloc_obj_cpuset_snprintf(char * __hwloc_restrict str, size_t size, size_t nobj, const hwloc_obj_t * __hwloc_restrict objs);
00741
00787 typedef enum {
00788 HWLOC_CPUBIND_PROCESS = (1<<0),
00791 HWLOC_CPUBIND_THREAD = (1<<1),
00793 HWLOC_CPUBIND_STRICT = (1<<2)
00821 } hwloc_cpubind_policy_t;
00822
00828 HWLOC_DECLSPEC int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set,
00829 int policy);
00830
00833 HWLOC_DECLSPEC int hwloc_get_cpubind(hwloc_topology_t topology, hwloc_cpuset_t set, int policy);
00834
00842 HWLOC_DECLSPEC int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int policy);
00843
00851 HWLOC_DECLSPEC int hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int policy);
00852
00860 #ifdef hwloc_thread_t
00861 HWLOC_DECLSPEC int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int policy);
00862 #endif
00863
00871 #ifdef hwloc_thread_t
00872 HWLOC_DECLSPEC int hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int policy);
00873 #endif
00874
00878
00879 #include <hwloc/helper.h>
00880
00881
00882 #endif