LCOV - code coverage report
Current view: top level - src/Communicate - Window.h (source / functions) Coverage Total Hit
Test: report.info Lines: 100.0 % 4 4
Test Date: 2025-05-12 09:25:18 Functions: 100.0 % 1 1

            Line data    Source code
       1              : //
       2              : // Class Window
       3              : //   Defines an interface to perform one-sided communication.
       4              : //   The term RMA stands for remote memory accesss.
       5              : //
       6              : #ifndef IPPL_MPI_WINDOW_H
       7              : #define IPPL_MPI_WINDOW_H
       8              : 
       9              : #include <iterator>
      10              : 
      11              : namespace ippl {
      12              :     namespace mpi {
      13              :         namespace rma {
      14              : 
      15              :             enum TargetComm {
      16              :                 Active,
      17              :                 Passive
      18              :             };
      19              : 
      20              :             template <TargetComm Target>
      21              :             struct isActiveTarget : std::false_type {};
      22              : 
      23              :             template <>
      24              :             struct isActiveTarget<Active> : std::true_type {};
      25              : 
      26              :             template <TargetComm Target>
      27              :             struct isPassiveTarget : std::false_type {};
      28              : 
      29              :             template <>
      30              :             struct isPassiveTarget<Passive> : std::true_type {};
      31              : 
      32              :             template <TargetComm Target>
      33              :             class Window {
      34              :             public:
      35           60 :                 Window()
      36           60 :                     : count_m(-1)
      37           60 :                     , attached_m(false)
      38           60 :                     , allocated_m(false) {}
      39              : 
      40              :                 ~Window();
      41              : 
      42              :                 operator MPI_Win*() noexcept { return &win_m; }
      43              : 
      44              :                 operator const MPI_Win*() const noexcept { return &win_m; }
      45              : 
      46              :                 template <std::contiguous_iterator Iter>
      47              :                 bool create(const Communicator& comm, Iter first, Iter last);
      48              : 
      49              :                 template <std::contiguous_iterator Iter>
      50              :                 bool attach(const Communicator& comm, Iter first, Iter last);
      51              : 
      52              :                 template <std::contiguous_iterator Iter>
      53              :                 bool detach(Iter first);
      54              : 
      55              :                 void fence(int asrt = 0);
      56              : 
      57              :                 template <std::contiguous_iterator Iter>
      58              :                 void put(Iter first, Iter last, int dest, unsigned int pos,
      59              :                          Request* request = nullptr);
      60              : 
      61              :                 template <typename T>
      62              :                 void put(const T& value, int dest, unsigned int pos, Request* request = nullptr);
      63              : 
      64              :                 template <typename T>
      65              :                 void put(const T* value, int dest, unsigned int pos, Request* request = nullptr);
      66              : 
      67              :                 template <std::contiguous_iterator Iter>
      68              :                 void get(Iter first, Iter last, int source, unsigned int pos,
      69              :                          Request* request = nullptr);
      70              : 
      71              :                 template <typename T>
      72              :                 void get(T& value, int source, unsigned int pos, Request* request = nullptr);
      73              : 
      74              :                 template <typename T>
      75              :                 void get(T* value, int source, unsigned int pos, Request* request = nullptr);
      76              : 
      77              :                 /*
      78              :                  * Passive target communication:
      79              :                  */
      80              :                 void flush(int rank);
      81              : 
      82              :                 void flushall();
      83              : 
      84              :                 enum LockType : int {
      85              :                     Exclusive = MPI_LOCK_EXCLUSIVE,
      86              :                     Shared    = MPI_LOCK_SHARED
      87              :                 };
      88              : 
      89              :                 void lock(int locktype, int rank, int asrt = 0);
      90              : 
      91              :                 void lockall(int asrt = 0);
      92              : 
      93              :                 void unlock(int rank);
      94              : 
      95              :                 void unlockall();
      96              : 
      97              :             private:
      98              :                 MPI_Win win_m;
      99              :                 MPI_Aint count_m;
     100              :                 bool attached_m;
     101              :                 bool allocated_m;
     102              :             };
     103              :         }  // namespace rma
     104              :     }      // namespace mpi
     105              : }  // namespace ippl
     106              : 
     107              : #include "Communicate/Window.hpp"
     108              : 
     109              : #endif
        

Generated by: LCOV version 2.0-1