• 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 <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  * Symbol transforms
00027  */
00028 #include <hwloc/rename.h>
00029 
00030 /*
00031  * Cpuset bitmask definitions
00032  */
00033 
00034 #include <hwloc/cpuset.h>
00035 
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 
00047 #define HWLOC_API_VERSION 0x00010000
00048 
00057 struct hwloc_topology;
00062 typedef struct hwloc_topology * hwloc_topology_t;
00063 
00078 typedef enum {
00079   HWLOC_OBJ_SYSTEM,     
00084   HWLOC_OBJ_MACHINE,    
00089   HWLOC_OBJ_NODE,       
00093   HWLOC_OBJ_SOCKET,     
00097   HWLOC_OBJ_CACHE,      
00100   HWLOC_OBJ_CORE,       
00104   HWLOC_OBJ_PU,         
00113   HWLOC_OBJ_GROUP,      
00125   HWLOC_OBJ_MISC        
00129 } hwloc_obj_type_t;
00130 
00148 HWLOC_DECLSPEC int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2) __hwloc_attribute_const;
00149 
00150 enum hwloc_compare_types_e {
00151     HWLOC_TYPE_UNORDERED = INT_MAX      
00152 };
00153 
00162 union hwloc_obj_attr_u;
00163 
00165 struct hwloc_obj_memory_s {
00166   uint64_t total_memory; 
00167   uint64_t local_memory; 
00169   unsigned page_types_len; 
00175   struct hwloc_obj_memory_page_type_s {
00176     uint64_t size;      
00177     uint64_t count;     
00178   } * page_types;
00179 };
00180 
00185 struct hwloc_obj {
00186   /* physical information */
00187   hwloc_obj_type_t type;                
00188   unsigned os_index;                    
00189   char *name;                           
00192   struct hwloc_obj_memory_s memory;
00193 
00195   union hwloc_obj_attr_u *attr;
00196 
00197   /* global position */
00198   unsigned depth;                       
00199   unsigned logical_index;               
00201   signed os_level;                      
00203   struct hwloc_obj *next_cousin;        
00204   struct hwloc_obj *prev_cousin;        
00206   /* parent */
00207   struct hwloc_obj *parent;             
00208   unsigned sibling_rank;                
00209   struct hwloc_obj *next_sibling;       
00210   struct hwloc_obj *prev_sibling;       
00212   /* children */
00213   unsigned arity;                       
00214   struct hwloc_obj **children;          
00215   struct hwloc_obj *first_child;        
00216   struct hwloc_obj *last_child;         
00218   /* misc */
00219   void *userdata;                       
00221   /* cpuset */
00222   hwloc_cpuset_t cpuset;                
00235   hwloc_cpuset_t complete_cpuset;       
00246   hwloc_cpuset_t online_cpuset;         
00254   hwloc_cpuset_t allowed_cpuset;        
00265   hwloc_cpuset_t nodeset;               
00277   hwloc_cpuset_t complete_nodeset;      
00288   hwloc_cpuset_t allowed_nodeset;       
00297 };
00301 typedef struct hwloc_obj * hwloc_obj_t;
00302 
00304 union hwloc_obj_attr_u {
00306   struct hwloc_cache_attr_s {
00307     uint64_t size;                        
00308     unsigned depth;                       
00309   } cache;
00311   struct hwloc_machine_attr_s {
00312     char *dmi_board_vendor;               
00313     char *dmi_board_name;                 
00314   } machine;
00316   struct hwloc_group_attr_s {
00317     unsigned depth;                       
00318   } group;
00319 };
00320 
00335 HWLOC_DECLSPEC int hwloc_topology_init (hwloc_topology_t *topologyp);
00336 
00349 HWLOC_DECLSPEC int hwloc_topology_load(hwloc_topology_t topology);
00350 
00355 HWLOC_DECLSPEC void hwloc_topology_destroy (hwloc_topology_t topology);
00356 
00361 HWLOC_DECLSPEC void hwloc_topology_check(hwloc_topology_t topology);
00362 
00395 HWLOC_DECLSPEC int hwloc_topology_ignore_type(hwloc_topology_t topology, hwloc_obj_type_t type);
00396 
00403 HWLOC_DECLSPEC int hwloc_topology_ignore_type_keep_structure(hwloc_topology_t topology, hwloc_obj_type_t type);
00404 
00410 HWLOC_DECLSPEC int hwloc_topology_ignore_all_keep_structure(hwloc_topology_t topology);
00411 
00416 enum hwloc_topology_flags_e {
00417   HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM = (1<<0),
00426   HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = (1<<1)
00445 };
00446 
00451 HWLOC_DECLSPEC int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
00452 
00466 HWLOC_DECLSPEC int hwloc_topology_set_fsroot(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict fsroot_path);
00467 
00481 HWLOC_DECLSPEC int hwloc_topology_set_pid(hwloc_topology_t __hwloc_restrict topology, hwloc_pid_t pid);
00482 
00496 HWLOC_DECLSPEC int hwloc_topology_set_synthetic(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict description);
00497 
00509 HWLOC_DECLSPEC int hwloc_topology_set_xml(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict xmlpath);
00510 
00512 struct hwloc_topology_discovery_support {
00514   unsigned char pu;
00515 };
00516 
00518 struct hwloc_topology_cpubind_support {
00520   unsigned char set_thisproc_cpubind;
00522   unsigned char get_thisproc_cpubind;
00524   unsigned char set_proc_cpubind;
00526   unsigned char get_proc_cpubind;
00528   unsigned char set_thisthread_cpubind;
00530   unsigned char get_thisthread_cpubind;
00532   unsigned char set_thread_cpubind;
00534   unsigned char get_thread_cpubind;
00535 };
00536 
00543 struct hwloc_topology_support {
00544   struct hwloc_topology_discovery_support *discovery;
00545   struct hwloc_topology_cpubind_support *cpubind;
00546 };
00547 
00549 HWLOC_DECLSPEC const struct hwloc_topology_support *hwloc_topology_get_support(hwloc_topology_t __hwloc_restrict topology);
00550 
00563 HWLOC_DECLSPEC void hwloc_topology_export_xml(hwloc_topology_t topology, const char *xmlpath);
00564 
00574 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset, const char *name);
00575 
00585 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name);
00586 
00599 HWLOC_DECLSPEC unsigned hwloc_topology_get_depth(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
00600 
00610 HWLOC_DECLSPEC int hwloc_get_type_depth (hwloc_topology_t topology, hwloc_obj_type_t type);
00611 
00612 enum hwloc_get_type_depth_e {
00613     HWLOC_TYPE_DEPTH_UNKNOWN = -1, 
00614     HWLOC_TYPE_DEPTH_MULTIPLE = -2 
00615 };
00616 
00621 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_get_depth_type (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
00622 
00624 HWLOC_DECLSPEC unsigned hwloc_get_nbobjs_by_depth (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
00625 
00631 static __hwloc_inline int __hwloc_attribute_pure
00632 hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type)
00633 {
00634         int depth = hwloc_get_type_depth(topology, type);
00635         if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00636                 return 0;
00637         if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00638                 return -1; /* FIXME: agregate nbobjs from different levels? */
00639         return hwloc_get_nbobjs_by_depth(topology, depth);
00640 }
00641 
00649 HWLOC_DECLSPEC int hwloc_topology_is_thissystem(hwloc_topology_t  __hwloc_restrict topology) __hwloc_attribute_pure;
00650 
00660 HWLOC_DECLSPEC hwloc_obj_t hwloc_get_obj_by_depth (hwloc_topology_t topology, unsigned depth, unsigned idx) __hwloc_attribute_pure;
00661 
00668 static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure
00669 hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
00670 {
00671   int depth = hwloc_get_type_depth(topology, type);
00672   if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00673     return NULL;
00674   if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00675     return NULL;
00676   return hwloc_get_obj_by_depth(topology, depth, idx);
00677 }
00678 
00688 HWLOC_DECLSPEC const char * hwloc_obj_type_string (hwloc_obj_type_t type) __hwloc_attribute_const;
00689 
00694 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_obj_type_of_string (const char * string) __hwloc_attribute_pure;
00695 
00704 HWLOC_DECLSPEC int hwloc_obj_type_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj,
00705                                    int verbose);
00706 
00716 HWLOC_DECLSPEC int hwloc_obj_attr_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj, const char * __hwloc_restrict separator,
00717                                    int verbose);
00718 
00737 HWLOC_DECLSPEC int hwloc_obj_snprintf(char * __hwloc_restrict string, size_t size,
00738                              hwloc_topology_t topology, hwloc_obj_t obj,
00739                              const char * __hwloc_restrict indexprefix, int verbose);
00740 
00744 HWLOC_DECLSPEC int hwloc_obj_cpuset_snprintf(char * __hwloc_restrict str, size_t size, size_t nobj, const hwloc_obj_t * __hwloc_restrict objs);
00745 
00791 typedef enum {
00792   HWLOC_CPUBIND_PROCESS = (1<<0), 
00795   HWLOC_CPUBIND_THREAD = (1<<1),  
00797   HWLOC_CPUBIND_STRICT = (1<<2)   
00825 } hwloc_cpubind_policy_t;
00826 
00832 HWLOC_DECLSPEC int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set,
00833                             int policy);
00834 
00837 HWLOC_DECLSPEC int hwloc_get_cpubind(hwloc_topology_t topology, hwloc_cpuset_t set, int policy);
00838 
00846 HWLOC_DECLSPEC int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int policy);
00847 
00855 HWLOC_DECLSPEC int hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int policy);
00856 
00857 #ifdef hwloc_thread_t
00858 
00865 HWLOC_DECLSPEC int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int policy);
00866 #endif
00867 
00868 #ifdef hwloc_thread_t
00869 
00876 HWLOC_DECLSPEC int hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int policy);
00877 #endif
00878 
00882 #ifdef __cplusplus
00883 } /* extern "C" */
00884 #endif
00885 
00886 
00887 /* high-level helpers */
00888 #include <hwloc/helper.h>
00889 
00890 
00891 #endif /* HWLOC_H */

Generated on Thu Dec 16 2010 06:44:16 for Hardware Locality (hwloc) by  doxygen 1.7.1