Skip to content

Commit f2724bb

Browse files
committed
tests/restrict: add some redundant restrict()
Apply the same restrict twice, or once with and once without REMOVE_CPULESS. Regression tests for #575 Signed-off-by: Brice Goglin <[email protected]>
1 parent f8000a5 commit f2724bb

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/hwloc/hwloc_topology_restrict.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ int main(void)
199199
check(topology, 3, 3, 3, 11);
200200
check_distances(topology, 3, 3);
201201

202+
/* duplicate/checkpoint to the current topology for additional testing */
203+
err = hwloc_topology_dup(&topology2, topology);
204+
assert(!err);
205+
202206
/* only keep three PUs (first and last of first core, and last of last core of second node) */
203207
printf("restricting to 3 PUs in 2 cores in 2 nodes, and remove the CPU-less node, and auto-merge groups\n");
204208
hwloc_bitmap_zero(cpuset);
@@ -210,6 +214,26 @@ int main(void)
210214
check(topology, 0, 2, 2, 3);
211215
check_distances(topology, 2, 2);
212216

217+
/* only keep three PUs (first and last of first core, and last of last core of second node) */
218+
printf("do the same on the duplicated topology, with multiple intermediate restricts\n");
219+
hwloc_bitmap_zero(cpuset);
220+
hwloc_bitmap_set(cpuset, 0);
221+
hwloc_bitmap_set(cpuset, 3);
222+
hwloc_bitmap_set(cpuset, 15);
223+
err = hwloc_topology_restrict(topology2, cpuset, 0);
224+
assert(!err);
225+
check(topology2, 3, 3, 2, 3);
226+
check_distances(topology2, 3, 2);
227+
err = hwloc_topology_restrict(topology2, cpuset, 0);
228+
assert(!err);
229+
check(topology2, 3, 3, 2, 3);
230+
check_distances(topology2, 3, 2);
231+
err = hwloc_topology_restrict(topology2, cpuset, HWLOC_RESTRICT_FLAG_REMOVE_CPULESS);
232+
assert(!err);
233+
check(topology2, 0, 2, 2, 3);
234+
check_distances(topology2, 2, 2);
235+
hwloc_topology_destroy(topology2);
236+
213237
/* restrict to the third node, impossible */
214238
printf("restricting to only some already removed node, must fail\n");
215239
hwloc_bitmap_zero(cpuset);
@@ -247,6 +271,11 @@ int main(void)
247271
assert(!err);
248272
hwloc_topology_check(topology);
249273
check(topology, 3, 2, 6, 24);
274+
printf("applying exact same restriction again\n");
275+
err = hwloc_topology_restrict(topology, cpuset, HWLOC_RESTRICT_FLAG_BYNODESET);
276+
assert(!err);
277+
hwloc_topology_check(topology);
278+
check(topology, 3, 2, 6, 24);
250279
printf("further restricting bynodeset to a single numa node\n");
251280
hwloc_bitmap_only(cpuset, 1);
252281
err = hwloc_topology_restrict(topology, cpuset, HWLOC_RESTRICT_FLAG_BYNODESET|HWLOC_RESTRICT_FLAG_REMOVE_MEMLESS);
@@ -285,6 +314,19 @@ int main(void)
285314
assert(!err);
286315
hwloc_topology_destroy(topology);
287316

317+
/* again with intermediate restricts */
318+
printf("do the same on the duplicated topology, with multiple intermediate restricts\n");
319+
hwloc_topology_init(&topology);
320+
hwloc_topology_set_synthetic(topology, "pack:2 l3:2 numa:1 pu:1(indexes=0,2,1,3)");
321+
hwloc_topology_load(topology);
322+
hwloc_bitmap_zero(cpuset);
323+
hwloc_bitmap_set_range(cpuset, 1, 2);
324+
err = hwloc_topology_restrict(topology, cpuset, HWLOC_RESTRICT_FLAG_BYNODESET);
325+
assert(!err);
326+
err = hwloc_topology_restrict(topology, cpuset, HWLOC_RESTRICT_FLAG_BYNODESET|HWLOC_RESTRICT_FLAG_REMOVE_MEMLESS);
327+
assert(!err);
328+
hwloc_topology_destroy(topology);
329+
288330
hwloc_bitmap_free(cpuset);
289331

290332
return 0;

0 commit comments

Comments
 (0)