Hardware Locality (hwloc)
v2.2-20200408.0300.gitad4a86f
|
00001 /* 00002 * Copyright © 2010-2019 Inria. All rights reserved. 00003 * See COPYING in top-level directory. 00004 */ 00005 00010 #ifndef HWLOC_DISTANCES_H 00011 #define HWLOC_DISTANCES_H 00012 00013 #ifndef HWLOC_H 00014 #error Please include the main hwloc.h instead 00015 #endif 00016 00017 00018 #ifdef __cplusplus 00019 extern "C" { 00020 #elif 0 00021 } 00022 #endif 00023 00024 00041 struct hwloc_distances_s { 00042 unsigned nbobjs; 00043 hwloc_obj_t *objs; 00048 unsigned long kind; 00049 hwloc_uint64_t *values; 00054 }; 00055 00067 enum hwloc_distances_kind_e { 00071 HWLOC_DISTANCES_KIND_FROM_OS = (1UL<<0), 00075 HWLOC_DISTANCES_KIND_FROM_USER = (1UL<<1), 00076 00083 HWLOC_DISTANCES_KIND_MEANS_LATENCY = (1UL<<2), 00090 HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH = (1UL<<3), 00091 00095 HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES = (1UL<<4) 00096 }; 00097 00121 HWLOC_DECLSPEC int 00122 hwloc_distances_get(hwloc_topology_t topology, 00123 unsigned *nr, struct hwloc_distances_s **distances, 00124 unsigned long kind, unsigned long flags); 00125 00130 HWLOC_DECLSPEC int 00131 hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth, 00132 unsigned *nr, struct hwloc_distances_s **distances, 00133 unsigned long kind, unsigned long flags); 00134 00139 HWLOC_DECLSPEC int 00140 hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type, 00141 unsigned *nr, struct hwloc_distances_s **distances, 00142 unsigned long kind, unsigned long flags); 00143 00148 HWLOC_DECLSPEC int 00149 hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name, 00150 unsigned *nr, struct hwloc_distances_s **distances, 00151 unsigned long flags); 00152 00158 HWLOC_DECLSPEC const char * 00159 hwloc_distances_get_name(hwloc_topology_t topology, struct hwloc_distances_s *distances); 00160 00165 HWLOC_DECLSPEC void 00166 hwloc_distances_release(hwloc_topology_t topology, struct hwloc_distances_s *distances); 00167 00180 static __hwloc_inline int 00181 hwloc_distances_obj_index(struct hwloc_distances_s *distances, hwloc_obj_t obj) 00182 { 00183 unsigned i; 00184 for(i=0; i<distances->nbobjs; i++) 00185 if (distances->objs[i] == obj) 00186 return (int)i; 00187 return -1; 00188 } 00189 00197 static __hwloc_inline int 00198 hwloc_distances_obj_pair_values(struct hwloc_distances_s *distances, 00199 hwloc_obj_t obj1, hwloc_obj_t obj2, 00200 hwloc_uint64_t *value1to2, hwloc_uint64_t *value2to1) 00201 { 00202 int i1 = hwloc_distances_obj_index(distances, obj1); 00203 int i2 = hwloc_distances_obj_index(distances, obj2); 00204 if (i1 < 0 || i2 < 0) 00205 return -1; 00206 *value1to2 = distances->values[i1 * distances->nbobjs + i2]; 00207 *value2to1 = distances->values[i2 * distances->nbobjs + i1]; 00208 return 0; 00209 } 00210 00220 enum hwloc_distances_add_flag_e { 00224 HWLOC_DISTANCES_ADD_FLAG_GROUP = (1UL<<0), 00230 HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE = (1UL<<1) 00231 }; 00232 00247 HWLOC_DECLSPEC int hwloc_distances_add(hwloc_topology_t topology, 00248 unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values, 00249 unsigned long kind, unsigned long flags); 00250 00259 HWLOC_DECLSPEC int hwloc_distances_remove(hwloc_topology_t topology); 00260 00265 HWLOC_DECLSPEC int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth); 00266 00271 static __hwloc_inline int 00272 hwloc_distances_remove_by_type(hwloc_topology_t topology, hwloc_obj_type_t type) 00273 { 00274 int depth = hwloc_get_type_depth(topology, type); 00275 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE) 00276 return 0; 00277 return hwloc_distances_remove_by_depth(topology, depth); 00278 } 00279 00284 HWLOC_DECLSPEC int hwloc_distances_release_remove(hwloc_topology_t topology, struct hwloc_distances_s *distances); 00285 00289 #ifdef __cplusplus 00290 } /* extern "C" */ 00291 #endif 00292 00293 00294 #endif /* HWLOC_DISTANCES_H */