Peano
Loading...
Searching...
No Matches
api.output.Hardcoded Namespace Reference

Functions

 assign_trees_to_ranks_round_Robin (int number_of_subtrees, int max_ranks)
 Take the trees and assign them to the ranks in a round-robin fashion.
 
 _format_initialisation_lists (parent_trees, subpartition_sizes, destination_ranks)
 Turn the enumerated splits into the C++ initialiser lists of Hardcoded.
 
 _markers_from_flags (bottom_up_flags)
 Translate the per-split flags of extract_split_instructions() into markers.
 
 _normalise_markers (modes, number_of_splits)
 Turn the user's modes argument into one marker per split.
 
 _format_modes (markers)
 Turn the markers into the C++ mode argument of Hardcoded.
 
 _normalise_destination_ranks (destination_ranks, subtrees)
 Normalise destination rank input to one rank per split instruction.
 
 _validate_round_robin (subtrees, destination_ranks, number_of_ranks=None)
 Ensure that the subtrees are assigned to the ranks round robin.
 
tuple[str, str] create_constructor_initialisation_string ("Tree" peano_tree, list[int] destination_ranks, bool verbose=False, modes=None, int|None number_of_ranks=None)
 Construct the constructor arguments for an instance of Hardcoded.
 

Variables

str TopDown = "top-down"
 
str BottomUp = "bottom-up"
 
dict _CppModes
 

Function Documentation

◆ _format_initialisation_lists()

api.output.Hardcoded._format_initialisation_lists (   parent_trees,
  subpartition_sizes,
  destination_ranks 
)
protected

Turn the enumerated splits into the C++ initialiser lists of Hardcoded.

Entry k of each list describes the kth split.

Parameters
parent_trees[int] Tree which splits in the kth split.
subpartition_sizes[int] Number of cells that the kth split hands over.
destination_ranks[int] Rank which receives the new tree of the kth split.

Definition at line 41 of file Hardcoded.py.

Referenced by api.output.Hardcoded.create_constructor_initialisation_string().

Here is the caller graph for this function:

◆ _format_modes()

api.output.Hardcoded._format_modes (   markers)
protected

Turn the markers into the C++ mode argument of Hardcoded.

The result is a single mode if all splits share the same mode, and an initialiser list with one mode per split otherwise.

Parameters
markers[str] One marker per split.

Definition at line 117 of file Hardcoded.py.

Referenced by api.output.Hardcoded.create_constructor_initialisation_string().

Here is the caller graph for this function:

◆ _markers_from_flags()

api.output.Hardcoded._markers_from_flags (   bottom_up_flags)
protected

Translate the per-split flags of extract_split_instructions() into markers.

Parameters
bottom_up_flags[bool] True means that the corresponding split is a bottom-up split.

Definition at line 75 of file Hardcoded.py.

Referenced by api.output.Hardcoded.create_constructor_initialisation_string().

Here is the caller graph for this function:

◆ _normalise_destination_ranks()

api.output.Hardcoded._normalise_destination_ranks (   destination_ranks,
  subtrees 
)
protected

Normalise destination rank input to one rank per split instruction.

Accepted input formats:

  1. Per-instruction ranks: len(destination_ranks) == len(subtrees)
  2. Per-subtree ranks (excluding subtree 0): len(destination_ranks) == max(subtrees) The rank for subtree s>0 is taken from destination_ranks[s-1] and repeated for every occurrence of s in subtrees.

Definition at line 134 of file Hardcoded.py.

Referenced by api.output.Hardcoded.create_constructor_initialisation_string().

Here is the caller graph for this function:

◆ _normalise_markers()

api.output.Hardcoded._normalise_markers (   modes,
  number_of_splits 
)
protected

Turn the user's modes argument into one marker per split.

Parameters
modesstr or [str] Either a single marker which holds for all splits, or a sequence with one marker per split. Each marker is TopDown ("top-down") or BottomUp ("bottom-up").
number_of_splitsint Number of splits that the markers have to describe.

Definition at line 85 of file Hardcoded.py.

Referenced by api.output.Hardcoded.create_constructor_initialisation_string().

Here is the caller graph for this function:

◆ _validate_round_robin()

api.output.Hardcoded._validate_round_robin (   subtrees,
  destination_ranks,
  number_of_ranks = None 
)
protected

Ensure that the subtrees are assigned to the ranks round robin.

Peano's tree numbers encode the rank which hosts a tree: peano4::parallel::Node::getId() gives the nth tree on rank r the number n*R+r for R ranks, and peano4::parallel::Node::getRank() hence maps tree number t onto rank tR. The offline plan refers to the trees through its subtree numbers, i.e. a split of subtree s is meant to split the tree with number s in Peano. This only holds if subtree s lives on rank sR, which is exactly what assign_trees_to_ranks_round_Robin() yields.

Parameters
subtrees[int] Subtree created by the kth split.
destination_ranks[int] Rank which receives the subtree of the kth split.
number_of_ranksint or None Number of ranks R. None derives R from the largest destination rank.

Definition at line 159 of file Hardcoded.py.

Referenced by api.output.Hardcoded.create_constructor_initialisation_string().

Here is the caller graph for this function:

◆ assign_trees_to_ranks_round_Robin()

api.output.Hardcoded.assign_trees_to_ranks_round_Robin ( int  number_of_subtrees,
int  max_ranks 
)

Take the trees and assign them to the ranks in a round-robin fashion.

Round robin is the only assignment that the offline load balancing supports, as Peano numbers its trees round robin, too: Tree t always lives on rank tR for R ranks. See _validate_round_robin() and the documentation of toolbox::loadbalancing::strategies::Hardcoded.

Note that we implicitly assume that the first tree remains on rank 0, so we really only assign number_of_subtrees-1 entries.

Definition at line 18 of file Hardcoded.py.

◆ create_constructor_initialisation_string()

tuple[str, str] api.output.Hardcoded.create_constructor_initialisation_string ( "Tree"  peano_tree,
list[int]  destination_ranks,
bool   verbose = False,
  modes = None,
int | None   number_of_ranks = None 
)

Construct the constructor arguments for an instance of Hardcoded.

The routine extracts the enumerated splits from the split tree, i.e. a sequence of splits where the kth split reads "tree t hands n cells over to a new tree on rank r and uses mode m to select these cells". toolbox::loadbalancing::strategies::Hardcoded decides itself when it issues the kth split.

By default, the mode of each split is inferred (see image below):

  • AggressiveTopDown: all subtrees assigned to rank k start on the same level l.
  • BottomUp: subtrees assigned to rank k start on different levels.

You can overwrite the inferred modes through modes.

Parameters
peano_treetoolbox.loadbalancing.api.Tree.Tree Tree after the split, i.e. after SplitTrees.split_tree().
destination_ranks[int] Either one rank per split or one rank per subtree excluding subtree 0.
verbosebool Print the extracted splits.
modesNone, str or [str] None infers the mode of each split. Otherwise, pass a single marker TopDown ("top-down") or BottomUp ("bottom-up") which holds for all splits, or a sequence with one marker per split.
number_of_ranksint or None Number of MPI ranks. None derives it from the largest destination rank. See _validate_round_robin() for why we need it.
Returns
(hardcoded_config, hardcoded_mode) where hardcoded_config is the complete constructor argument string and hardcoded_mode is the mode argument within this string.

Definition at line 193 of file Hardcoded.py.

References api.output.Hardcoded._format_initialisation_lists(), api.output.Hardcoded._format_modes(), api.output.Hardcoded._markers_from_flags(), api.output.Hardcoded._normalise_destination_ranks(), api.output.Hardcoded._normalise_markers(), and api.output.Hardcoded._validate_round_robin().

Here is the call graph for this function:

Variable Documentation

◆ _CppModes

dict api.output.Hardcoded._CppModes
protected
Initial value:
1= {
2 TopDown: "peano4::SplitInstruction::Mode::AggressiveTopDown",
3 BottomUp: "peano4::SplitInstruction::Mode::BottomUp",
4}

Definition at line 12 of file Hardcoded.py.

◆ BottomUp

str api.output.Hardcoded.BottomUp = "bottom-up"

Definition at line 10 of file Hardcoded.py.

◆ TopDown

str api.output.Hardcoded.TopDown = "top-down"

Definition at line 9 of file Hardcoded.py.