Skip to content

Commit c0d3113

Browse files
committed
test: reverse of rank0/1 for pu
Signed-off-by: vsoch <[email protected]>
1 parent d45b66e commit c0d3113

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

fluxbind/graph/graphic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def _build_contextual_subgraph(self):
7979
if data.get("type") not in ["Core", "PU"]
8080
]
8181
final_subgraph.remove_nodes_from(nodes_to_remove)
82-
8382
return final_subgraph
8483

8584
def draw(self, filename: str):
86.2 KB
Loading
85.8 KB
Loading

tests/test_single_node.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)