@@ -226,6 +226,52 @@ def test_08_explicit_core_binding_multi_rank(self):
226226 self .assertEqual (result_rank1 .mask , "0x00000050" )
227227 self .assertEqual (len (result_rank1 .nodes ), 2 )
228228
229+ def test_09_explicit_bind_pu_reverse_multi_rank (self ):
230+ """
231+ Test: Ask for 4 cores, bind to PUs in REVERSE, divide among 2 ranks.
232+ This validates the `reverse: true` modifier with `bind: pu`.
233+ """
234+ print ("\n --- Testing: Explicit `bind: pu` with `reverse: true` (Multi-Rank) ---" )
235+ shape_yaml = """
236+ options:
237+ bind: pu
238+ resources:
239+ - type: core
240+ count: 4
241+ reverse: true
242+ """
243+ # The total pool of resources will be all PUs on the first 4 cores,
244+ # but the list will be reversed.
245+ # Initial PUs: [PU0, PU1, PU2, PU3, PU4, PU5, PU6, PU7]
246+ # Reversed PUs: [PU7, PU6, PU5, PU4, PU3, PU2, PU1, PU0]
247+ # local_size = 2, so items_per_rank = 8 // 2 = 4.
248+
249+ # We expect this rank to get the first 4 PUs from the REVERSED list:
250+ # PUs 7, 6, 5, 4.
251+ # The mask for these is 0x80 | 0x40 | 0x20 | 0x10 = 0xF0
252+ result_rank0 = self .run_test_case (
253+ shape_yaml ,
254+ local_rank = 0 ,
255+ local_size = 2 ,
256+ output_filename = "09_explicit_pu_reverse_rank0.png" ,
257+ title = "Explicit PU Binding, Reversed: Rank 0 of 2" ,
258+ )
259+ self .assertEqual (result_rank0 .mask , "0x000000f0" )
260+ self .assertEqual (len (result_rank0 .nodes ), 4 )
261+
262+ # We expect this rank to get the next 4 PUs from the REVERSED list:
263+ # PUs 3, 2, 1, 0.
264+ # The mask for these is 0x8 | 0x4 | 0x2 | 0x1 = 0xF
265+ result_rank1 = self .run_test_case (
266+ shape_yaml ,
267+ local_rank = 1 ,
268+ local_size = 2 ,
269+ output_filename = "09_explicit_pu_reverse_rank1.png" ,
270+ title = "Explicit PU Binding, Reversed: Rank 1 of 2" ,
271+ )
272+ self .assertEqual (result_rank1 .mask , "0x0000000f" )
273+ self .assertEqual (len (result_rank1 .nodes ), 4 )
274+
229275
230276@unittest .skipUnless (
231277 os .path .exists (TEST_GPU_XML_FILE ), f"Skipping GPU tests, { TEST_GPU_XML_FILE } not found."
0 commit comments