@@ -199,6 +199,10 @@ int main(void)
199
199
check (topology , 3 , 3 , 3 , 11 );
200
200
check_distances (topology , 3 , 3 );
201
201
202
+ /* duplicate/checkpoint to the current topology for additional testing */
203
+ err = hwloc_topology_dup (& topology2 , topology );
204
+ assert (!err );
205
+
202
206
/* only keep three PUs (first and last of first core, and last of last core of second node) */
203
207
printf ("restricting to 3 PUs in 2 cores in 2 nodes, and remove the CPU-less node, and auto-merge groups\n" );
204
208
hwloc_bitmap_zero (cpuset );
@@ -210,6 +214,26 @@ int main(void)
210
214
check (topology , 0 , 2 , 2 , 3 );
211
215
check_distances (topology , 2 , 2 );
212
216
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
+
213
237
/* restrict to the third node, impossible */
214
238
printf ("restricting to only some already removed node, must fail\n" );
215
239
hwloc_bitmap_zero (cpuset );
@@ -247,6 +271,11 @@ int main(void)
247
271
assert (!err );
248
272
hwloc_topology_check (topology );
249
273
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 );
250
279
printf ("further restricting bynodeset to a single numa node\n" );
251
280
hwloc_bitmap_only (cpuset , 1 );
252
281
err = hwloc_topology_restrict (topology , cpuset , HWLOC_RESTRICT_FLAG_BYNODESET |HWLOC_RESTRICT_FLAG_REMOVE_MEMLESS );
@@ -285,6 +314,19 @@ int main(void)
285
314
assert (!err );
286
315
hwloc_topology_destroy (topology );
287
316
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
+
288
330
hwloc_bitmap_free (cpuset );
289
331
290
332
return 0 ;
0 commit comments