4import toolbox.loadbalancing.api.output.Hardcoded
as Hardcoded
5import toolbox.loadbalancing.api.strategies.Decomposition
as Decomposition
6import toolbox.loadbalancing.api.strategies.SplitTrees
as split_strategy
10 """Split the 27x27 mesh of tutorial 35 into number_of_subtrees subtrees"""
12 split_strategy.split_tree(
15 peano_tree=tree, number_of_subtrees=number_of_subtrees
17 periodic_BC=periodic_BC,
23 counts = [0] * number_of_subtrees
26 weight, subtree = tree._tree_arrays[2][a][b]
27 counts[subtree] += weight
37 """All cells along a periodic boundary remain on subtree 0, and the shares still add up."""
41 if min(a, b) == 0
or max(a, b) == 26:
42 assert tree._tree_arrays[2][a][b][1] == 0, (a, b)
47 """Only the faces of periodic axes are kept on subtree 0."""
49 owners_along_x_faces = {
50 tree._tree_arrays[2][a][b][1]
for a
in (0, 26)
for b
in range(27)
52 owners_along_y_faces = {
53 tree._tree_arrays[2][a][b][1]
for a
in range(27)
for b
in (0, 26)
55 assert owners_along_x_faces == {0}
56 assert owners_along_y_faces != {0}
60 """periodic_BC=None and all-False yield the same decomposition."""
63 assert (plain._tree_arrays[2] == non_periodic._tree_arrays[2]).all()
73 configuration, mode = Hardcoded.create_constructor_initialisation_string(
74 tree, [0, 0, 0], modes=Hardcoded.BottomUp
76 assert mode ==
"peano4::SplitInstruction::Mode::BottomUp"
79 ==
"{{0, 0, 0}, {182, 182, 182}, {0, 0, 0}, peano4::SplitInstruction::Mode::BottomUp}"
85 configuration, mode = Hardcoded.create_constructor_initialisation_string(
88 modes=[Hardcoded.TopDown, Hardcoded.TopDown, Hardcoded.BottomUp],
91 "{peano4::SplitInstruction::Mode::AggressiveTopDown, "
92 "peano4::SplitInstruction::Mode::AggressiveTopDown, "
93 "peano4::SplitInstruction::Mode::BottomUp}"
95 assert configuration.endswith(mode +
"}")
98@pytest.mark.parametrize("modes", [[Hardcoded.BottomUp], ["sideways"] * 3])
101 with pytest.raises(ValueError):
102 Hardcoded.create_constructor_initialisation_string(tree, [0, 0, 0], modes=modes)
110@pytest.mark.parametrize("number_of_ranks", [1, 2, 3, 8])
113 destination_ranks = Hardcoded.assign_trees_to_ranks_round_Robin(
114 number_of_subtrees=8, max_ranks=number_of_ranks
116 Hardcoded.create_constructor_initialisation_string(
117 tree, destination_ranks, number_of_ranks=number_of_ranks
122 """Subtree s has to live on rank s%R, as Peano numbers its trees round robin."""
124 with pytest.raises(ValueError):
125 Hardcoded.create_constructor_initialisation_string(tree, [1, 1, 1, 2, 2, 2, 0])
129 """Round robin over three ranks is no round robin over four ranks."""
131 destination_ranks = Hardcoded.assign_trees_to_ranks_round_Robin(
132 number_of_subtrees=8, max_ranks=3
134 with pytest.raises(ValueError):
135 Hardcoded.create_constructor_initialisation_string(
136 tree, destination_ranks, number_of_ranks=4
equidistant_splitting(Tree peano_tree, int number_of_subtrees, verbose=False)
test_periodic_frame_only_along_periodic_axes()
Only the faces of periodic axes are kept on subtree 0.
test_no_periodic_boundaries_keeps_plain_split()
periodic_BC=None and all-False yield the same decomposition.
test_single_marker_holds_for_all_splits()
_cells_per_subtree(tree, number_of_subtrees)
test_invalid_markers_are_rejected(modes)
test_periodic_frame_stays_on_subtree_zero()
All cells along a periodic boundary remain on subtree 0, and the shares still add up.
test_other_assignments_are_rejected()
Subtree s has to live on rank sR, as Peano numbers its trees round robin.
test_number_of_ranks_is_taken_into_account()
Round robin over three ranks is no round robin over four ranks.
_split_regular_grid(number_of_subtrees, periodic_BC=None)
Split the 27x27 mesh of tutorial 35 into number_of_subtrees subtrees.
test_round_robin_assignment_is_accepted(number_of_ranks)
test_one_marker_per_split()