SpECTRE Documentation Coverage Report
Current view: top level - Parallel/MemoryMonitor - MemoryMonitor.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 2 8 25.0 %
Date: 2024-04-23 20:50:18
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include "DataStructures/DataBox/Protocols/Mutator.hpp"
       7             : #include "Parallel/Algorithms/AlgorithmSingletonDeclarations.hpp"
       8             : #include "Parallel/GlobalCache.hpp"
       9             : #include "Parallel/Local.hpp"
      10             : #include "Parallel/MemoryMonitor/Tags.hpp"
      11             : #include "Parallel/ParallelComponentHelpers.hpp"
      12             : #include "Parallel/Phase.hpp"
      13             : #include "ParallelAlgorithms/Actions/AddSimpleTags.hpp"
      14             : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
      15             : #include "Utilities/Gsl.hpp"
      16             : #include "Utilities/ProtocolHelpers.hpp"
      17             : #include "Utilities/TMPL.hpp"
      18             : 
      19             : /*!
      20             :  * \ingroup ParallelGroup
      21             :  * Holds the MemoryMonitor parallel component and all actions and tags related
      22             :  * to the memory monitor.
      23             :  */
      24           1 : namespace mem_monitor {}
      25             : 
      26             : namespace mem_monitor {
      27             : namespace detail {
      28             : struct InitializeMutator : tt::ConformsTo<db::protocols::Mutator> {
      29             :   using return_tags = tmpl::list<mem_monitor::Tags::MemoryHolder>;
      30             :   using argument_tags = tmpl::list<>;
      31             : 
      32             :   using tag_type = typename mem_monitor::Tags::MemoryHolder::type;
      33             : 
      34             :   static void apply(const gsl::not_null<tag_type*> /*holder*/) {}
      35             : };
      36             : }  // namespace detail
      37             : 
      38             : /*!
      39             :  * \brief Singleton parallel component used for monitoring memory usage of other
      40             :  * parallel components
      41             :  */
      42             : template <class Metavariables>
      43           1 : struct MemoryMonitor {
      44           0 :   using chare_type = Parallel::Algorithms::Singleton;
      45             : 
      46           0 :   using metavariables = Metavariables;
      47             : 
      48           0 :   using phase_dependent_action_list = tmpl::list<Parallel::PhaseActions<
      49             :       Parallel::Phase::Initialization,
      50             :       tmpl::list<Initialization::Actions::AddSimpleTags<
      51             :                      mem_monitor::detail::InitializeMutator>,
      52             :                  Parallel::Actions::TerminatePhase>>>;
      53             : 
      54           0 :   using simple_tags_from_options = Parallel::get_simple_tags_from_options<
      55             :       Parallel::get_initialization_actions_list<phase_dependent_action_list>>;
      56             : 
      57           0 :   static void execute_next_phase(
      58             :       const Parallel::Phase next_phase,
      59             :       Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
      60             :     auto& local_cache = *Parallel::local_branch(global_cache);
      61             :     Parallel::get_parallel_component<MemoryMonitor<Metavariables>>(local_cache)
      62             :         .start_phase(next_phase);
      63             :   }
      64             : };
      65             : }  // namespace mem_monitor

Generated by: LCOV version 1.14