Quinoa all test code coverage report
Current view: top level - Base - ChareStateCollector.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 13 13 100.0 %
Date: 2024-11-22 08:51:48 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 16 43.8 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Base/ChareStateCollector.cpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Charm++ chare state collector group
       9                 :            :   \details   Charm++ chare state collectory group used for debugging.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : 
      13                 :            : #include <vector>
      14                 :            : #include <unordered_map>
      15                 :            : 
      16                 :            : #include "ChareStateCollector.hpp"
      17                 :            : #include "HashMapReducer.hpp"
      18                 :            : 
      19                 :            : namespace tk {
      20                 :            : 
      21                 :            : static CkReduction::reducerType stateMerger;
      22                 :            : 
      23                 :            : } // tk::
      24                 :            : 
      25                 :            : using tk::ChareStateCollector;
      26                 :            : 
      27                 :            : void
      28                 :        626 : ChareStateCollector::registerReducers()
      29                 :            : // *****************************************************************************
      30                 :            : //  Configure Charm++ reduction types
      31                 :            : //! \details Since this is a [initnode] routine, the runtime system executes the
      32                 :            : //!   routine exactly once on every logical node early on in the Charm++ init
      33                 :            : //!   sequence. Must be static as it is called without an object. See also:
      34                 :            : //!   Section "Initializations at Program Startup" at in the Charm++ manual
      35                 :            : //!   http://charm.cs.illinois.edu/manuals/html/charm++/manual.html.
      36                 :            : // *****************************************************************************
      37                 :            : {
      38                 :        626 :   stateMerger =
      39                 :        626 :     CkReduction::addReducer( tk::mergeHashMap< int, decltype(m_state) > );
      40                 :        626 : }
      41                 :            : 
      42                 :            : void
      43                 :      16994 : ChareStateCollector::insert( const std::string& ch, int id, int pe, uint64_t it,
      44                 :            :                              const std::string& fn )
      45                 :            : // *****************************************************************************
      46                 :            : //  Insert new state entry
      47                 :            : //! \param[in] ch Chare name
      48                 :            : //! \param[in] id Chare thisIndex
      49                 :            : //! \param[in] pe Chare PE happens to reside on
      50                 :            : //! \param[in] it Iteration count
      51                 :            : //! \param[in] fn Chare member function name
      52                 :            : // *****************************************************************************
      53                 :            : {
      54 [ +  - ][ +  - ]:      16994 :   m_state.push_back( ChareState{{ ch, id, pe, it, fn, m_timer.dsec() }} );
      55                 :      16994 : }
      56                 :            : 
      57                 :            : void
      58                 :        402 : ChareStateCollector::collect( bool error, CkCallback cb )
      59                 :            : // *****************************************************************************
      60                 :            : //  Collect chare state
      61                 :            : //! \param[in] error If true we are called due to an error, if false, user is
      62                 :            : //!   just curious
      63                 :            : //! \param[in] cb Callback to use for the reduction
      64                 :            : // *****************************************************************************
      65                 :            : {
      66                 :            :   // Will aggregate states across all PEs categorized by PEs
      67 [ +  - ][ +  - ]:       1608 :   std::unordered_map< int, std::vector< ChareState > > s{{ CkMyPe(), m_state }};
      68                 :            : 
      69                 :            :   // If we are called due to an error, encode a -1 chare id from which the
      70                 :            :   // receiving side will know about the error.
      71 [ -  + ][ -  - ]:        402 :   if (error) s[-1];
      72                 :            : 
      73                 :            :   // Aggregate states collected by this PE across all PEs
      74         [ +  - ]:        804 :   auto stream = tk::serialize( s );
      75         [ +  - ]:        402 :   contribute( stream.first, stream.second.get(), stateMerger, cb );
      76                 :        402 : }
      77                 :            : 
      78                 :            : #include "NoWarning/charestatecollector.def.h"

Generated by: LCOV version 1.14