SpECTRE  2021.08.02
Parallelization

Functions, classes and documentation related to parallelization and Charm++. More...

Namespaces

namespace  Parallel::InboxInserters
 Structs that have insert_into_inbox methods for commonly used cases.
 

Classes

class  Parallel::AlgorithmImpl< ParallelComponent, tmpl::list< PhaseDepActionListsPack... > >
 A distributed object (Charm++ Chare) that executes a series of Actions and is capable of sending and receiving data. Acts as an interface to Charm++. More...
 
class  AlgorithmArray< ParallelComponent, SpectreArrayIndex >
 A Spectre algorithm object that wraps a charm++ array chare. More...
 
struct  Parallel::Algorithms::Array
 A struct that stores the charm++ types relevant for a particular array component. More...
 
class  AlgorithmGroup< ParallelComponent, SpectreArrayIndex >
 A Spectre algorithm object that wraps a charm++ group chare. More...
 
struct  Parallel::Algorithms::Group
 A struct that stores the charm++ types relevant for a particular group component. More...
 
class  AlgorithmNodegroup< ParallelComponent, SpectreArrayIndex >
 A Spectre algorithm object that wraps a charm++ nodegroup chare. More...
 
struct  Parallel::Algorithms::Nodegroup
 A struct that stores the charm++ types relevant for a particular nodegroup component. More...
 
class  AlgorithmSingleton< ParallelComponent, SpectreArrayIndex >
 A Spectre algorithm object that wraps a charm++ singleton chare. More...
 
struct  Parallel::Algorithms::Singleton
 A struct that stores the charm++ types relevant for a particular singleton component. More...
 
struct  Parallel::ArrayIndex< Index >
 The array index used for indexing Chare Arrays, mostly an implementation detail. More...
 
class  Parallel::MutableGlobalCache< Metavariables >
 A Charm++ chare that caches mutable data once per Charm++ core. More...
 
class  Parallel::GlobalCache< Metavariables >
 A Charm++ chare that caches constant data once per Charm++ node or non-constant data once per Charm++ core. More...
 
struct  Parallel::Tags::GlobalCache
 Tag to retrieve the Parallel::GlobalCache from the DataBox. More...
 
struct  Parallel::Tags::FromGlobalCache< CacheTag >
 Tag used to retrieve data from the Parallel::GlobalCache. This is the recommended way for compute tags to retrieve data out of the global cache. More...
 
class  Parallel::Main< Metavariables >
 The main function of a Charm++ executable. See the Parallelization documentation for an overview of Metavariables, Phases, and parallel components. More...
 
class  Parallel::NodeLock
 A typesafe wrapper for a lock for synchronization of shared resources on a given node, with safe creation, destruction, and serialization. More...
 
struct  Parallel::PhaseActions< PhaseType, Phase, ActionsList >
 List of all the actions to be executed in the specified phase. More...
 
struct  Parallel::get_action_list_from_phase_dep_action_list< PhaseDepActionList >
 (Lazy) metafunction to get the action list from a PhaseActions More...
 
struct  Parallel::get_phase_type_from_phase_dep_action_list< PhaseDepActionList >
 (Lazy) metafunction to get the phase type from a PhaseActions More...
 
struct  Parallel::get_phase_from_phase_dep_action_list< PhaseDepActionList >
 (Lazy) metafunction to get the phase as a std::integral_constant from a PhaseActions More...
 
struct  Parallel::ReductionDatum< T, InvokeCombine, InvokeFinal, InvokeFinalExtraArgsIndices >
 The data to be reduced, and invokables to be called whenever two reduction messages are combined and after the reduction has been completed. More...
 
struct  Parallel::ReductionData< ReductionDatum< Ts, InvokeCombines, InvokeFinals, InvokeFinalExtraArgsIndices >... >
 Used for reducing a possibly heterogeneous collection of types in a single reduction call. More...
 
struct  Parallel::Tags::Metavariables
 Tag to retrieve the Metavariables from the DataBox. More...
 
struct  Parallel::is_array_proxy< T >
 Check if T is a Charm++ proxy for an array chare. More...
 
struct  Parallel::is_chare_proxy< T >
 Check if T is a Charm++ proxy for a chare. More...
 
struct  Parallel::is_group_proxy< T >
 Check if T is a Charm++ proxy for a group chare. More...
 
struct  Parallel::is_node_group_proxy< T >
 Check if T is a Charm++ proxy for a node group chare. More...
 
struct  Parallel::is_bound_array< T, typename >
 Check if T is a ParallelComponent for a Charm++ bound array. More...
 
struct  Parallel::has_pup_member< T, typename >
 Check if T has a pup member function. More...
 
struct  Parallel::is_pupable< T, U >
 Check if type T has operator| defined for Charm++ serialization. More...
 

Macros

#define WRAPPED_PUPable_decl_template(className)    PUPable_decl_template(SINGLE_ARG(className))
 Mark derived classes as serializable. More...
 
#define WRAPPED_PUPable_decl_base_template(baseClassName, className)
 Mark derived template classes as serializable. More...
 

Typedefs

template<class ActionsList >
using Parallel::get_inbox_tags = tmpl::remove_duplicates< tmpl::join< tmpl::transform< ActionsList, detail::get_inbox_tags_from_action< tmpl::_1 > > > >
 Given a list of Actions, get a list of the unique inbox tags.
 
template<class ActionsList >
using Parallel::get_const_global_cache_tags_from_actions = tmpl::remove_duplicates< tmpl::join< tmpl::transform< ActionsList, detail::get_const_global_cache_tags_from_parallel_struct< tmpl::_1 > > > >
 Given a list of Actions, get a list of the unique tags specified in the actions' const_global_cache_tags aliases.
 
template<class ActionsList >
using Parallel::get_mutable_global_cache_tags_from_actions = tmpl::remove_duplicates< tmpl::join< tmpl::transform< ActionsList, detail::get_mutable_global_cache_tags_from_parallel_struct< tmpl::_1 > > > >
 Given a list of Actions, get a list of the unique tags specified in the actions' mutable_global_cache_tags aliases.
 
template<typename Metavariables >
using Parallel::get_const_global_cache_tags = tmpl::remove_duplicates< tmpl::flatten< tmpl::list< typename detail::get_const_global_cache_tags_from_parallel_struct< Metavariables >::type, tmpl::transform< typename Metavariables::component_list, detail::get_const_global_cache_tags_from_parallel_struct< tmpl::_1 > >, tmpl::transform< typename Metavariables::component_list, detail::get_const_global_cache_tags_from_pdal< tmpl::_1 > > > > >
 Given the metavariables, get a list of the unique tags that will specify the items in the GlobalCache.
 
template<typename Metavariables >
using Parallel::get_mutable_global_cache_tags = tmpl::remove_duplicates< tmpl::flatten< tmpl::list< typename detail::get_mutable_global_cache_tags_from_parallel_struct< Metavariables >::type, tmpl::transform< typename Metavariables::component_list, detail::get_mutable_global_cache_tags_from_parallel_struct< tmpl::_1 > >, tmpl::transform< typename Metavariables::component_list, detail::get_mutable_global_cache_tags_from_pdal< tmpl::_1 > > > > >
 Given the metavariables, get a list of the unique tags that will specify the mutable items in the GlobalCache.
 
template<typename PhaseDepActionList >
using Parallel::get_initialization_actions_list = tmpl::flatten< tmpl::transform< PhaseDepActionList, detail::get_initialization_actions_list< tmpl::_1 > > >
 Given the phase dependent action list, return the list of actions in the Initialization phase (or an empty list if the Initialization phase is absent from the phase dependent action list)
 
template<typename InitializationActionsList , typename AllocationTagsList = tmpl::list<>>
using Parallel::get_initialization_tags = tmpl::remove_duplicates< tmpl::flatten< tmpl::list< AllocationTagsList, tmpl::transform< InitializationActionsList, detail::get_initialization_tags_from_action< tmpl::_1 > > > > >
 Given a list of initialization actions, and possibly a list of tags needed for allocation of an array component, returns a list of the unique initialization_tags for all the actions (and the allocate function).
 
template<typename InitializationActionsList >
using Parallel::get_initialization_tags_to_keep = tmpl::remove_duplicates< tmpl::flatten< tmpl::transform< InitializationActionsList, detail::get_initialization_tags_to_keep_from_action< tmpl::_1 > > > >
 Given a list of initialization actions, returns a list of the unique initialization_tags_to_keep for all the actions. These are the tags that are not removed from the DataBox after initialization.
 
template<typename InitializationTagsList , typename Metavariables >
using Parallel::get_option_tags = tmpl::remove_duplicates< tmpl::flatten< tmpl::transform< InitializationTagsList, tmpl::bind< detail::get_option_tags_from_initialization_tag< Metavariables >::template f, tmpl::_1 > > > >
 Given a list of initialization tags, returns a list of the unique option tags required to construct them.
 

Functions

template<typename Metavariables , typename... Tags, typename... OptionTags>
tuples::TaggedTuple< Tags... > Parallel::create_from_options (const tuples::TaggedTuple< OptionTags... > &options, tmpl::list< Tags... >) noexcept
 Given a list of tags and a tagged tuple containing items created from input options, return a tagged tuple of items constructed by calls to create_from_options for each tag in the list.
 
template<typename DistribObject >
int Parallel::number_of_procs (const DistribObject &distributed_object) noexcept
 Number of processing elements.
 
template<typename DistribObject >
int Parallel::my_proc (const DistribObject &distributed_object) noexcept
 Index of my processing element.
 
template<typename DistribObject >
int Parallel::number_of_nodes (const DistribObject &distributed_object) noexcept
 Number of nodes.
 
template<typename DistribObject >
int Parallel::my_node (const DistribObject &distributed_object) noexcept
 Index of my node.
 
template<typename DistribObject >
int Parallel::procs_on_node (const int node_index, const DistribObject &distributed_object) noexcept
 Number of processing elements on the given node.
 
template<typename DistribObject >
int Parallel::my_local_rank (const DistribObject &distributed_object) noexcept
 The local index of my processing element on my node. This is in the interval 0, ..., procs_on_node(my_node()) - 1.
 
template<typename DistribObject >
int Parallel::first_proc_on_node (const int node_index, const DistribObject &distributed_object) noexcept
 Index of first processing element on the given node.
 
template<typename DistribObject >
int Parallel::node_of (const int proc_index, const DistribObject &distributed_object) noexcept
 Index of the node for the given processing element.
 
template<typename DistribObject >
int Parallel::local_rank_of (const int proc_index, const DistribObject &distributed_object) noexcept
 The local index for the given processing element on its node.
 
template<typename ReceiveTag , typename Proxy , typename ReceiveDataType >
void Parallel::receive_data (Proxy &&proxy, typename ReceiveTag::temporal_id temporal_id, ReceiveDataType &&receive_data, const bool enable_if_disabled=false) noexcept
 Send the data args... to the algorithm running on proxy, and tag the message with the identifier temporal_id. More...
 
template<typename Action , typename Proxy , typename... Args>
decltype(auto) Parallel::local_synchronous_action (Proxy &&proxy, Args &&... args) noexcept
 Invoke a local synchronous action on proxy
 
template<typename... Args>
void Parallel::printf (const std::string &format, Args &&... args)
 Print an atomic message to stdout with C printf usage. More...
 
template<typename... Args>
void Parallel::printf_error (const std::string &format, Args &&... args)
 Print an atomic message to stderr with C printf usage. More...
 
template<class Action , class SenderProxy , class TargetProxy , class... Ts, class SectionType = NoSection>
void Parallel::contribute_to_reduction (ReductionData< Ts... > reduction_data, const SenderProxy &sender_component, const TargetProxy &target_component, const gsl::not_null< SectionType * > section=&no_section()) noexcept
 Perform a reduction from the sender_component (typically your own parallel component) to the target_component, performing the Action upon receiving the reduction. More...
 
template<typename T >
std::vector< char > serialize (const T &obj) noexcept
 Serialize an object using PUP. More...
 
template<typename T >
deserialize (const void *const data) noexcept
 Deserialize an object using PUP. More...
 
template<typename T >
void deserialize (const gsl::not_null< T * > result, const void *const data) noexcept
 Deserialize an object using PUP. More...
 
template<typename ParallelComponentTag , typename Metavariables >
auto Parallel::get_parallel_component (GlobalCache< Metavariables > &cache) noexcept -> Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag > > &
 Access the Charm++ proxy associated with a ParallelComponent. More...
 
template<typename ParallelComponentTag , typename Metavariables >
auto Parallel::get_parallel_component (const GlobalCache< Metavariables > &cache) noexcept -> const Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag > > &
 Access the Charm++ proxy associated with a ParallelComponent. More...
 
template<typename GlobalCacheTag , typename Metavariables >
auto Parallel::get (const GlobalCache< Metavariables > &cache) noexcept -> const GlobalCache_detail::type_for_get< GlobalCacheTag, Metavariables > &
 Access data in the cache. More...
 
template<typename GlobalCacheTag , typename Function , typename Metavariables >
bool Parallel::mutable_cache_item_is_ready (GlobalCache< Metavariables > &cache, const Function &function) noexcept
 Returns whether the object identified by GlobalCacheTag is ready to be accessed by get. More...
 
template<typename GlobalCacheTag , typename Function , typename Metavariables , typename... Args>
void Parallel::mutate (GlobalCache< Metavariables > &cache, Args &&... args) noexcept
 Mutates non-const data in the cache, by calling Function::apply() More...
 
template<typename GlobalCacheTag , typename Function , typename Metavariables , typename... Args>
void Parallel::mutate (CProxy_GlobalCache< Metavariables > &cache_proxy, Args &&... args) noexcept
 Mutates non-const data in the cache, by calling Function::apply() More...
 
template<typename Action , typename Proxy >
void Parallel::simple_action (Proxy &&proxy) noexcept
 Invoke a simple action on proxy
 
template<typename Action , typename Proxy , typename Arg0 , typename... Args>
void Parallel::simple_action (Proxy &&proxy, Arg0 &&arg0, Args &&... args) noexcept
 Invoke a simple action on proxy
 
template<typename Action , typename Proxy >
void Parallel::threaded_action (Proxy &&proxy) noexcept
 Invoke a threaded action on proxy, where the proxy must be a nodegroup.
 
template<typename Action , typename Proxy , typename Arg0 , typename... Args>
void Parallel::threaded_action (Proxy &&proxy, Arg0 &&arg0, Args &&... args) noexcept
 Invoke a threaded action on proxy, where the proxy must be a nodegroup.
 

Detailed Description

Functions, classes and documentation related to parallelization and Charm++.

See Parallelization infrastructure for details.

Macro Definition Documentation

◆ WRAPPED_PUPable_decl_base_template

#define WRAPPED_PUPable_decl_base_template (   baseClassName,
  className 
)
Value:
PUPable_decl_base_template(SINGLE_ARG(baseClassName), /* NOLINT */ \
SINGLE_ARG(className))

Mark derived template classes as serializable.

Any class that inherits from an abstract base class where the base class is a template class must contain this macro if it is to be serialized.

◆ WRAPPED_PUPable_decl_template

#define WRAPPED_PUPable_decl_template (   className)     PUPable_decl_template(SINGLE_ARG(className))

Mark derived classes as serializable.

Any class that inherits from an abstract base class where the base class is not a template class must contain this macro if it is to be serialized.

Function Documentation

◆ contribute_to_reduction()

template<class Action , class SenderProxy , class TargetProxy , class... Ts, class SectionType = NoSection>
void Parallel::contribute_to_reduction ( ReductionData< Ts... >  reduction_data,
const SenderProxy &  sender_component,
const TargetProxy &  target_component,
const gsl::not_null< SectionType * >  section = &no_section() 
)
noexcept

Perform a reduction from the sender_component (typically your own parallel component) to the target_component, performing the Action upon receiving the reduction.

Section reductions
This function supports section reductions (see Parallel::Section). Pass the Parallel::Section as the section argument, or pass Parallel::no_section() to perform a reduction over the entire parallel component (default). Here's an example of a section reduction:
auto& array_section = db::get_mutable_reference<
make_not_null(&box));
if (array_section.has_value()) {
// We'll just count the elements in each section
Parallel::ReductionData<
reduction_data{section_id, 1};
// Reduce over the section and broadcast to the full array
auto& array_proxy =
Parallel::get_parallel_component<ParallelComponent>(cache);
Parallel::contribute_to_reduction<ReceiveCount<ArraySectionIdTag>>(
std::move(reduction_data), array_proxy[array_index], array_proxy,
make_not_null(&*array_section));
}
auto & get_mutable_reference(const gsl::not_null< DataBox< TagList > * > box) noexcept
Retrieve a mutable reference to the item with tag Tag from the DataBox.
Definition: DataBox.hpp:839
The data to be reduced, and invokables to be called whenever two reduction messages are combined and ...
Definition: Reduction.hpp:65
The Parallel::Section<ParallelComponent, SectionIdTag> that this element belongs to.
Definition: Section.hpp:29
Warning
Section reductions currently don't support migrating elements, i.e. either load-balancing or restoring a checkpoint to a different number of PEs. Support for migrating elements may require updating the "section cookie". One possibility to update the section cookie is to broadcast a CkMulticast message to the section elements and invoke CkGetSectionInfo within the message.

◆ deserialize() [1/2]

template<typename T >
void deserialize ( const gsl::not_null< T * >  result,
const void *const  data 
)
noexcept

Deserialize an object using PUP.

Template Parameters
Tthe type to deserialize to.

◆ deserialize() [2/2]

template<typename T >
T deserialize ( const void *const  data)
noexcept

Deserialize an object using PUP.

Template Parameters
Tthe type to deserialize to

◆ get()

template<typename GlobalCacheTag , typename Metavariables >
auto Parallel::get ( const GlobalCache< Metavariables > &  cache) -> const GlobalCache_detail::type_for_get<GlobalCacheTag, Metavariables>&
noexcept

Access data in the cache.

Requires: GlobalCacheTag is a tag in the mutable_global_cache_tags or const_global_cache_tags defined by the Metavariables and in Actions.

Returns: a constant reference to an object in the cache

◆ get_parallel_component() [1/2]

template<typename ParallelComponentTag , typename Metavariables >
auto Parallel::get_parallel_component ( const GlobalCache< Metavariables > &  cache) -> const Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag>>&
noexcept

Access the Charm++ proxy associated with a ParallelComponent.

Requires: ParallelComponentTag is a tag in component_list

Returns: a Charm++ proxy that can be used to call an entry method on the chare(s)

◆ get_parallel_component() [2/2]

template<typename ParallelComponentTag , typename Metavariables >
auto Parallel::get_parallel_component ( GlobalCache< Metavariables > &  cache) -> Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename Metavariables::component_list, ParallelComponentTag>>&
noexcept

Access the Charm++ proxy associated with a ParallelComponent.

Requires: ParallelComponentTag is a tag in component_list

Returns: a Charm++ proxy that can be used to call an entry method on the chare(s)

◆ mutable_cache_item_is_ready()

template<typename GlobalCacheTag , typename Function , typename Metavariables >
bool Parallel::mutable_cache_item_is_ready ( GlobalCache< Metavariables > &  cache,
const Function &  function 
)
noexcept

Returns whether the object identified by GlobalCacheTag is ready to be accessed by get.

Requires: GlobalCacheTag is a tag in mutable_global_cache_tags defined by the Metavariables and in Actions.

Requires: function is a user-defined invokable that takes one argument: a const reference to the object referred to by the GlobalCacheTag. function returns a std::unique_ptr<CallBack> that determines the readiness. To indicate that the item is ready, the std::unique_ptr returned by function must be nullptr; in this case mutable_cache_item_is_ready returns true. To indicate that the item is not ready, the std::unique_ptr returned by function must be valid; in this case, mutable_cache_item_is_ready appends the std::unique_ptr<Callback> to an internal list of callbacks to be called on mutate, and then returns false.

◆ mutate() [1/2]

template<typename GlobalCacheTag , typename Function , typename Metavariables , typename... Args>
void Parallel::mutate ( CProxy_GlobalCache< Metavariables > &  cache_proxy,
Args &&...  args 
)
noexcept

Mutates non-const data in the cache, by calling Function::apply()

Requires: GlobalCacheTag is a tag in tag_list.

Requires: Function is a struct with a static void apply() function that mutates the object. Function::apply() takes as its first argument a gsl::not_null pointer to the object named by the GlobalCacheTag, and takes args as subsequent arguments.

This is the version that takes a charm++ proxy to the GlobalCache.

◆ mutate() [2/2]

template<typename GlobalCacheTag , typename Function , typename Metavariables , typename... Args>
void Parallel::mutate ( GlobalCache< Metavariables > &  cache,
Args &&...  args 
)
noexcept

Mutates non-const data in the cache, by calling Function::apply()

Requires: GlobalCacheTag is a tag in the mutable_global_cache_tags defined by the Metavariables and in Actions.

Requires: Function is a struct with a static void apply() function that mutates the object. Function::apply() takes as its first argument a gsl::not_null pointer to the object named by the GlobalCacheTag, and takes args as subsequent arguments.

This is the version that takes a GlobalCache<Metavariables>. Used only for tests.

◆ printf()

template<typename... Args>
void Parallel::printf ( const std::string format,
Args &&...  args 
)
inline

Print an atomic message to stdout with C printf usage.

Similar to Python, you can print any object that's streamable by passing it in as an argument and using the formatter "%s". For example,

std::vector<double> a{0.8, 73, 9.8};
Parallel::printf("%s\n", a);
void printf(const std::string &format, Args &&... args)
Print an atomic message to stdout with C printf usage.
Definition: Printf.hpp:103

◆ printf_error()

template<typename... Args>
void Parallel::printf_error ( const std::string format,
Args &&...  args 
)
inline

Print an atomic message to stderr with C printf usage.

See Parallel::printf for details.

◆ receive_data()

template<typename ReceiveTag , typename Proxy , typename ReceiveDataType >
void Parallel::receive_data ( Proxy &&  proxy,
typename ReceiveTag::temporal_id  temporal_id,
ReceiveDataType &&  receive_data,
const bool  enable_if_disabled = false 
)
noexcept

Send the data args... to the algorithm running on proxy, and tag the message with the identifier temporal_id.

If the algorithm was previously disabled, set enable_if_disabled to true to enable the algorithm on the parallel component.

◆ serialize()

template<typename T >
std::vector< char > serialize ( const T &  obj)
noexcept

Serialize an object using PUP.

The type to serialize as must be explicitly specified. We require this because a mismatch between the serialize and deserialize calls causes undefined behavior and we do not want this to depend on inferred types for safety.

Template Parameters
Ttype to serialize