SpECTRE Documentation Coverage Report
Current view: top level - Parallel - Local.hpp Hit Total Coverage
Commit: 9e4176f904ee1c51f05efc42ff1e485357699444 Lines: 2 3 66.7 %
Date: 2024-03-28 23:18:37
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 <charm++.h>
       7             : 
       8             : #include "Parallel/TypeTraits.hpp"
       9             : 
      10             : namespace Parallel {
      11             : /// \cond
      12             : namespace Algorithms {
      13             : struct Singleton;
      14             : }  // namespace Algorithms
      15             : /// \endcond
      16             : 
      17             : /// Wrapper for calling Charm++'s `.ckLocal()` on a proxy
      18             : ///
      19             : /// The Proxy must be to a Charm++ array chare (implementing a singleton
      20             : /// design pattern using a single-element array) or to a Charm++ array element
      21             : /// chare (i.e., the proxy obtained by indexing into a Charm++ array chare).
      22             : ///
      23             : /// The function returns a pointer to the chare if it exists on the local
      24             : /// processor, and NULL if it does not. See the Charm++ documentation.
      25             : /// It is the responsibility of the user to check the result pointer is valid.
      26             : template <typename Proxy>
      27           1 : auto* local(Proxy&& proxy) {
      28             :   // It only makes sense to call .ckLocal() on some kinds of proxies
      29             :   static_assert(is_array_element_proxy<std::decay_t<Proxy>>::value or
      30             :                 is_array_proxy<std::decay_t<Proxy>>::value);
      31             :   if constexpr (std::is_same_v<
      32             :                     Parallel::Algorithms::Singleton,
      33             :                     typename Parallel::get_parallel_component_from_proxy<
      34             :                         std::decay_t<Proxy>>::type::chare_type>) {
      35             :     // The array case should be a single-element array serving as a singleton
      36             :     return proxy[0].ckLocal();
      37             :   } else {
      38             :     return proxy.ckLocal();
      39             :   }
      40             : }
      41             : 
      42             : /// Wrapper for calling Charm++'s `.ckLocalBranch()` on a proxy
      43             : ///
      44             : /// The Proxy must be to a Charm++ group chare or nodegroup chare.
      45             : ///
      46             : /// The function returns a pointer to the local group/nodegroup chare.
      47             : template <typename Proxy>
      48           1 : auto* local_branch(Proxy&& proxy) {
      49             :   // It only makes sense to call .ckLocalBranch() on some kinds of proxies
      50             :   static_assert(is_group_proxy<std::decay_t<Proxy>>::value or
      51             :                 is_node_group_proxy<std::decay_t<Proxy>>::value);
      52             :   return proxy.ckLocalBranch();
      53             : }
      54             : 
      55             : }  // namespace Parallel

Generated by: LCOV version 1.14