PhaseControlTags.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <memory>
7 #include <type_traits>
8 #include <utility>
9 #include <vector>
10 
11 #include "Parallel/Serialize.hpp"
12 #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
13 #include "Utilities/Registration.hpp"
14 #include "Utilities/TMPL.hpp"
15 
16 /// \cond
17 template <typename PhaseChangeRegistrars>
18 struct PhaseChange;
19 /// \endcond
20 
21 namespace PhaseControl {
22 namespace OptionTags {
23 /// Option tag for the collection of triggers that indicate synchronization
24 /// points at which phase changes should be considered, and the associated
25 /// `PhaseChange` objects for making the phase change decisions.
26 ///
27 /// When the phase control is arbitrated on the main chare, the `PhaseChange`
28 /// objects will be queried for their phase request in order of appearance in
29 /// the nested list (i.e. first all of the `PhaseChange`s associated with the
30 /// first trigger, in order, then those associated with the second trigger,
31 /// etc.). The order therefore determines the order of resolution of
32 /// simultaneous requests.
33 ///
34 /// \note The nested collection types for this option tag gives the yaml
35 /// format the slightly unusual form:
36 ///
37 /// ```
38 /// PhaseChangeAndTriggers:
39 /// - - Trigger1
40 /// - - PhaseChange1
41 /// - PhaseChange2
42 /// - - Trigger2
43 /// - - PhaseChange3
44 /// - PhaseChange4
45 /// ```
46 template <typename PhaseChangeRegistrars>
49  static constexpr Options::String help{
50  "A collection of pairs of triggers and collections of phase change "
51  "objects to determine runtime phase control-flow decisions. The order of "
52  "the phase change objects determines the order of the requests processed "
53  "by the Main chare during phase change arbitration."};
54 
55  using type =
58 };
59 } // namespace OptionTags
60 
61 namespace Tags {
62 /// Tag for the collection of triggers that indicate synchronization points at
63 /// which phase changes should be considered, and the associated `PhaseChange`
64 /// objects for making the phase change decisions.
65 template <typename PhaseChangeRegistrars>
68  using type =
71 
72  using option_tags =
73  tmpl::list<OptionTags::PhaseChangeAndTriggers<PhaseChangeRegistrars>>;
74  static constexpr bool pass_metavariables = false;
75  static type create_from_options(
76  const type& phase_control_and_triggers) noexcept {
77  return deserialize<type>(
78  serialize<type>(phase_control_and_triggers).data());
79  }
80 };
81 } // namespace Tags
82 
83 namespace TagsAndCombines {
84 /// A tag for indicating that a halt was called by a trigger associated with
85 /// `PhaseChange`s.
86 ///
87 /// This is needed to disambiguate different quiescence conditions in the main
88 /// chare. It is automatically included in
89 /// `PhaseControl::get_phase_change_tags`, so shouldn't be explicitly included
90 /// in the `phase_change_tags_and_combines_list` in derived classes of
91 /// `PhaseChange`.
93  using type = bool;
96 };
97 } // namespace TagsAndCombines
98 
99 namespace detail {
100 template <typename PhaseChangeDerived>
101 struct get_phase_change_tags_and_combines {
102  using type = typename PhaseChangeDerived::phase_change_tags_and_combines;
103 };
104 } // namespace detail
105 
106 /// Metafunction for determining the merged collection of tags in
107 /// `phase_change_tags_and_combines_list`s from all `PhaseChange` derived
108 /// classes registered in `PhaseChangeRegistrars`
109 template <typename PhaseChangeRegistrars>
110 using get_phase_change_tags =
111  tmpl::push_back<tmpl::flatten<tmpl::transform<
113  detail::get_phase_change_tags_and_combines<tmpl::_1>>>,
115 } // namespace PhaseControl
PhaseControl
Contains utilities for determining control-flow among phases.
Definition: ExecutePhaseChange.hpp:17
utility
PhaseControl::TagsAndCombines::UsePhaseChangeArbitration
A tag for indicating that a halt was called by a trigger associated with PhaseChanges.
Definition: PhaseControlTags.hpp:92
vector
Serialize.hpp
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
PhaseControl::Tags::PhaseChangeAndTriggers
Tag for the collection of triggers that indicate synchronization points at which phase changes should...
Definition: PhaseControlTags.hpp:66
domain::push_back
CoordinateMap< SourceFrame, TargetFrame, Maps..., NewMap > push_back(CoordinateMap< SourceFrame, TargetFrame, Maps... > old_map, NewMap new_map) noexcept
Creates a CoordinateMap by appending the new map to the end of the old maps.
PhaseControl::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 > get_phase_change_tags
Metafunction for determining the merged collection of tags in phase_change_tags_and_combines_lists fr...
Definition: PhaseControlTags.hpp:114
PhaseControl::OptionTags::PhaseChangeAndTriggers
Option tag for the collection of triggers that indicate synchronization points at which phase changes...
Definition: PhaseControlTags.hpp:47
memory
PhaseChange
PhaseChange objects determine the storage types and logic for moving between phases based on runtime ...
Definition: PhaseChange.hpp:141
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Registration::registrants
tmpl::transform< tmpl::remove_duplicates< RegistrarList >, detail::registrant< tmpl::pin< tmpl::remove_duplicates< RegistrarList > >, tmpl::_1 > > registrants
Transform a list of registrars into the list of associated registrants. This is usually used to defin...
Definition: Registration.hpp:65
funcl::Or
Functional for computing or of two objects.
Definition: Functional.hpp:240
type_traits
TMPL.hpp