Classes | Typedefs | Enumerations | Functions
PhaseControl Namespace Reference

Contains utilities for determining control-flow among phases. More...

Classes

struct  InitializePhaseChangeDecisionData
 Initialize the Main chare's phase_change_decision_data for the option-selected PhaseChanges. More...
 
struct  TagAndCombine
 A type for denoting a piece of data for deciding a phase change. More...
 
struct  TaggedTupleCombine
 A flexible combine invokable that combines into a tuples::TaggedTuple a new tuples::TaggedTuple, and combines according to type aliases combination_methods that are required to be defined in each tag. More...
 
struct  TaggedTupleMainCombine
 A flexible combine invokable that combines into a tuples::TaggedTuple a new tuples::TaggedTuple with a subset of the original tags, and combines according to type aliases main_combine_methods that are required to be defined in each tag. More...
 

Typedefs

template<typename PhaseChangeRegistrars >
using get_phase_change_tags = tmpl::push_back< tmpl::flatten< tmpl::transform< Registration::registrants< PhaseChangeRegistrars >, detail::get_phase_change_tags_and_combines< tmpl::_1 > >>, TagsAndCombines::UsePhaseChangeArbitration >
 Metafunction for determining the merged collection of tags in phase_change_tags_and_combines_lists from all PhaseChange derived classes registered in PhaseChangeRegistrars
 
template<typename TagsAndCombinesPresent , typename TagsAndCombines >
using reduction_data = Parallel::ReductionData< Parallel::ReductionDatum< tuples::tagged_tuple_from_typelist< TagsAndCombinesPresent >, TaggedTupleCombine > >
 A Parallel::ReductionData with a single Parallel::ReductionDatum for a given tagged tuple type determined by TagsPresent, and performs the combine according to TagsAndCombines, which must be a tmpl::list of PhaseControl::TagAndCombines. More...
 

Enumerations

enum  ArbitrationStrategy { RunPhaseImmediately, PermitAdditionalJumps }
 The possible options for instructing the Main chare in deciding the next phase to jump to. More...
 

Functions

template<typename PhaseChangeRegistrars , typename... DecisionTags, typename Metavariables >
std::optional< typename Metavariables::Phase > arbitrate_phase_change (const gsl::not_null< tuples::TaggedTuple< DecisionTags... > * > phase_change_decision_data, typename Metavariables::Phase current_phase, const Parallel::GlobalCache< Metavariables > &cache) noexcept
 Use the runtime data aggregated in phase_change_decision_data to decide which phase to execute next. More...
 

Detailed Description

Contains utilities for determining control-flow among phases.

Typedef Documentation

◆ reduction_data

template<typename TagsAndCombinesPresent , typename TagsAndCombines >
using PhaseControl::reduction_data = typedef Parallel::ReductionData<Parallel::ReductionDatum< tuples::tagged_tuple_from_typelist<TagsAndCombinesPresent>, TaggedTupleCombine> >

A Parallel::ReductionData with a single Parallel::ReductionDatum for a given tagged tuple type determined by TagsPresent, and performs the combine according to TagsAndCombines, which must be a tmpl::list of PhaseControl::TagAndCombines.

Each tag in the TagsAndCombinesPresent may either be a TagsAndCombines or otherise define all three type traits type, combine_method, and main_combine_method.

Enumeration Type Documentation

◆ ArbitrationStrategy

The possible options for instructing the Main chare in deciding the next phase to jump to.

An object of this enum type is packaged with a requested phase in the PhaseChange::arbitrate_phase_change function.

Enumerator
RunPhaseImmediately 

Jump to the requested phase immediately, before considering other requested phases.

This will ensure that the requested phase is always run, where alternative methods could have 'double-jumps' where the Main chare replaces a requested phase immediately without actually entering the phase.

PermitAdditionalJumps 

After the requested phase is considered, continue considering other requests, potentially replacing this request.

This will permit reprocessing the phase-jumps to help with cases where multiple phases are simultaneously requested. The PermitAdditionalJumps permits 'double-jumps' where a requested phase is immediately replaced by another phase to jump to.

Function Documentation

◆ arbitrate_phase_change()

template<typename PhaseChangeRegistrars , typename... DecisionTags, typename Metavariables >
std::optional<typename Metavariables::Phase> PhaseControl::arbitrate_phase_change ( const gsl::not_null< tuples::TaggedTuple< DecisionTags... > * >  phase_change_decision_data,
typename Metavariables::Phase  current_phase,
const Parallel::GlobalCache< Metavariables > &  cache 
)
noexcept

Use the runtime data aggregated in phase_change_decision_data to decide which phase to execute next.

Details

This function will iterate through each of the option-created pairs of PhaseChanges, and obtain from each a std::optional<std::pair<Metavariables::Phase, PhaseControl::ArbitrationStrategy>. Any std::nullopt is skipped. If all PhaseChanges provide std::nullopt, the phase will either keep its current value (if the halt was caused by one of the triggers associated with an option-created PhaseChange), or this function will return a std::nullopt as well (otherwise), indicating that the phase should proceed according to other information, such as global ordering.

In the case of a PhaseControl::ArbitrationStrategy::RunPhaseImmediately, the first such return value is immediately run, and no further PhaseChanges are queried for their input.

Note
There can be cases where multiple triggers activate, and/or multiple PhaseChange objects have data in a state for which they would request a specific phase. When multiple phases are requested, arbitration will proceed in order of appearance in the PhaseChangeAndTriggers, determined from the input file options. Therefore, if that order of execution is important for the logic of the executable, the input file ordering and ArbitrationStrategy must be chosen carefully.