LCOV - code coverage report
Current view: top level - coupling/sendrecv - FromMD2Macro.cpph (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 31 0
Test Date: 2026-08-21 15:14:06 Functions: 0.0 % 6 0

            Line data    Source code
       1              : // Copyright (C) 2015 Technische Universitaet Muenchen
       2              : // This file is part of the Mamico project. For conditions of distribution
       3              : // and use, please see the copyright notice in Mamico's main folder, or at
       4              : // www5.in.tum.de/mamico
       5              : 
       6              : #pragma region collective operations
       7              : 
       8              : template <class Cell_T, unsigned int dim>
       9              : template <class Container_T1, class Container_T2>
      10              : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::reduceFromMD2Macro(std::vector<coupling::sendrecv::DataExchangeFromMD2Macro<dim>*>& dataExchanges,
      11              :                                                                        const Container_T1& src, const Container_T2& dst) {
      12              :   const unsigned int rank = IDXS.getRank();
      13              : 
      14              :   // empty send and receive buffers
      15              :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::deleteBuffers();
      16              : 
      17              :   for (unsigned int i = 0; i < dataExchanges.size(); ++i) {
      18              :     if (nullptr == dataExchanges[i])
      19              :       continue;
      20              :     // fill the reduce buffers (expands the reduce buffer)
      21              :     writeToReduceBuffer(*dataExchanges[i], src);
      22              :     // allocate the reduce buffers (additional)
      23              :     allocateReduceBufferForReceiving(*dataExchanges[i], dst);
      24              :   }
      25              : 
      26              :   // allocate all requests -> needs to be called AFTER all buffers are filled
      27              :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateReduceRequests(rank);
      28              : 
      29              :   // trigger MPI reduce
      30              :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::triggerReduce(rank);
      31              : 
      32              :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::waitAllCollectiveOperations();
      33              : 
      34              :   for (unsigned int i = 0; i < dataExchanges.size(); ++i) {
      35              :     if (nullptr == dataExchanges[i])
      36              :       continue;
      37              :     readFromReduceBuffer(*dataExchanges[i], dst);
      38              :   }
      39              : }
      40              : 
      41              : template <class Cell_T, unsigned int dim>
      42              : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::writeToReduceBuffer(coupling::sendrecv::DataExchangeFromMD2Macro<dim>& dataExchange,
      43              :                                                                         const Local_Container_T& cells) {
      44              :   for (auto idx : I10())
      45              :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::writeToReduceBuffer(dataExchange, cells[idx], idx);
      46              : }
      47              : 
      48              : template <class Cell_T, unsigned int dim>
      49              : template <class Container_T>
      50              : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::allocateReduceBufferForReceiving(coupling::sendrecv::DataExchangeFromMD2Macro<dim>& dataExchange,
      51              :                                                                                      const Container_T& cells) {
      52              :   I01* idx;
      53              :   Cell_T* cell;
      54              :   for (auto pair : cells) {
      55              :     std::tie(cell, idx) = pair;
      56              :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateReduceBufferForReceiving(dataExchange, idx);
      57              :   }
      58              : }
      59              : 
      60              : template <class Cell_T, unsigned int dim>
      61              : template <class Container_T>
      62              : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::readFromReduceBuffer(coupling::sendrecv::DataExchangeFromMD2Macro<dim>& dataExchange,
      63              :                                                                          const Container_T& cells) {
      64              :   I01* idx;
      65              :   Cell_T* cell;
      66              :   for (auto pair : cells) {
      67              :     std::tie(cell, idx) = pair;
      68              :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::readFromReduceBuffer(dataExchange, cell, idx);
      69              :   }
      70              : }
      71              : 
      72              : #pragma endregion // collective operations
      73              : 
      74              : #pragma region sequential operations
      75              : 
      76              : template <class Cell_T, unsigned int dim>
      77            0 : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::sendFromMD2Macro(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange, const Local_Container_T& src,
      78              :                                                                      const Macro_Container_T& dst) {
      79            0 :   sendFromMD2MacroNonBlocking(dataExchange, src, dst);
      80            0 :   wait4SendFromMD2Macro(dataExchange, dst);
      81            0 : }
      82              : 
      83              : template <class Cell_T, unsigned int dim>
      84            0 : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::sendFromMD2MacroNonBlocking(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
      85              :                                                                                 const Local_Container_T& src, const Macro_Container_T& dst) {
      86              :   // empty send and receive buffers
      87            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::deleteBuffers();
      88              : 
      89              :   // allocate the receive buffers and trigger the MPI-recv
      90            0 :   allocateReceiveBuffers(dataExchange, dst);
      91              :   // fill the send buffers
      92            0 :   writeToSendBuffer(dataExchange, src);
      93              : 
      94              :   // allocate all requests -> needs to be called AFTER all buffers are filled
      95            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateRequests();
      96              : 
      97              :   // trigger MPI recv/send
      98            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::triggerReceiving(dataExchange);
      99            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::triggerSending(dataExchange);
     100            0 : }
     101              : 
     102              : template <class Cell_T, unsigned int dim>
     103            0 : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::allocateReceiveBuffers(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
     104              :                                                                            const Macro_Container_T& cells) {
     105            0 :   I01 idx;
     106              :   Cell_T* cell;
     107            0 :   for (auto pair : cells) {
     108            0 :     std::tie(cell, idx) = pair;
     109            0 :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateReceiveBuffers(dataExchange, idx);
     110              :   }
     111            0 : }
     112              : 
     113              : template <class Cell_T, unsigned int dim>
     114            0 : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::writeToSendBuffer(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
     115              :                                                                       const Local_Container_T& cells) {
     116            0 :   coupling::datastructures::CellContainer<I10, dim> container;
     117            0 :   for (auto idx : I10())
     118            0 :     container << cells[idx];
     119            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::writeToSendBuffer(dataExchange, container);
     120            0 : }
     121              : 
     122              : template <class Cell_T, unsigned int dim>
     123            0 : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::wait4SendFromMD2Macro(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
     124              :                                                                           const Macro_Container_T& cells) {
     125              :   // wait for all send- and receive operations to complete
     126            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::waitAllOperations();
     127              : 
     128              :   // fill information from receive buffers into the coupling cells
     129            0 :   readFromReceiveBuffer(dataExchange, cells);
     130            0 : }
     131              : 
     132              : template <class Cell_T, unsigned int dim>
     133            0 : void coupling::sendrecv::FromMD2Macro<Cell_T, dim>::readFromReceiveBuffer(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
     134              :                                                                           const Macro_Container_T& cells) {
     135            0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::readFromReceiveBuffer(dataExchange, cells);
     136            0 : }
     137              : 
     138              : #pragma endregion // sequential operations
        

Generated by: LCOV version 2.0-1