00001
00002
00003
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 };
00092
00115 HWLOC_DECLSPEC int
00116 hwloc_distances_get(hwloc_topology_t topology,
00117 unsigned *nr, struct hwloc_distances_s **distances,
00118 unsigned long kind, unsigned long flags);
00119
00124 HWLOC_DECLSPEC int
00125 hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
00126 unsigned *nr, struct hwloc_distances_s **distances,
00127 unsigned long kind, unsigned long flags);
00128
00133 static __hwloc_inline int
00134 hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
00135 unsigned *nr, struct hwloc_distances_s **distances,
00136 unsigned long kind, unsigned long flags)
00137 {
00138 int depth = hwloc_get_type_depth(topology, type);
00139 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE) {
00140 *nr = 0;
00141 return 0;
00142 }
00143 return hwloc_distances_get_by_depth(topology, depth, nr, distances, kind, flags);
00144 }
00145
00147 HWLOC_DECLSPEC void
00148 hwloc_distances_release(hwloc_topology_t topology, struct hwloc_distances_s *distances);
00149
00162 static __hwloc_inline int
00163 hwloc_distances_obj_index(struct hwloc_distances_s *distances, hwloc_obj_t obj)
00164 {
00165 unsigned i;
00166 for(i=0; i<distances->nbobjs; i++)
00167 if (distances->objs[i] == obj)
00168 return (int)i;
00169 return -1;
00170 }
00171
00179 static __hwloc_inline int
00180 hwloc_distances_obj_pair_values(struct hwloc_distances_s *distances,
00181 hwloc_obj_t obj1, hwloc_obj_t obj2,
00182 hwloc_uint64_t *value1to2, hwloc_uint64_t *value2to1)
00183 {
00184 int i1 = hwloc_distances_obj_index(distances, obj1);
00185 int i2 = hwloc_distances_obj_index(distances, obj2);
00186 if (i1 < 0 || i2 < 0)
00187 return -1;
00188 *value1to2 = distances->values[i1 * distances->nbobjs + i2];
00189 *value2to1 = distances->values[i2 * distances->nbobjs + i1];
00190 return 0;
00191 }
00192
00202 enum hwloc_distances_add_flag_e {
00206 HWLOC_DISTANCES_ADD_FLAG_GROUP = (1UL<<0),
00212 HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE = (1UL<<1)
00213 };
00214
00229 HWLOC_DECLSPEC int hwloc_distances_add(hwloc_topology_t topology,
00230 unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values,
00231 unsigned long kind, unsigned long flags);
00232
00241 HWLOC_DECLSPEC int hwloc_distances_remove(hwloc_topology_t topology);
00242
00247 HWLOC_DECLSPEC int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth);
00248
00253 static __hwloc_inline int
00254 hwloc_distances_remove_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
00255 {
00256 int depth = hwloc_get_type_depth(topology, type);
00257 if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
00258 return 0;
00259 return hwloc_distances_remove_by_depth(topology, depth);
00260 }
00261
00265 #ifdef __cplusplus
00266 }
00267 #endif
00268
00269
00270 #endif