Skip to content

Commit eebbf28

Browse files
perarnauiskra-anl
andauthored
[fix] bugs in numa distance logic (#236)
* area_preferred relies on qsort for sorting numa nodes. qsort expects negative,0,positive return values, instead of just 0,1. * Rename arguments of OBJ_DIST to be less confusing. * fix cpu to numa distance iteration * area hwloc preferred local is wrong on numa systems --------- Co-authored-by: Kamil Iskra <[email protected]>
1 parent 91a9302 commit eebbf28

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/backend/hwloc.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
hwloc_topology_t aml_topology;
1818
hwloc_const_bitmap_t allowed_nodeset;
1919

20-
#define OBJ_DIST(dist, i, j, row_stride, col_stride) \
21-
(dist)->values[((i)->logical_index + row_stride) * (dist)->nbobjs + \
22-
col_stride + (j)->logical_index]
20+
#define OBJ_DIST(dist, i, j, row_offset, col_offset) \
21+
(dist)->values[((i)->logical_index + row_offset) * (dist)->nbobjs + \
22+
col_offset + (j)->logical_index]
2323

2424
#define IND_DIST(dist, i, j) (dist)->values[(i) * (dist)->nbobjs + (j)]
2525

@@ -99,7 +99,12 @@ int aml_hwloc_distance_lt(const void *a_ptr, const void *b_ptr)
9999
{
100100
struct aml_hwloc_distance *a = (struct aml_hwloc_distance *)a_ptr;
101101
struct aml_hwloc_distance *b = (struct aml_hwloc_distance *)b_ptr;
102-
return a->distance < b->distance;
102+
if (a->distance < b->distance)
103+
return -1;
104+
else if (a->distance > b->distance)
105+
return 1;
106+
else
107+
return 0;
103108
}
104109

105110
/**
@@ -346,7 +351,7 @@ static int aml_hwloc_distances_reshape(struct hwloc_distances_s *dist,
346351
goto err_with_out;
347352
OBJ_DIST(*out, obj0, obj1, 0, nt0) = d0;
348353
OBJ_DIST(*out, obj1, obj0, nt0, 0) = d1;
349-
obj1 = hwloc_get_next_obj_by_depth(aml_topology, depth0,
354+
obj1 = hwloc_get_next_obj_by_depth(aml_topology, depth1,
350355
obj1);
351356
}
352357
obj0 = hwloc_get_next_obj_by_depth(aml_topology, depth0, obj0);

tests/area/test_hwloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void test_preferred()
210210
AML_SUCCESS);
211211

212212
data = (struct aml_area_hwloc_preferred_data *)area->data;
213-
assert(data->numanodes[data->num_nodes - 1] == NUMANODE);
213+
assert(data->numanodes[0] == NUMANODE);
214214

215215
aml_area_hwloc_preferred_destroy(&area);
216216
}

0 commit comments

Comments
 (0)