Skip to content

Commit a931fa6

Browse files
committed
distances: also group by hops
Not only by latency. Signed-off-by: Brice Goglin <[email protected]>
1 parent b95d0df commit a931fa6

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

hwloc/distances.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,7 @@ hwloc__groups_by_distances(struct hwloc_topology *topology,
12031203
if (nbobjs <= 2)
12041204
return;
12051205

1206-
if (!(kind & HWLOC_DISTANCES_KIND_VALUE_LATENCY))
1207-
/* don't know use to use those for grouping */
1206+
if (!(kind & (HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_VALUE_HOPS)))
12081207
/* TODO hwloc__find_groups_by_max_distance() for bandwidth */
12091208
return;
12101209

include/hwloc/distances.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ HWLOC_DECLSPEC int hwloc_distances_add_values(hwloc_topology_t topology,
411411
/** \brief Flags for adding a new distances to a topology. */
412412
enum hwloc_distances_add_flag_e {
413413
/** \brief Try to group objects based on the newly provided distance information.
414-
* Grouping is only performed when the distances structure contains latencies,
414+
* Grouping is only performed when the distances structure contains latencies or hops,
415415
* and when all objects are of the same type.
416416
* \hideinitializer
417417
*/

tests/hwloc/hwloc_distances.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int main(void)
170170
for(i=0; i<16; i++)
171171
values[i+16*i] = 1;
172172
handle = hwloc_distances_add_create(topology, NULL,
173-
HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER,
173+
HWLOC_DISTANCES_KIND_VALUE_HOPS|HWLOC_DISTANCES_KIND_FROM_USER,
174174
0);
175175
assert(handle);
176176
err = hwloc_distances_add_values(topology, handle, 16, objs, values, 0);
@@ -197,7 +197,7 @@ int main(void)
197197
assert(nr == 1);
198198
assert(distances[0]);
199199
assert(distances[0]->values);
200-
assert(distances[0]->kind == (HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER));
200+
assert(distances[0]->kind == (HWLOC_DISTANCES_KIND_VALUE_HOPS|HWLOC_DISTANCES_KIND_FROM_USER));
201201
/* check that some random values are ok */
202202
assert(distances[0]->values[0] == 1); /* diagonal */
203203
assert(distances[0]->values[1] == 2); /* same group */
@@ -289,11 +289,11 @@ int main(void)
289289
assert(distances[1]->kind == (HWLOC_DISTANCES_KIND_VALUE_BANDWIDTH|HWLOC_DISTANCES_KIND_FROM_USER|HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES));
290290
hwloc_distances_release(topology, distances[1]);
291291
nr = 2;
292-
err = hwloc_distances_get(topology, &nr, distances, HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_FROM_OS, 0);
292+
err = hwloc_distances_get(topology, &nr, distances, HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_VALUE_HOPS|HWLOC_DISTANCES_KIND_FROM_OS, 0);
293293
assert(!err);
294294
assert(nr == 0);
295295
nr = 2;
296-
err = hwloc_distances_get(topology, &nr, distances, HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_FROM_USER, 0);
296+
err = hwloc_distances_get(topology, &nr, distances, HWLOC_DISTANCES_KIND_VALUE_LATENCY|HWLOC_DISTANCES_KIND_VALUE_HOPS|HWLOC_DISTANCES_KIND_FROM_USER, 0);
297297
assert(!err);
298298
assert(nr == 2);
299299
hwloc_distances_release(topology, distances[0]);

0 commit comments

Comments
 (0)