|
SpECTRE
v2026.04.01
|
A Charm++ chare that caches global data once per Charm++ node. 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. | |
| using | chare_type = Parallel::Algorithms::Nodegroup |
| using | const_tags_list = get_const_global_cache_tags<Metavariables> |
| using | ConstTagsTuple = tuples::tagged_tuple_from_typelist<const_tags_list> |
| using | ConstTagsStorage = ConstTagsTuple |
| using | mutable_tags_list = get_mutable_global_cache_tags<Metavariables> |
| using | MutableTagsTuple |
| using | MutableTagsStorage |
Public Member Functions | |
| GlobalCache (ConstTagsTuple const_global_cache, MutableTagsTuple 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) | |
| Constructor meant to be used in the ActionTesting framework. | |
| GlobalCache (ConstTagsTuple const_global_cache, MutableTagsTuple mutable_global_cache, std::optional< main_proxy_type > main_proxy) | |
| Constructor meant to be used in charm-aware settings (with a Main proxy). | |
| GlobalCache (CkMigrateMessage *msg) | |
| void | set_parallel_components (ParallelComponentTuple &¶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 Parallel::ArrayComponentId &array_component_id, 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. | |
| template<typename GlobalCacheTag, typename Function, typename... Args> | |
| void | mutate (const std::tuple< Args... > &args) |
| Mutates the non-const object identified by GlobalCacheTag. | |
| 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. | |
| 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) | |
| void | print_mutable_cache_callbacks (const std::string &file_name) |
| Entry method to print the mutable global cache callbacks upon a deadlock to a file. | |
| const Parallel::ResourceInfo< Metavariables > & | get_resource_info () const |
| Retrieve the resource_info. | |
| void | overlay_cache_data (const tuples::tagged_tuple_from_typelist< Parallel::get_overlayable_option_list< Metavariables > > &data_to_overlay) |
| Overlay new data onto a subset of the GlobalCache's tags. | |
| 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, i.e. we are not charm-aware). | |
| int | number_of_procs () const |
| Wrappers for charm++ informational functions. | |
| 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. | |
Static Public Attributes | |
| static constexpr bool | is_mocked = GlobalCache_detail::mock_global_cache |
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 global data once per Charm++ node.
There are two types of global data that are stored; const data and mutable data. Once the GlobalCache is created, const data cannot be edited but mutable data can be edited using Parallel::mutate.
The template parameter Metavariables must define the following type aliases:
The tag lists for the const items added to the GlobalCache is created by combining the following tag lists:
The tag lists for the mutable 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 (or initial mutable 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 mutable items in the GlobalCache are not added to the db::DataBox.
Since mutable data is stored once per Charm++ node, we require that data structures held by mutable tags have some sort of thread-safety. Particularly, we require data structures in mutable tags be Single Producer-Multiple Consumer. This means that the data structure should be readable/accessible by multiple threads at once, even while being mutated (multiple consumer), but will not be edited/mutated simultaneously on multiple threads (single producer).
| using Parallel::GlobalCache< Metavariables >::MutableTagsStorage |
| using Parallel::GlobalCache< Metavariables >::MutableTagsTuple |
| 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.
| bool Parallel::GlobalCache< Metavariables >::mutable_cache_item_is_ready | ( | const Parallel::ArrayComponentId & | array_component_id, |
| 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:
| 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 (or if that object is a std::unique_ptr<T>, a gsl::not_null<T*>), and takes the contents of args as subsequent arguments.
| int Parallel::GlobalCache< Metavariables >::number_of_procs | ( | ) | const |
Wrappers for charm++ informational functions.
Number of processing elements
| void Parallel::GlobalCache< Metavariables >::overlay_cache_data | ( | const tuples::tagged_tuple_from_typelist< Parallel::get_overlayable_option_list< Metavariables > > & | data_to_overlay | ) |
Overlay new data onto a subset of the GlobalCache's tags.
This is used when reparsing an input file to update option values during a restart from a checkpoint.
| void Parallel::GlobalCache< Metavariables >::print_mutable_cache_callbacks | ( | const std::string & | file_name | ) |
Entry method to print the mutable global cache callbacks upon a deadlock to a file.
For each mutable cache tag, this prints
| 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.