Quinoa all test code coverage report
Current view: top level - Transfer - M2MTransfer.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 58 60 96.7 %
Date: 2024-05-15 16:30:14 Functions: 11 13 84.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 66 54.5 %

           Branch data     Line data    Source code
       1                 :            : // Controller for the library
       2                 :            : 
       3                 :            : #include "M2MTransfer.hpp"
       4                 :            : #include "TransferDetails.hpp"
       5                 :            : 
       6                 :            : #include <cassert>
       7                 :            : 
       8                 :            : namespace exam2m {
       9                 :            : 
      10                 :            : #if defined(__clang__)
      11                 :            :   #pragma clang diagnostic push
      12                 :            :   #pragma clang diagnostic ignored "-Wmissing-prototypes"
      13                 :            :   #pragma clang diagnostic ignored "-Wmissing-variable-declarations"
      14                 :            : #endif
      15                 :            : 
      16                 :            : /* readonly */ CProxy_M2MTransfer m2mtransferProxy;
      17                 :            : //! \brief Charm handle to the collision detection library instance
      18                 :            : /* readonly */ CollideHandle collideHandle;
      19                 :            : 
      20                 :        310 : void collisionHandler( [[maybe_unused]] void *param,
      21                 :            :                         int nColl,
      22                 :            :                         Collision *colls )
      23                 :            : {
      24                 :        310 :   m2mtransferProxy.ckLocalBranch()->distributeCollisions( nColl, colls );
      25                 :        310 : }
      26                 :            : 
      27                 :            : #if defined(__clang__)
      28                 :            :   #pragma clang diagnostic pop
      29                 :            : #endif
      30                 :            : 
      31                 :            : #if defined(__clang__)
      32                 :            :   #pragma clang diagnostic push
      33                 :            :   #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
      34                 :            :   #pragma clang diagnostic ignored "-Wunused-private-field"
      35                 :            :   #pragma clang diagnostic ignored "-Wvla"
      36                 :            :   #pragma clang diagnostic ignored "-Wvla-extension"
      37                 :            : #endif
      38                 :            : 
      39                 :          4 : void addMesh(CkArrayID p, int elem, CkCallback cb) {
      40         [ +  - ]:          4 :   m2mtransferProxy[0].addMesh(p, elem, cb);
      41                 :          4 : }
      42                 :            : 
      43                 :       1232 : void setSourceTets(CkArrayID p, int index, std::vector< std::size_t >* inpoel, tk::UnsMesh::Coords* coords, const tk::Fields& u) {
      44                 :       1232 :   m2mtransferProxy.ckLocalBranch()->setSourceTets(p, index, inpoel, coords, u);
      45                 :       1232 : }
      46                 :            : 
      47                 :       1232 : void setDestPoints(CkArrayID p, int index, tk::UnsMesh::Coords* coords, tk::Fields& u, CkCallback cb) {
      48         [ +  - ]:       1232 :   m2mtransferProxy.ckLocalBranch()->setDestPoints(p, index, coords, u, cb);
      49                 :       1232 : }
      50                 :            : 
      51                 :        193 : LibMain::LibMain(CkArgMsg* msg) {
      52         [ +  - ]:        193 :   delete msg;
      53 [ +  - ][ +  - ]:        386 :   m2mtransferProxy = CProxy_M2MTransfer::ckNew();
      54                 :            : 
      55                 :            :   // TODO: Need to make sure this is actually correct
      56                 :          0 :   CollideGrid3d gridMap(CkVector3d(0, 0, 0),CkVector3d(2, 100, 2));
      57                 :            :   collideHandle = CollideCreate(gridMap,
      58 [ +  - ][ +  - ]:        193 :       CollideSerialClient(collisionHandler, 0));
      59                 :        193 : }
      60                 :            : 
      61                 :        582 : M2MTransfer::M2MTransfer() : current_chunk(0) {}
      62                 :            : 
      63                 :          4 : void M2MTransfer::addMesh(CkArrayID p, int elem, CkCallback cb) {
      64                 :          4 :   auto id = static_cast<std::size_t>(CkGroupID(p).idx);
      65         [ +  - ]:          4 :   if (proxyMap.count(id) == 0) {
      66                 :          8 :     CkArrayOptions opts;
      67         [ +  - ]:          4 :     opts.bindTo(p);
      68         [ +  - ]:          4 :     opts.setNumInitial(elem);
      69                 :            :     MeshData mesh;
      70                 :          4 :     mesh.m_nchare = elem;
      71                 :          4 :     mesh.m_firstchunk = current_chunk;
      72 [ +  - ][ +  - ]:          8 :     mesh.m_proxy = CProxy_TransferDetails::ckNew(p, mesh, cb, opts);
                 [ -  - ]
      73                 :            :     proxyMap[id] = mesh;
      74         [ -  + ]:          4 :     current_chunk += elem;
      75                 :            :   } else {
      76                 :          0 :     CkAbort("Uhoh...\n");
      77                 :            :   }
      78                 :          4 : }
      79                 :         14 : void M2MTransfer::setMesh( CkArrayID p, MeshData d ) {
      80         [ +  - ]:         14 :   proxyMap[static_cast<std::size_t>(CkGroupID(p).idx)] = d;
      81                 :         14 : }
      82                 :            : 
      83                 :       1232 : void M2MTransfer::setDestPoints(CkArrayID p, int index, tk::UnsMesh::Coords* coords, tk::Fields& u, CkCallback cb) {
      84                 :       1232 :   m_destmesh = static_cast<std::size_t>(CkGroupID(p).idx);
      85                 :       1232 :   TransferDetails* w = proxyMap[m_destmesh].m_proxy[index].ckLocal();
      86                 :            :   assert(w);
      87         [ +  - ]:       1232 :   w->setDestPoints(coords, u, cb);
      88                 :       1232 : }
      89                 :            : 
      90                 :       1232 : void M2MTransfer::setSourceTets(CkArrayID p, int index, std::vector< std::size_t >* inpoel, tk::UnsMesh::Coords* coords, const tk::Fields& u) {
      91                 :       1232 :   m_sourcemesh = static_cast<std::size_t>(CkGroupID(p).idx);
      92                 :       1232 :   TransferDetails* w = proxyMap[m_sourcemesh].m_proxy[index].ckLocal();
      93                 :            :   assert(w);
      94                 :       1232 :   w->setSourceTets(inpoel, coords, u);
      95                 :       1232 : }
      96                 :            : 
      97                 :            : void
      98                 :        310 : M2MTransfer::distributeCollisions(int nColl, Collision* colls)
      99                 :            : // *****************************************************************************
     100                 :            : //  Called when all potential collisions have been found, and now need to be
     101                 :            : //  destributed to the chares in the destination mesh to determine actual
     102                 :            : //  collisions.
     103                 :            : //! \param[in] nColl Number of potential collisions found
     104                 :            : //! \param[in] colls The list of potential collisions
     105                 :            : // *****************************************************************************
     106                 :            : {
     107                 :            :   //CkPrintf("Collisions found: %i\n", nColl);
     108                 :        310 :   auto first = static_cast<int>(proxyMap[m_destmesh].m_firstchunk);
     109                 :        310 :   auto nchare = static_cast<int>(proxyMap[m_destmesh].m_nchare);
     110 [ +  + ][ +  + ]:       3084 :   std::vector<Collision> separated[nchare];
         [ +  + ][ -  - ]
                 [ -  - ]
     111                 :            : 
     112                 :            :   // Separate collisions based on the destination mesh chare they belong to
     113         [ +  + ]:    3461332 :   for (int i = 0; i < nColl; i++) {
     114 [ +  + ][ +  - ]:    3461022 :     if (colls[i].A.chunk >= first && colls[i].A.chunk < first + nchare) {
     115         [ +  - ]:     203350 :       separated[static_cast<std::size_t>(colls[i].A.chunk - first)].push_back(colls[i]);
     116                 :            :     } else {
     117         [ +  - ]:    3257672 :       separated[static_cast<std::size_t>(colls[i].B.chunk - first)].push_back(colls[i]);
     118                 :            :     }
     119                 :            :   }
     120                 :            : 
     121                 :            :   // Send out each list to the destination chares for further processing
     122         [ +  + ]:       1542 :   for (int i = 0; i < nchare; i++) {
     123                 :            :     //CkPrintf("Dest mesh chunk %i has %lu\n", i, separated[i].size());
     124 [ +  - ][ +  - ]:       3696 :     proxyMap[m_destmesh].m_proxy[i].processCollisions(
                 [ +  - ]
     125         [ +  - ]:       1232 :         proxyMap[m_sourcemesh].m_proxy,
     126                 :            :         proxyMap[m_sourcemesh].m_nchare,
     127         [ +  - ]:       1232 :         proxyMap[m_sourcemesh].m_firstchunk,
     128                 :       1232 :         static_cast<int>(separated[i].size()),
     129         [ +  - ]:       1232 :         separated[i].data() );
     130                 :        310 :   }
     131                 :        310 : }
     132                 :            : 
     133                 :            : #if defined(__clang__)
     134                 :            :   #pragma clang diagnostic pop
     135                 :            : #endif
     136                 :            : 
     137                 :            : } // exam2m::
     138                 :            : 
     139                 :            : #include "NoWarning/m2mtransfer.def.h"

Generated by: LCOV version 1.14