ParallelComponentHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "Utilities/TMPL.hpp"
8 
9 namespace Parallel {
10 namespace Parallel_detail {
11 template <class Action, class = cpp17::void_t<>>
13  using type = tmpl::list<>;
14 };
15 
16 template <class Action>
17 struct get_inbox_tags_from_action<Action,
18  cpp17::void_t<typename Action::inbox_tags>> {
19  using type = typename Action::inbox_tags;
20 };
21 } // namespace Parallel_detail
22 
23 /*!
24  * \ingroup ParallelGroup
25  * \brief Given an Action returns the list of inbox tags for that action
26  */
27 template <class Action>
29  typename Parallel_detail::get_inbox_tags_from_action<Action>::type;
30 
31 /*!
32  * \ingroup ParallelGroup
33  * \brief Given a list of Actions, get a list of the unique inbox tags
34  */
35 template <class ActionsList>
36 using get_inbox_tags = tmpl::remove_duplicates<tmpl::join<tmpl::transform<
37  ActionsList, Parallel_detail::get_inbox_tags_from_action<tmpl::_1>>>>;
38 
39 namespace Parallel_detail {
40 template <class Action, class = cpp17::void_t<>>
42  using type = tmpl::list<>;
43 };
44 
45 template <class Action>
47  Action, cpp17::void_t<typename Action::const_global_cache_tags>> {
48  using type = typename Action::const_global_cache_tags;
49 };
50 } // namespace Parallel_detail
51 
52 /*!
53  * \ingroup ParallelGroup
54  * \brief Given an Action returns the contents of the
55  * `const_global_cache_tags` alias for that action, or an empty list
56  * if no such alias exists.
57  */
58 template <class Action>
61  Action>::type;
62 
63 /*!
64  * \ingroup ParallelGroup
65  * \brief Given a list of Actions, get a list of the unique tags
66  * specified in the actions' `const_global_cache_tags` aliases.
67  */
68 template <class ActionsList>
70  tmpl::remove_duplicates<tmpl::join<tmpl::transform<
71  ActionsList,
72  Parallel_detail::get_const_global_cache_tags_from_action<tmpl::_1>>>>;
73 
74 /// \cond
75 namespace Algorithms {
76 struct Singleton;
77 struct Array;
78 struct Group;
79 struct Nodegroup;
80 } // namespace Algorithms
81 
82 template <class ChareType>
83 struct get_array_index;
84 
85 template <>
86 struct get_array_index<Parallel::Algorithms::Singleton> {
87  template <class ParallelComponent>
88  using f = cpp17::void_type;
89 };
90 
91 template <>
92 struct get_array_index<Parallel::Algorithms::Array> {
93  template <class ParallelComponent>
94  using f = typename ParallelComponent::array_index;
95 };
96 
97 template <>
98 struct get_array_index<Parallel::Algorithms::Group> {
99  template <class ParallelComponent>
100  using f = int;
101 };
102 
103 template <>
104 struct get_array_index<Parallel::Algorithms::Nodegroup> {
105  template <class ParallelComponent>
106  using f = int;
107 };
108 
109 template <typename ParallelComponent>
110 using proxy_from_parallel_component =
111  typename ParallelComponent::chare_type::template cproxy<
112  ParallelComponent,
113  typename get_array_index<typename ParallelComponent::chare_type>::
114  template f<ParallelComponent>>;
115 
116 template <typename ParallelComponent>
117 using index_from_parallel_component =
118  typename ParallelComponent::chare_type::template ckindex<
119  ParallelComponent,
120  typename get_array_index<typename ParallelComponent::chare_type>::
121  template f<ParallelComponent>>;
122 
123 template <class ParallelComponent, class... Args>
124 struct charm_types_with_parameters {
125  using cproxy =
126  typename ParallelComponent::chare_type::template cproxy<ParallelComponent,
127  Args...>;
128  using cbase =
129  typename ParallelComponent::chare_type::template cbase<ParallelComponent,
130  Args...>;
131  using algorithm =
132  typename ParallelComponent::chare_type::template algorithm_type<
133  ParallelComponent, Args...>;
134  using ckindex = typename ParallelComponent::chare_type::template ckindex<
135  ParallelComponent, Args...>;
136 };
137 /// \endcond
138 } // namespace Parallel
tmpl::remove_duplicates< tmpl::join< tmpl::transform< ActionsList, Parallel_detail::get_inbox_tags_from_action< tmpl::_1 > >> > get_inbox_tags
Given a list of Actions, get a list of the unique inbox tags.
Definition: ParallelComponentHelpers.hpp:37
Mark a return type as being "void". In C++17 void is a regular type under certain circumstances...
Definition: TypeTraits.hpp:47
void void_t
Given a set of types, returns void
Definition: TypeTraits.hpp:214
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
tmpl::remove_duplicates< tmpl::join< tmpl::transform< ActionsList, Parallel_detail::get_const_global_cache_tags_from_action< tmpl::_1 > >> > get_const_global_cache_tags
Given a list of Actions, get a list of the unique tags specified in the actions&#39; const_global_cache_t...
Definition: ParallelComponentHelpers.hpp:72
Wraps the template metaprogramming library used (brigand)
typename Parallel_detail::get_const_global_cache_tags_from_action< Action >::type get_const_global_cache_tags_from_action
Given an Action returns the contents of the const_global_cache_tags alias for that action...
Definition: ParallelComponentHelpers.hpp:61
C++ STL code present in C++17.
Definition: Array.hpp:16
Defines type traits, some of which are future STL type_traits header.
typename Parallel_detail::get_inbox_tags_from_action< Action >::type get_inbox_tags_from_action
Given an Action returns the list of inbox tags for that action.
Definition: ParallelComponentHelpers.hpp:29