SpECTRE
v2023.01.13
|
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 | mutable_global_cache_proxy_type = CProxy_MutableGlobalCache< 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. | |
using | chare_type = Parallel::Algorithms::Nodegroup |
using | tags_list = get_const_global_cache_tags< Metavariables > |
Public Member Functions | |
GlobalCache (tuples::tagged_tuple_from_typelist< get_const_global_cache_tags< Metavariables > > const_global_cache, MutableGlobalCache< Metavariables > *mutable_global_cache, std::vector< size_t > procs_per_node={1}, const int my_proc=0, const int my_node=0, const int my_local_rank=0, 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 > &¶llel_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... | |
void | compute_size_for_memory_monitor (const double time) |
Entry method that computes the size of the local branch of the GlobalCache and sends it to the MemoryMonitor parallel component. More... | |
void | set_resource_info (const Parallel::ResourceInfo< Metavariables > &resource_info) |
Entry method that will set the value of the Parallel::Tags::ResourceInfo tag to the value passed in (if the tag exists in the GlobalCache) More... | |
const Parallel::ResourceInfo< Metavariables > & | get_resource_info () const |
Retrieve the resource_info. | |
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). | |
bool | mutable_global_cache_proxy_is_set () const |
Returns true if the GlobalCache was constructed with a Proxy to the MutableGlobalCache (i.e. the GlobalCache is charm-aware). | |
mutable_global_cache_proxy_type | mutable_global_cache_proxy () |
Returns a proxy to the MutableGlobalCache if the proxy has been set. If it hasn't been set, an ERROR will occur meaning that this method can't be used in the testing framework. | |
int | number_of_procs () const |
Wrappers for charm++ informational functions. More... | |
int | number_of_nodes () const |
Number of nodes. | |
int | procs_on_node (const int node_index) const |
Number of processing elements on the given node. | |
int | first_proc_on_node (const int node_index) const |
Index of first processing element on the given node. | |
int | node_of (const int proc_index) const |
Index of the node for the given processing element. | |
int | local_rank_of (const int proc_index) const |
The local index for the given processing element on its node. | |
int | my_proc () const |
Index of my processing element. | |
int | my_node () const |
Index of my node. | |
int | my_local_rank () const |
The local index of my processing element on my node. This is in the interval 0, ..., procs_on_node(my_node()) - 1. | |
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 > > & |
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 ParallelComponentsconst_global_cache_tags
(possibly empty) typelist of tags of constant datamutable_global_cache_tags
(possibly empty) typelist of tags of non-constant dataThe 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.
void Parallel::GlobalCache< Metavariables >::compute_size_for_memory_monitor | ( | const double | time | ) |
Entry method that computes the size of the local branch of the GlobalCache and sends it to the MemoryMonitor parallel component.
component_list
of the metavariables. Also can't be called in the testing framework. Trying to do either of these will result in an ERROR. 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:
GlobalCacheTag
.std::unique_ptr<CallBack>
std::unique_ptr<CallBack>
, where the Callback
will re-invoke the current action on the current parallel component. 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.
int Parallel::GlobalCache< Metavariables >::number_of_procs |
Wrappers for charm++ informational functions.
Number of processing elements
void Parallel::GlobalCache< Metavariables >::set_resource_info | ( | const Parallel::ResourceInfo< Metavariables > & | resource_info | ) |
Entry method that will set the value of the Parallel::Tags::ResourceInfo tag to the value passed in (if the tag exists in the GlobalCache)
This is only meant to be called once.