• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List

hwloc.h

00001 /*
00002  * Copyright © 2009 CNRS
00003  * Copyright © 2009-2010 INRIA
00004  * Copyright © 2009-2010 Université Bordeaux 1
00005  * Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
00006  * See COPYING in top-level directory.
00007  */
00008 
00016 #ifndef HWLOC_H
00017 #define HWLOC_H
00018 
00019 #include <hwloc/config.h>
00020 #include <sys/types.h>
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include <limits.h>
00024 #ifdef HWLOC_HAVE_STDINT_H
00025 #include <stdint.h>
00026 #endif
00027 
00028 /*
00029  * Symbol transforms
00030  */
00031 #include <hwloc/rename.h>
00032 
00033 /*
00034  * Bitmap definitions
00035  */
00036 
00037 #include <hwloc/bitmap.h>
00038 #include <hwloc/cpuset.h>
00039 
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 
00051 #define HWLOC_API_VERSION 0x00010100
00052 
00061 struct hwloc_topology;
00066 typedef struct hwloc_topology * hwloc_topology_t;
00067 
00080 typedef hwloc_bitmap_t hwloc_cpuset_t;
00082 typedef hwloc_const_bitmap_t hwloc_const_cpuset_t;
00083 
00095 typedef hwloc_bitmap_t hwloc_nodeset_t;
00098 typedef hwloc_const_bitmap_t hwloc_const_nodeset_t;
00099 
00114 typedef enum {
00115   HWLOC_OBJ_SYSTEM,     
00120   HWLOC_OBJ_MACHINE,    
00125   HWLOC_OBJ_NODE,       
00129   HWLOC_OBJ_SOCKET,     
00133   HWLOC_OBJ_CACHE,      
00136   HWLOC_OBJ_CORE,       
00140   HWLOC_OBJ_PU,         
00149   HWLOC_OBJ_GROUP,      
00161   HWLOC_OBJ_MISC        
00165 } hwloc_obj_type_t;
00166 
00184 HWLOC_DECLSPEC int hwloc_compare_types (hwloc_obj_type_t type1, hwloc_obj_type_t type2) __hwloc_attribute_const;
00185 
00186 enum hwloc_compare_types_e {
00187     HWLOC_TYPE_UNORDERED = INT_MAX      
00188 };
00189 
00198 union hwloc_obj_attr_u;
00199 
00201 struct hwloc_obj_memory_s {
00202   uint64_t total_memory; 
00203   uint64_t local_memory; 
00205   unsigned page_types_len; 
00211   struct hwloc_obj_memory_page_type_s {
00212     uint64_t size;      
00213     uint64_t count;     
00214   } * page_types;
00215 };
00216 
00221 struct hwloc_obj {
00222   /* physical information */
00223   hwloc_obj_type_t type;                
00224   unsigned os_index;                    
00225   char *name;                           
00227   struct hwloc_obj_memory_s memory;     
00229   union hwloc_obj_attr_u *attr;         
00232   /* global position */
00233   unsigned depth;                       
00234   unsigned logical_index;               
00236   signed os_level;                      
00238   struct hwloc_obj *next_cousin;        
00239   struct hwloc_obj *prev_cousin;        
00241   /* parent */
00242   struct hwloc_obj *parent;             
00243   unsigned sibling_rank;                
00244   struct hwloc_obj *next_sibling;       
00245   struct hwloc_obj *prev_sibling;       
00247   /* children */
00248   unsigned arity;                       
00249   struct hwloc_obj **children;          
00250   struct hwloc_obj *first_child;        
00251   struct hwloc_obj *last_child;         
00253   /* misc */
00254   void *userdata;                       
00256   /* cpusets and nodesets */
00257   hwloc_cpuset_t cpuset;                
00270   hwloc_cpuset_t complete_cpuset;       
00281   hwloc_cpuset_t online_cpuset;         
00289   hwloc_cpuset_t allowed_cpuset;        
00300   hwloc_nodeset_t nodeset;              
00317   hwloc_nodeset_t complete_nodeset;     
00331   hwloc_nodeset_t allowed_nodeset;      
00344   struct hwloc_obj_info_s *infos;       
00345   unsigned infos_count;                 
00346 };
00350 typedef struct hwloc_obj * hwloc_obj_t;
00351 
00353 union hwloc_obj_attr_u {
00355   struct hwloc_cache_attr_s {
00356     uint64_t size;                        
00357     unsigned depth;                       
00358     unsigned linesize;                    
00359   } cache;
00361   struct hwloc_group_attr_s {
00362     unsigned depth;                       
00363   } group;
00364 };
00365 
00367 struct hwloc_obj_info_s {
00368   char *name;   
00369   char *value;  
00370 };
00371 
00386 HWLOC_DECLSPEC int hwloc_topology_init (hwloc_topology_t *topologyp);
00387 
00400 HWLOC_DECLSPEC int hwloc_topology_load(hwloc_topology_t topology);
00401 
00406 HWLOC_DECLSPEC void hwloc_topology_destroy (hwloc_topology_t topology);
00407 
00412 HWLOC_DECLSPEC void hwloc_topology_check(hwloc_topology_t topology);
00413 
00446 HWLOC_DECLSPEC int hwloc_topology_ignore_type(hwloc_topology_t topology, hwloc_obj_type_t type);
00447 
00454 HWLOC_DECLSPEC int hwloc_topology_ignore_type_keep_structure(hwloc_topology_t topology, hwloc_obj_type_t type);
00455 
00461 HWLOC_DECLSPEC int hwloc_topology_ignore_all_keep_structure(hwloc_topology_t topology);
00462 
00467 enum hwloc_topology_flags_e {
00468   HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM = (1<<0),
00477   HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM = (1<<1)
00496 };
00497 
00502 HWLOC_DECLSPEC int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
00503 
00517 HWLOC_DECLSPEC int hwloc_topology_set_fsroot(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict fsroot_path);
00518 
00532 HWLOC_DECLSPEC int hwloc_topology_set_pid(hwloc_topology_t __hwloc_restrict topology, hwloc_pid_t pid);
00533 
00547 HWLOC_DECLSPEC int hwloc_topology_set_synthetic(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict description);
00548 
00560 HWLOC_DECLSPEC int hwloc_topology_set_xml(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict xmlpath);
00561 
00567 HWLOC_DECLSPEC int hwloc_topology_set_xmlbuffer(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict buffer, int size);
00568 
00570 struct hwloc_topology_discovery_support {
00572   unsigned char pu;
00573 };
00574 
00576 struct hwloc_topology_cpubind_support {
00578   unsigned char set_thisproc_cpubind;
00580   unsigned char get_thisproc_cpubind;
00582   unsigned char set_proc_cpubind;
00584   unsigned char get_proc_cpubind;
00586   unsigned char set_thisthread_cpubind;
00588   unsigned char get_thisthread_cpubind;
00590   unsigned char set_thread_cpubind;
00592   unsigned char get_thread_cpubind;
00593 };
00594 
00596 struct hwloc_topology_membind_support {
00598   unsigned char set_thisproc_membind;
00600   unsigned char get_thisproc_membind;
00602   unsigned char set_proc_membind;
00604   unsigned char get_proc_membind;
00606   unsigned char set_thisthread_membind;
00608   unsigned char get_thisthread_membind;
00610   unsigned char set_area_membind;
00612   unsigned char get_area_membind;
00614   unsigned char alloc_membind;
00616   unsigned char firsttouch_membind;
00618   unsigned char bind_membind;
00620   unsigned char interleave_membind;
00622   unsigned char replicate_membind;
00624   unsigned char nexttouch_membind;
00625 
00627   unsigned char migrate_membind;
00628 };
00629 
00636 struct hwloc_topology_support {
00637   struct hwloc_topology_discovery_support *discovery;
00638   struct hwloc_topology_cpubind_support *cpubind;
00639   struct hwloc_topology_membind_support *membind;
00640 };
00641 
00643 HWLOC_DECLSPEC const struct hwloc_topology_support *hwloc_topology_get_support(hwloc_topology_t __hwloc_restrict topology);
00644 
00657 HWLOC_DECLSPEC void hwloc_topology_export_xml(hwloc_topology_t topology, const char *xmlpath);
00658 
00665 HWLOC_DECLSPEC void hwloc_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlbuffer, int *buflen);
00666 
00676 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset, const char *name);
00677 
00687 HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name);
00688 
00701 HWLOC_DECLSPEC unsigned hwloc_topology_get_depth(hwloc_topology_t __hwloc_restrict topology) __hwloc_attribute_pure;
00702 
00712 HWLOC_DECLSPEC int hwloc_get_type_depth (hwloc_topology_t topology, hwloc_obj_type_t type);
00713 
00714 enum hwloc_get_type_depth_e {
00715     HWLOC_TYPE_DEPTH_UNKNOWN = -1, 
00716     HWLOC_TYPE_DEPTH_MULTIPLE = -2 
00717 };
00718 
00723 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_get_depth_type (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
00724 
00726 HWLOC_DECLSPEC unsigned hwloc_get_nbobjs_by_depth (hwloc_topology_t topology, unsigned depth) __hwloc_attribute_pure;
00727 
00733 static __hwloc_inline int __hwloc_attribute_pure
00734 hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type)
00735 {
00736         int depth = hwloc_get_type_depth(topology, type);
00737         if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00738                 return 0;
00739         if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00740                 return -1; /* FIXME: agregate nbobjs from different levels? */
00741         return hwloc_get_nbobjs_by_depth(topology, depth);
00742 }
00743 
00751 HWLOC_DECLSPEC int hwloc_topology_is_thissystem(hwloc_topology_t  __hwloc_restrict topology) __hwloc_attribute_pure;
00752 
00762 HWLOC_DECLSPEC hwloc_obj_t hwloc_get_obj_by_depth (hwloc_topology_t topology, unsigned depth, unsigned idx) __hwloc_attribute_pure;
00763 
00770 static __hwloc_inline hwloc_obj_t __hwloc_attribute_pure
00771 hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
00772 {
00773   int depth = hwloc_get_type_depth(topology, type);
00774   if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
00775     return NULL;
00776   if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00777     return NULL;
00778   return hwloc_get_obj_by_depth(topology, depth, idx);
00779 }
00780 
00790 HWLOC_DECLSPEC const char * hwloc_obj_type_string (hwloc_obj_type_t type) __hwloc_attribute_const;
00791 
00796 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_obj_type_of_string (const char * string) __hwloc_attribute_pure;
00797 
00806 HWLOC_DECLSPEC int hwloc_obj_type_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj,
00807                                    int verbose);
00808 
00818 HWLOC_DECLSPEC int hwloc_obj_attr_snprintf(char * __hwloc_restrict string, size_t size, hwloc_obj_t obj, const char * __hwloc_restrict separator,
00819                                    int verbose);
00820 
00839 HWLOC_DECLSPEC int hwloc_obj_snprintf(char * __hwloc_restrict string, size_t size,
00840                              hwloc_topology_t topology, hwloc_obj_t obj,
00841                              const char * __hwloc_restrict indexprefix, int verbose);
00842 
00846 HWLOC_DECLSPEC int hwloc_obj_cpuset_snprintf(char * __hwloc_restrict str, size_t size, size_t nobj, const hwloc_obj_t * __hwloc_restrict objs);
00847 
00852 static __hwloc_inline char * __hwloc_attribute_pure
00853 hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name)
00854 {
00855   unsigned i;
00856   for(i=0; i<obj->infos_count; i++)
00857     if (!strcmp(obj->infos[i].name, name))
00858       return obj->infos[i].value;
00859   return NULL;
00860 }
00861 
00913 typedef enum {
00914   HWLOC_CPUBIND_PROCESS = (1<<0), 
00917   HWLOC_CPUBIND_THREAD = (1<<1),  
00919   HWLOC_CPUBIND_STRICT = (1<<2),  
00947   HWLOC_CPUBIND_NOMEMBIND = (1<<3)
00961 } hwloc_cpubind_flags_t;
00962 
00968 HWLOC_DECLSPEC int hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
00969 
00972 HWLOC_DECLSPEC int hwloc_get_cpubind(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
00973 
00981 HWLOC_DECLSPEC int hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags);
00982 
00990 HWLOC_DECLSPEC int hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
00991 
00992 #ifdef hwloc_thread_t
00993 
01000 HWLOC_DECLSPEC int hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int flags);
01001 #endif
01002 
01003 #ifdef hwloc_thread_t
01004 
01011 HWLOC_DECLSPEC int hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int flags);
01012 #endif
01013 
01054 typedef enum {
01055   HWLOC_MEMBIND_DEFAULT =       0,      
01057   HWLOC_MEMBIND_FIRSTTOUCH =    1,      
01060   HWLOC_MEMBIND_BIND =          2,      
01062   HWLOC_MEMBIND_INTERLEAVE =    3,      
01064   HWLOC_MEMBIND_REPLICATE =     4,      
01066   HWLOC_MEMBIND_NEXTTOUCH =     5       
01069 } hwloc_membind_policy_t;
01070 
01077 typedef enum {
01078   HWLOC_MEMBIND_PROCESS =       (1<<0), 
01081   HWLOC_MEMBIND_THREAD =        (1<<1), 
01084   HWLOC_MEMBIND_STRICT =        (1<<2), 
01089   HWLOC_MEMBIND_MIGRATE =       (1<<3), 
01093   HWLOC_MEMBIND_NOCPUBIND =     (1<<4)  
01106 } hwloc_membind_flags_t;
01107 
01113 HWLOC_DECLSPEC int hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
01114 
01120 HWLOC_DECLSPEC int hwloc_set_membind(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset, hwloc_membind_policy_t policy, int flags);
01121 
01124 HWLOC_DECLSPEC int hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
01125 
01128 HWLOC_DECLSPEC int hwloc_get_membind(hwloc_topology_t topology, hwloc_cpuset_t cpuset, hwloc_membind_policy_t * policy, int flags);
01129 
01135 HWLOC_DECLSPEC int hwloc_set_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
01136 
01142 HWLOC_DECLSPEC int hwloc_set_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t cpuset, hwloc_membind_policy_t policy, int flags);
01143 
01146 HWLOC_DECLSPEC int hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
01147 
01150 HWLOC_DECLSPEC int hwloc_get_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t cpuset, hwloc_membind_policy_t * policy, int flags);
01151 
01157 HWLOC_DECLSPEC int hwloc_set_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
01158 
01164 HWLOC_DECLSPEC int hwloc_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_cpuset_t cpuset, hwloc_membind_policy_t policy, int flags);
01165 
01168 HWLOC_DECLSPEC int hwloc_get_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
01169 
01172 HWLOC_DECLSPEC int hwloc_get_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_cpuset_t cpuset, hwloc_membind_policy_t * policy, int flags);
01173 
01181 HWLOC_DECLSPEC void *hwloc_alloc(hwloc_topology_t topology, size_t len);
01182 
01192 HWLOC_DECLSPEC void *hwloc_alloc_membind_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc;
01193 
01203 HWLOC_DECLSPEC void *hwloc_alloc_membind(hwloc_topology_t topology, size_t len, hwloc_const_cpuset_t cpuset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc;
01204 
01207 HWLOC_DECLSPEC int hwloc_free(hwloc_topology_t topology, void *addr, size_t len);
01208 
01212 #ifdef __cplusplus
01213 } /* extern "C" */
01214 #endif
01215 
01216 
01217 /* high-level helpers */
01218 #include <hwloc/helper.h>
01219 
01220 
01221 #endif /* HWLOC_H */

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