LCOV - code coverage report
Current view: top level - src/Communicate - Window.h (source / functions) Coverage Total Hit
Test: final_report.info Lines: 100.0 % 5 5
Test Date: 2025-09-02 12:20:15 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          144 :                 Window()
      36          144 :                     : win_m(MPI_WIN_NULL)
      37          144 :                     , count_m(-1)
      38          144 :                     , attached_m(false)
      39          144 :                     , allocated_m(false) {}
      40              : 
      41              :                 ~Window();
      42              : 
      43              :                 operator MPI_Win*() noexcept { return &win_m; }
      44              : 
      45              :                 operator const MPI_Win*() const noexcept { return &win_m; }
      46              : 
      47              :                 template <std::contiguous_iterator Iter>
      48              :                 bool create(const Communicator& comm, Iter first, Iter last);
      49              : 
      50              :                 template <std::contiguous_iterator Iter>
      51              :                 bool attach(const Communicator& comm, Iter first, Iter last);
      52              : 
      53              :                 template <std::contiguous_iterator Iter>
      54              :                 bool detach(Iter first);
      55              : 
      56              :                 void fence(int asrt = 0);
      57              : 
      58              :                 template <std::contiguous_iterator Iter>
      59              :                 void put(Iter first, Iter last, int dest, unsigned int pos,
      60              :                          Request* request = nullptr);
      61              : 
      62              :                 template <typename T>
      63              :                 void put(const T& value, int dest, unsigned int pos, Request* request = nullptr);
      64              : 
      65              :                 template <typename T>
      66              :                 void put(const T* value, int dest, unsigned int pos, Request* request = nullptr);
      67              : 
      68              :                 template <std::contiguous_iterator Iter>
      69              :                 void get(Iter first, Iter last, int source, unsigned int pos,
      70              :                          Request* request = nullptr);
      71              : 
      72              :                 template <typename T>
      73              :                 void get(T& value, int source, unsigned int pos, Request* request = nullptr);
      74              : 
      75              :                 template <typename T>
      76              :                 void get(T* value, int source, unsigned int pos, Request* request = nullptr);
      77              : 
      78              :                 /*
      79              :                  * Passive target communication:
      80              :                  */
      81              :                 void flush(int rank);
      82              : 
      83              :                 void flushall();
      84              : 
      85              :                 enum LockType : int {
      86              :                     Exclusive = MPI_LOCK_EXCLUSIVE,
      87              :                     Shared    = MPI_LOCK_SHARED
      88              :                 };
      89              : 
      90              :                 void lock(int locktype, int rank, int asrt = 0);
      91              : 
      92              :                 void lockall(int asrt = 0);
      93              : 
      94              :                 void unlock(int rank);
      95              : 
      96              :                 void unlockall();
      97              : 
      98              :             private:
      99              :                 MPI_Win win_m;
     100              :                 MPI_Aint count_m;
     101              :                 bool attached_m;
     102              :                 bool allocated_m;
     103              :             };
     104              :         }  // namespace rma
     105              :     }      // namespace mpi
     106              : }  // namespace ippl
     107              : 
     108              : #include "Communicate/Window.hpp"
     109              : 
     110              : #endif
        

Generated by: LCOV version 2.0-1