- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List

# hwloc.h

    00001 /*
    00002  * Copyright © 2009 CNRS, INRIA, Université Bordeaux 1
    00003  * Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
    00004  * See COPYING in top-level directory.
    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 #include <stdint.h>
    00021
    00022 /*
    00023  * Symbol transforms
    00024  */
    00025 #include <hwloc/rename.h>
    00026
    00027 /*
    00028  * Cpuset bitmask definitions
    00029  */
    00030
    00031 #include <hwloc/cpuset.h>
    00032
    00033
    00034
    00040 #define HWLOC_API_VERSION 0x00010000
    00041
    00050 struct hwloc_topology;
    00055 typedef struct hwloc_topology * hwloc_topology_t;
    00056
    00071 typedef enum {
    00072   HWLOC_OBJ_SYSTEM,
    00077   HWLOC_OBJ_MACHINE,
    00082   HWLOC_OBJ_NODE,
    00086   HWLOC_OBJ_SOCKET,
    00090   HWLOC_OBJ_CACHE,
    00093   HWLOC_OBJ_CORE,
    00097   HWLOC_OBJ_PU,
    00106   HWLOC_OBJ_GROUP,
    00118   HWLOC_OBJ_MISC
    00122 } hwloc_obj_type_t;
    00123
    00141 HWLOC_DECLSPEC int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2) __hwloc_attribute_const;
    00142
    00143 enum hwloc_compare_types_e {
    00144     HWLOC_TYPE_UNORDERED = INT_MAX
    00145 };
    00146
    00155 union hwloc_obj_attr_u;
    00156
    00158 struct hwloc_obj_memory_s {
    00159   uint64_t total_memory;
    00160   uint64_t local_memory;
    00162   unsigned page_types_len;
    00168   struct hwloc_obj_memory_page_type_s {
    00169     uint64_t size;
    00170     uint64_t count;
    00171   } * page_types;
    00172 };
    00173
    00178 struct hwloc_obj {
    00179   /* physical information */
    00180   hwloc_obj_type_t type;
    00181   unsigned os_index;
    00182   char *name;
    00185   struct hwloc_obj_memory_s memory;
    00186
    00188   union hwloc_obj_attr_u *attr;
    00189
    00190   /* global position */
    00191   unsigned depth;
    00192   unsigned logical_index;
    00194   signed os_level;
    00196   struct hwloc_obj *next_cousin;
    00197   struct hwloc_obj *prev_cousin;
    00199   /* parent */
    00200   struct hwloc_obj *parent;
    00201   unsigned sibling_rank;
    00202   struct hwloc_obj *next_sibling;
    00203   struct hwloc_obj *prev_sibling;
    00205   /* children */
    00206   unsigned arity;
    00207   struct hwloc_obj **children;
    00208   struct hwloc_obj *first_child;
    00209   struct hwloc_obj *last_child;
    00211   /* misc */
    00212   void *userdata;
    00214   /* cpuset */
    00215   hwloc_cpuset_t cpuset;
    00228   hwloc_cpuset_t complete_cpuset;
    00239   hwloc_cpuset_t online_cpuset;
    00247   hwloc_cpuset_t allowed_cpuset;
    00258   hwloc_cpuset_t nodeset;
    00270   hwloc_cpuset_t complete_nodeset;
    00281   hwloc_cpuset_t allowed_nodeset;
    00290 };
    00294 typedef struct hwloc_obj * hwloc_obj_t;
    00295
    00297 union hwloc_obj_attr_u {
    00299   struct hwloc_cache_attr_s {
    00300     uint64_t size;
    00301     unsigned depth;
    00302   } cache;
    00304   struct hwloc_machine_attr_s {
    00305     char *dmi_board_vendor;
    00306     char *dmi_board_name;
    00307   } machine;
    00309   struct hwloc_group_attr_s {
    00310     unsigned depth;
    00311   } group;
    00312 };
    00313
    00328 HWLOC_DECLSPEC int hwloc_topology_init (hwloc_topology_t *topologyp);
    00329
    00342 HWLOC_DECLSPEC int hwloc_topology_load(hwloc_topology_t topology);
    00343
    00348 HWLOC_DECLSPEC void hwloc_topology_destroy (hwloc_topology_t topology);
    00349
    00354 HWLOC_DECLSPEC void hwloc_topology_check(hwloc_topology_t topology);
    00355
    00388 HWLOC_DECLSPEC int hwloc_topology_ignore_type(hwloc_topology_t topology, hwloc_obj_type_t type);
    00389
    00396 HWLOC_DECLSPEC int hwloc_topology_ignore_type_keep_structure(hwloc_topology_t topology, hwloc_obj_type_t type);
    00397
    00403 HWLOC_DECLSPEC int hwloc_topology_ignore_all_keep_structure(hwloc_topology_t topology);
    00404
    00409 enum hwloc_topology_flags_e {
    00410   HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM = (1<<0),
    00419   HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = (1<<1)
    00438 };
    00439
    00444 HWLOC_DECLSPEC int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
    00445
    00459 HWLOC_DECLSPEC int hwloc_topology_set_fsroot(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict fsroot_path);
    00460
    00474 HWLOC_DECLSPEC int hwloc_topology_set_pid(hwloc_topology_t __hwloc_restrict topology, hwloc_pid_t pid);
    00475
    00489 HWLOC_DECLSPEC int hwloc_topology_set_synthetic(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict description);
    00490
    00502 HWLOC_DECLSPEC int hwloc_topology_set_xml(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict xmlpath);
    00503
    00505 struct hwloc_topology_discovery_support {
    00507   unsigned char pu;
    00508 };
    00509
    00511 struct hwloc_topology_cpubind_support {
    00513   unsigned char set_thisproc_cpubind;
    00515   unsigned char get_thisproc_cpubind;
    00517   unsigned char set_proc_cpubind;
    00519   unsigned char get_proc_cpubind;
    00521   unsigned char set_thisthread_cpubind;
    00523   unsigned char get_thisthread_cpubind;
    00525   unsigned char set_thread_cpubind;
    00527   unsigned char get_thread_cpubind;
    00528 };
    00529
    00536 struct hwloc_topology_support {
    00537   struct hwloc_topology_discovery_support *discovery;
    00538   struct hwloc_topology_cpubind_support *cpubind;
    00539 };
    00540
    00542 HWLOC_DECLSPEC const struct hwloc_topology_support *hwloc_topology_get_support(hwloc_topology_t __hwloc_restrict topology);
    00543
    00556 HWLOC_DECLSPEC void hwloc_topology_export_xml(hwloc_topology_t topology, const char *xmlpath);
    00557
    00567 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset, const char *name);
    00568
    00578 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name);
    00579
    00592 HWLOC_DECLSPEC unsigned hwloc_topology_get_depth(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
    00593
    00603 HWLOC_DECLSPEC int hwloc_get_type_depth (hwloc_topology_t topology, hwloc_obj_type_t type);
    00604
    00605 enum hwloc_get_type_depth_e {
    00606     HWLOC_TYPE_DEPTH_UNKNOWN = -1,
    00607     HWLOC_TYPE_DEPTH_MULTIPLE = -2
    00608 };
    00609
    00614 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_get_depth_type (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
    00615
    00617 HWLOC_DECLSPEC unsigned hwloc_get_nbobjs_by_depth (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
    00618
    00624 static __hwloc_inline int __hwloc_attribute_pure
    00625 hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type)
    00626 {
    00627         int depth = hwloc_get_type_depth(topology, type);
    00628         if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
    00629                 return 0;
    00630         if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
    00631                 return -1; /* FIXME: agregate nbobjs from different levels? */
    00632         return hwloc_get_nbobjs_by_depth(topology, depth);
    00633 }
    00634
    00642 HWLOC_DECLSPEC int hwloc_topology_is_thissystem(hwloc_topology_t  __hwloc_restrict topology) __hwloc_attribute_pure;
    00643
    00653 HWLOC_DECLSPEC hwloc_obj_t hwloc_get_obj_by_depth (hwloc_topology_t topology, unsigned depth, unsigned idx) __hwloc_attribute_pure;
    00654
    00661 static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure
    00662 hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
    00663 {
    00664   int depth = hwloc_get_type_depth(topology, type);
    00665   if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
    00666     return NULL;
    00667   if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
    00668     return NULL;
    00669   return hwloc_get_obj_by_depth(topology, depth, idx);
    00670 }
    00671
    00681 HWLOC_DECLSPEC const char * hwloc_obj_type_string (hwloc_obj_type_t type) __hwloc_attribute_const;
    00682
    00687 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_obj_type_of_string (const char * string) __hwloc_attribute_pure;
    00688
    00697 HWLOC_DECLSPEC int hwloc_obj_type_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj,
    00698                                    int verbose);
    00699
    00709 HWLOC_DECLSPEC int hwloc_obj_attr_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj, const char * __hwloc_restrict separator,
    00710                                    int verbose);
    00711
    00730 HWLOC_DECLSPEC int hwloc_obj_snprintf(char * __hwloc_restrict string, size_t size,
    00731                              hwloc_topology_t topology, hwloc_obj_t obj,
    00732                              const char * __hwloc_restrict indexprefix, int verbose);
    00733
    00737 HWLOC_DECLSPEC int hwloc_obj_cpuset_snprintf(char * __hwloc_restrict str, size_t size, size_t nobj, const hwloc_obj_t * __hwloc_restrict objs);
    00738
    00784 typedef enum {
    00785   HWLOC_CPUBIND_PROCESS = (1<<0),
    00788   HWLOC_CPUBIND_THREAD = (1<<1),
    00790   HWLOC_CPUBIND_STRICT = (1<<2)
    00818 } hwloc_cpubind_policy_t;
    00819
    00825 HWLOC_DECLSPEC int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set,
    00826                             int policy);
    00827
    00830 HWLOC_DECLSPEC int hwloc_get_cpubind(hwloc_topology_t topology, hwloc_cpuset_t set, int policy);
    00831
    00839 HWLOC_DECLSPEC int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int policy);
    00840
    00848 HWLOC_DECLSPEC int hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int policy);
    00849
    00857 #ifdef hwloc_thread_t
    00858 HWLOC_DECLSPEC int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int policy);
    00859 #endif
    00860
    00868 #ifdef hwloc_thread_t
    00869 HWLOC_DECLSPEC int hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int policy);
    00870 #endif
    00871
    00875 /* high-level helpers */
    00876 #include <hwloc/helper.h>
    00877
    00878
    00879 #endif /* HWLOC_H */