Xyst test code coverage report
Current view: top level - Inciter - HoleReducer.cpp (source / functions) Hit Total Coverage
Commit: 7512f2d92be539d3e2bf801c81cb357720d8ffd7 Lines: 0 22 0.0 %
Date: 2025-04-27 10:04:21 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 24 0.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                 :          0 :   PUP::sizer sizer;
      34         [ -  - ]:          0 :   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         [ -  - ]:          0 :   std::unique_ptr<char[]> flatData = std::make_unique<char[]>( sizer.size() );
      39                 :            : 
      40                 :            :   // Serialize vector, each message will contain a vector
      41                 :          0 :   PUP::toMem packer( flatData.get() );
      42         [ -  - ]:          0 :   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                 :          0 : }
      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                 :          0 :   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         [ -  - ]:          0 :   creator | v;
      66                 :            : 
      67         [ -  - ]:          0 :   for (int m=1; m<nmsg; ++m) {
      68                 :            :     // Unpack partial hole data
      69                 :          0 :     std::unordered_map< std::size_t, std::vector< tk::real > > inholes;
      70                 :          0 :     PUP::fromMem curCreator( msgs[m]->getData() );
      71         [ -  - ]:          0 :     curCreator | inholes;
      72                 :            :     // Aggregate hole data
      73         [ -  - ]:          0 :     for (auto&& [hid,data] : inholes) {
      74 [ -  - ][ -  - ]:          0 :       std::move( begin(data), end(data), std::back_inserter(v[hid]) );
                 [ -  - ]
      75                 :            :      }
      76                 :          0 :   }
      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                 :          0 : }
      84                 :            : 
      85                 :            : } // inciter::

Generated by: LCOV version 1.16