SpECTRE  v2021.10.04
Parallel::GlobalCache< Metavariables > Class Template Reference

A Charm++ chare that caches constant data once per Charm++ node or non-constant data once per Charm++ core. More...

#include <GlobalCache.hpp>

Public Types

using proxy_type = CProxy_GlobalCache< Metavariables >
 
using main_proxy_type = CProxy_Main< Metavariables >
 
using metavariables = Metavariables
 Access to the Metavariables template parameter.
 
using component_list = typename Metavariables::component_list
 Typelist of the ParallelComponents stored in the GlobalCache.
 

Public Member Functions

 GlobalCache (tuples::tagged_tuple_from_typelist< get_const_global_cache_tags< Metavariables > > const_global_cache, MutableGlobalCache< Metavariables > *mutable_global_cache, std::optional< main_proxy_type > main_proxy=std::nullopt)
 Constructor used only by the ActionTesting framework and other non-charm++ tests that don't know about proxies.
 
 GlobalCache (tuples::tagged_tuple_from_typelist< get_const_global_cache_tags< Metavariables > > const_global_cache, CProxy_MutableGlobalCache< Metavariables > mutable_global_cache_proxy, std::optional< main_proxy_type > main_proxy=std::nullopt)
 Constructor used by Main and anything else that is charm++ aware.
 
 GlobalCache (CkMigrateMessage *msg)
 
void set_parallel_components (tuples::tagged_tuple_from_typelist< parallel_component_tag_list > &&parallel_components, const CkCallback &callback)
 Entry method to set the ParallelComponents (should only be called once)
 
template<typename GlobalCacheTag , typename Function >
bool mutable_cache_item_is_ready (const Function &function)
 Returns whether the object referred to by GlobalCacheTag (which must be a mutable cache tag) is ready to be accessed by a get call. More...
 
template<typename GlobalCacheTag , typename Function , typename... Args>
void mutate (const std::tuple< Args... > &args)
 Mutates the non-const object identified by GlobalCacheTag. More...
 
proxy_type get_this_proxy ()
 Retrieve the proxy to the global cache.
 
void pup (PUP::er &p) override
 
std::optional< main_proxy_type > get_main_proxy ()
 Retrieve the proxy to the Main chare (or std::nullopt if the proxy has not been set).
 

Friends

template<typename GlobalCacheTag , typename MV >
auto get (const GlobalCache< MV > &cache) -> const GlobalCache_detail::type_for_get< GlobalCacheTag, MV > &
 
template<typename ParallelComponentTag , typename MV >
auto get_parallel_component (GlobalCache< MV > &cache) -> Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename MV::component_list, ParallelComponentTag > > &
 
template<typename ParallelComponentTag , typename MV >
auto get_parallel_component (const GlobalCache< MV > &cache) -> const Parallel::proxy_from_parallel_component< GlobalCache_detail::get_component_if_mocked< typename MV::component_list, ParallelComponentTag > > &
 

Detailed Description

template<typename Metavariables>
class Parallel::GlobalCache< Metavariables >

A Charm++ chare that caches constant data once per Charm++ node or non-constant data once per Charm++ core.

Metavariables must define the following metavariables:

  • component_list typelist of ParallelComponents
  • const_global_cache_tags (possibly empty) typelist of tags of constant data
  • mutable_global_cache_tags (possibly empty) typelist of tags of non-constant data

The tag lists for the const items added to the GlobalCache is created by combining the following tag lists:

  • Metavariables::const_global_cache_tags which should contain only those tags that cannot be added from the other tag lists below.
  • Component::const_global_cache_tags for each Component in Metavariables::component_list which should contain the tags needed by any simple actions called on the Component, as well as tags need by the allocate_array function of an array component. The type alias may be omitted for an empty list.
  • Action::const_global_cache_tags for each Action in the phase_dependent_action_list of each Component of Metavariables::component_list which should contain the tags needed by that Action. The type alias may be omitted for an empty list.

The tag lists for the non-const items added to the GlobalCache is created by combining exactly the same tag lists as for the const items, except with const_global_cache_tags replaced by mutable_global_cache_tags.

The tags in the const_global_cache_tags and mutable_global_cache_tags type lists are db::SimpleTags that have a using option_tags type alias and a static function create_from_options that are used to create the constant data from input file options.

References to const items in the GlobalCache are also added to the db::DataBox of each Component in the Metavariables::component_list with the same tag with which they were inserted into the GlobalCache. References to non-const items in the GlobalCache are not added to the db::DataBox.

Member Function Documentation

◆ mutable_cache_item_is_ready()

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

Returns whether the object referred to by GlobalCacheTag (which must be a mutable cache tag) is ready to be accessed by a get call.

function is a user-defined invokable that:

  • takes one argument: a const reference to the object referred to by the GlobalCacheTag.
  • if the data is ready, returns a default constructed std::unique_ptr<CallBack>
  • if the data is not ready, returns a std::unique_ptr<CallBack>, where the Callback will re-invoke the current action on the current parallel component.

◆ mutate()

template<typename Metavariables >
template<typename GlobalCacheTag , typename Function , typename... Args>
void Parallel::GlobalCache< Metavariables >::mutate ( const std::tuple< Args... > &  args)

Mutates the non-const object identified by GlobalCacheTag.

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

Internally calls Function::apply(), where Function is a user-defined struct and Function::apply() is a user-defined static 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 the contents of args as subsequent arguments.


The documentation for this class was generated from the following file: