Xyst test code coverage report
Current view: top level - Inciter - HoleReducer.cpp (source / functions) Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 0.0 % 9 0
Test Date: 2025-08-13 22:18:46 Functions: 0.0 % 2 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 0.0 % 16 0

             Branch data     Line data    Source code
       1                 :             : // *****************************************************************************
       2                 :             : /*!
       3                 :             :   \file      src/Inciter/HoleReducer.cpp
       4                 :             :   \copyright 2012-2015 J. Bakosi,
       5                 :             :              2016-2018 Los Alamos National Security, LLC.,
       6                 :             :              2019-2021 Triad National Security, LLC.,
       7                 :             :              2022-2025 J. Bakosi
       8                 :             :              All rights reserved. See the LICENSE file for details.
       9                 :             :   \brief     Custom Charm++ reducer for aggregating hole data across PEs
      10                 :             :   \details   Custom Charm++ reducer for aggregating hole data across PEs.
      11                 :             : */
      12                 :             : // *****************************************************************************
      13                 :             : 
      14                 :             : #include <stddef.h>
      15                 :             : #include <type_traits>
      16                 :             : #include <memory>
      17                 :             : 
      18                 :             : #include "HoleReducer.hpp"
      19                 :             : #include "Exception.hpp"
      20                 :             : #include "ContainerUtil.hpp"
      21                 :             : 
      22                 :             : namespace inciter {
      23                 :             : 
      24                 :             : std::pair< int, std::unique_ptr<char[]> >
      25         [ -  - ]:           0 : serialize( const std::unordered_map< std::size_t, std::vector< tk::real > >& d )
      26                 :             : // *****************************************************************************
      27                 :             : // Serialize hole surface data to raw memory stream
      28                 :             : //! \param[in] d Hole data structure
      29                 :             : //! \return Pair of the length and the raw stream containing serialized data
      30                 :             : // *****************************************************************************
      31                 :             : {
      32                 :             :   // Prepare for serializing hole data to a raw binary stream, compute size
      33                 :             :   PUP::sizer sizer;
      34                 :             :   sizer | const_cast< std::unordered_map< std::size_t,
      35                 :             :                                           std::vector< tk::real > >& >( d );
      36                 :             : 
      37                 :             :   // Create raw character stream to store the serialized data
      38                 :             :   std::unique_ptr<char[]> flatData = std::make_unique<char[]>( sizer.size() );
      39                 :             : 
      40                 :             :   // Serialize vector, each message will contain a vector
      41                 :             :   PUP::toMem packer( flatData.get() );
      42                 :             :   packer | const_cast< std::unordered_map< std::size_t,
      43                 :             :                                            std::vector< tk::real > >& >( d );
      44                 :             : 
      45                 :             :   // Return size of and raw stream
      46                 :           0 :   return { sizer.size(), std::move(flatData) };
      47                 :             : }
      48                 :             : 
      49                 :             : CkReductionMsg*
      50         [ -  - ]:           0 : mergeHole( int nmsg, CkReductionMsg **msgs )
      51                 :             : // *****************************************************************************
      52                 :             : // Charm++ custom reducer for merging hole data during reduction across PEs
      53                 :             : //! \param[in] nmsg Number of messages in msgs
      54                 :             : //! \param[in] msgs Charm++ reduction message containing the serialized
      55                 :             : //!   hole surface data
      56                 :             : //! \return Aggregated hole surface data built for further aggregation if needed
      57                 :             : // *****************************************************************************
      58                 :             : {
      59                 :             :   std::unordered_map< std::size_t, std::vector< tk::real > > v;
      60                 :             : 
      61                 :             :   // Create PUP deserializer based on message passed in
      62         [ -  - ]:           0 :   PUP::fromMem creator( msgs[0]->getData() );
      63                 :             : 
      64                 :             :   // Deserialize vector from raw stream
      65                 :             :   creator | v;
      66                 :             : 
      67         [ -  - ]:           0 :   for (int m=1; m<nmsg; ++m) {
      68                 :             :     // Unpack partial hole data
      69                 :             :     std::unordered_map< std::size_t, std::vector< tk::real > > inholes;
      70         [ -  - ]:           0 :     PUP::fromMem curCreator( msgs[m]->getData() );
      71                 :             :     curCreator | inholes;
      72                 :             :     // Aggregate hole data
      73         [ -  - ]:           0 :     for (auto&& [hid,data] : inholes) {
      74                 :             :       std::move( begin(data), end(data), std::back_inserter(v[hid]) );
      75                 :             :      }
      76                 :             :   }
      77                 :             : 
      78                 :             :   // Serialize concatenated hole surface data to raw stream
      79         [ -  - ]:           0 :   auto stream = serialize( v );
      80                 :             : 
      81                 :             :   // Forward serialized hole surface data
      82         [ -  - ]:           0 :   return CkReductionMsg::buildNew( stream.first, stream.second.get() );
      83                 :             : }
      84                 :             : 
      85                 :             : } // inciter::
        

Generated by: LCOV version 2.0-1