5Create the quantised-decomposition PNG of the tutorial 35_offline-load-balancing.ipynb
7The script computes two offline decompositions of the tutorial's regular
8mesh along Peano's space-filling curve, the equidistant one and the quantised
9one, keeps the cells along the periodic boundary on tree 0, and draws them next
10to each other. It does not build or run anything. Call it from anywhere:
12 python3 tutorials/exahype2/illustrations/35_offline-load-balancing-quantised.py
14The script needs matplotlib, but no ParaView.
24import matplotlib.pyplot
as plt
26Here = os.path.dirname(os.path.abspath(__file__))
29_specification = importlib.util.spec_from_file_location(
30 "plan_vs_run_illustrations",
31 os.path.join(Here,
"35_offline-load-balancing-plan-vs-run.py"),
33plan_vs_run = importlib.util.module_from_spec(_specification)
34_specification.loader.exec_module(plan_vs_run)
37import toolbox.loadbalancing.api.strategies.Decomposition
as Decomposition
38import toolbox.loadbalancing.api.strategies.SplitTrees
as SplitTrees
40QuantisedPicture = os.path.join(Here,
"35_offline-load-balancing-quantised.png")
41NumberOfSubtrees = plan_vs_run.domain_decomposition.NumberOfThreads
42CellsPerAxis = plan_vs_run.CellsPerAxis
47 Owner of each fine grid cell after the offline decomposition
49 @param quantised: Bool
50 Quantised instead of equidistant chunk sizes
55 peano_tree=tree, number_of_subtrees=NumberOfSubtrees, dimension=2
59 peano_tree=tree, number_of_subtrees=NumberOfSubtrees
62 owner = np.zeros((CellsPerAxis, CellsPerAxis), dtype=int)
63 for x
in range(CellsPerAxis):
64 for y
in range(CellsPerAxis):
65 owner[y, x] = tree._tree_arrays[2][x][y][1]
69if __name__ ==
"__main__":
70 figure, axes = plt.subplots(1, 2, figsize=(9.0, 5.2))
71 plan_vs_run.draw(axes[0],
owner_of_cells(
False),
"Equidistant decomposition")
72 plan_vs_run.draw(axes[1],
owner_of_cells(
True),
"Quantised decomposition")
74 plt.savefig(QuantisedPicture, dpi=130, bbox_inches=
"tight")
75 print(
"wrote {}".format(QuantisedPicture))
owner_of_cells(quantised)
Owner of each fine grid cell after the offline decomposition.
quantised_splitting(Tree peano_tree, int number_of_subtrees, int dimension, verbose=False)
Quantised splitting.
equidistant_splitting(Tree peano_tree, int number_of_subtrees, verbose=False)
RegularGridGenerator(name=None, max_level=None, dimensions=None)
Generate an artificial regular grid with uniform refinement for testing purposes.
tuple[str, str] split_tree(Tree peano_tree, decomposition, str traversal="bfs_finest_first", bool enable_propagate_bottom_up=False, bool enable_optimize_hierarchy=False, bool require_all_children_for_hierarchy_optimization=True, list[bool]|None periodic_BC=None, bool verbose=False)
Split a tree using a staged load-balancing workflow.