LCOV - code coverage report
Current view: top level - coupling/sendrecv - FromMacro2MD.cpph (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 26 0.0 %
Date: 2025-06-25 11:26:37 Functions: 0 6 0.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 sequential operations
       7             : 
       8             : template <class Cell_T, unsigned int dim>
       9             : template <class Container_T>
      10           0 : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::sendFromMacro2MD(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange, const Local_Container_T& dst,
      11             :                                                                      const Container_T& src) {
      12             :   // send data
      13           0 :   sendFromMacro2MDNonBlocking(dataExchange, src);
      14             :   // wait for MPI calls to be finished and fill coupling cells from Mamico
      15           0 :   wait4SendFromMacro2MD(dataExchange, dst);
      16           0 : }
      17             : 
      18             : template <class Cell_T, unsigned int dim>
      19             : template <class Container_T>
      20           0 : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::sendFromMacro2MDNonBlocking(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
      21             :                                                                                 const Container_T& cells) {
      22             :   // empty send and receive buffers
      23           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::deleteBuffers();
      24             : 
      25             :   // allocate the receive buffers and trigger the MPI-recv
      26           0 :   allocateReceiveBuffers(dataExchange);
      27             :   // fill the send buffers
      28           0 :   writeToSendBuffer(dataExchange, cells);
      29             : 
      30             :   // allocate all requests -> needs to be called AFTER all buffers are filled
      31           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateRequests();
      32             : 
      33             :   // trigger MPI calls for send/recv
      34           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::triggerReceiving(dataExchange);
      35           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::triggerSending(dataExchange);
      36           0 : }
      37             : 
      38             : template <class Cell_T, unsigned int dim>
      39           0 : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::allocateReceiveBuffers(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange) {
      40           0 :   for (auto idx : I02())
      41           0 :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateReceiveBuffers(dataExchange, idx);
      42           0 : }
      43             : 
      44             : template <class Cell_T, unsigned int dim>
      45             : template <class Container_T>
      46           0 : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::writeToSendBuffer(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange, const Container_T& cells) {
      47           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::writeToSendBuffer(dataExchange, cells);
      48           0 : }
      49             : 
      50             : template <class Cell_T, unsigned int dim>
      51           0 : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::wait4SendFromMacro2MD(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
      52             :                                                                           const Local_Container_T& cells) {
      53             :   // wait for all send- and receive operations to complete
      54           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::waitAllOperations();
      55             : 
      56             :   // fill information from receive buffers into the coupling cells
      57           0 :   readFromReceiveBuffer(dataExchange, cells);
      58           0 : }
      59             : 
      60             : template <class Cell_T, unsigned int dim>
      61           0 : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::readFromReceiveBuffer(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
      62             :                                                                           const Local_Container_T& cells) {
      63           0 :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::readFromReceiveBuffer(dataExchange, cells);
      64           0 : }
      65             : 
      66             : #pragma endregion // sequential operations
      67             : 
      68             : #pragma region collective operations
      69             : template <class Cell_T, unsigned int dim>
      70             : template <class Container_T>
      71             : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::bcastFromMacro2MD(
      72             :     std::vector<coupling::sendrecv::DataExchangeFromMacro2MD<dim>*>& dataExchangeFromCouplingCellServices, const Container_T& src,
      73             :     std::vector<Local_Container_T> dst) {
      74             :   // empty send and receive buffers
      75             :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::deleteBuffers();
      76             : 
      77             :   const unsigned int rank = IDXS.getRank();
      78             : 
      79             :   for (auto& de : dataExchangeFromCouplingCellServices) {
      80             :     if (nullptr == de)
      81             :       continue;
      82             :     // TODO compute target ranks here and pass them in
      83             :     writeToSendBufferCollective(*de, src);
      84             :     allocateReceiveBuffersCollective(*de);
      85             :   }
      86             : 
      87             :   SendReceiveBuffer<Cell_T, dim>::allocateBcastRequests(rank);
      88             : 
      89             :   // SendReceiveBuffer<Cell_T,dim >::triggerReceivingCollective(dataExchange);
      90             :   SendReceiveBuffer<Cell_T, dim>::triggerBcasts(rank);
      91             : 
      92             :   coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::waitAllCollectiveOperations();
      93             : 
      94             :   for (unsigned int i = 0; i < dataExchangeFromCouplingCellServices.size(); ++i) {
      95             :     if (dst[i].empty())
      96             :       continue;
      97             :     if (nullptr == dataExchangeFromCouplingCellServices[i])
      98             :       continue;
      99             :     readFromCollectiveBuffer(*dataExchangeFromCouplingCellServices[i], dst[i]);
     100             :   }
     101             : }
     102             : 
     103             : template <class Cell_T, unsigned int dim>
     104             : template <class Container_T>
     105             : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::writeToSendBufferCollective(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
     106             :                                                                                 const Container_T& cells) {
     107             :   I01 idx;
     108             :   Cell_T* cell;
     109             :   for (auto pair : cells) {
     110             :     std::tie(cell, idx) = pair;
     111             :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::writeToBcastBuffer(dataExchange, cell, idx);
     112             :   }
     113             : }
     114             : 
     115             : template <class Cell_T, unsigned int dim>
     116             : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::allocateReceiveBuffersCollective(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange) {
     117             :   for (auto idx : I02())
     118             :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::allocateBcastBufferForReceiving(dataExchange, idx);
     119             : }
     120             : 
     121             : template <class Cell_T, unsigned int dim>
     122             : void coupling::sendrecv::FromMacro2MD<Cell_T, dim>::readFromCollectiveBuffer(coupling::sendrecv::DataExchange<Cell_T, dim>& dataExchange,
     123             :                                                                              const Local_Container_T& cells) {
     124             :   I01 idx;
     125             :   Cell_T* cell;
     126             :   for (auto pair : cells) {
     127             :     std::tie(cell, idx) = pair;
     128             :     coupling::sendrecv::SendReceiveBuffer<Cell_T, dim>::readFromCollectiveBuffer(dataExchange, *cell, idx);
     129             :   }
     130             : }
     131             : 
     132             : #pragma endregion // collective operations

Generated by: LCOV version 1.14