iterative-solver 0.0
 
Loading...
Searching...
No Matches
DistrArrayGA.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYGA_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYGA_H
3#include <map>
4
5#include "molpro/linalg/array/DistrArray.h"
6
7namespace molpro::linalg::array {
8
16class DistrArrayGA : public DistrArray {
17protected:
18 int m_comm_rank = 0;
19 int m_comm_size = 0;
20 int m_ga_handle = 0;
21 int m_ga_pgroup = 0;
22 int m_ga_chunk = 1;
23 bool m_ga_allocated = false;
27 static std::map<MPI_Comm, int> _ga_pgroups;
28 std::unique_ptr<Distribution> m_distribution;
29
30public:
31 DistrArrayGA() = delete;
32 DistrArrayGA(size_t dimension, MPI_Comm commun);
34 DistrArrayGA(const DistrArrayGA &source);
38 DistrArrayGA(DistrArrayGA &&source) noexcept;
40 DistrArrayGA &operator=(DistrArrayGA &&source) noexcept;
41 ~DistrArrayGA() override;
42
44 friend void swap(DistrArrayGA &a1, DistrArrayGA &a2) noexcept;
45 void sync() const override;
46
47protected:
49 explicit LocalBufferGA(DistrArrayGA &source);
50 };
51
52public:
53 [[nodiscard]] const Distribution &distribution() const override;
54 [[nodiscard]] std::unique_ptr<LocalBuffer> local_buffer() override;
55 [[nodiscard]] std::unique_ptr<const LocalBuffer> local_buffer() const override;
56 [[nodiscard]] value_type at(index_type ind) const override;
57 void set(index_type ind, value_type val) override;
58 void get(index_type lo, index_type hi, value_type *buf) const override;
59 [[nodiscard]] std::vector<value_type> get(index_type lo, index_type hi) const override;
60 void put(index_type lo, index_type hi, const value_type *data) override;
61 void acc(index_type lo, index_type hi, const value_type *data) override;
62 [[nodiscard]] std::vector<value_type> gather(const std::vector<index_type> &indices) const override;
63 void scatter(const std::vector<index_type> &indices, const std::vector<value_type> &data) override;
64 void scatter_acc(std::vector<index_type> &indices, const std::vector<value_type> &data) override;
65 [[nodiscard]] std::vector<value_type> vec() const override;
66 void error(const std::string &message) const override;
67
68protected:
71
74};
75
76} // namespace molpro::linalg::array
77
78#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYGA_H
Distributed array which uses Global Arrays for managing the array buffer and RMA calls.
Definition DistrArrayGA.h:16
std::vector< value_type > vec() const override
Copies the whole buffer into a vector. Blocking.
void error(const std::string &message) const override
stops application with an error
static std::map< MPI_Comm, int > _ga_pgroups
Definition DistrArrayGA.h:27
int m_ga_chunk
GA chunck size.
Definition DistrArrayGA.h:22
Distribution make_distribution() const
void scatter_acc(std::vector< index_type > &indices, const std::vector< value_type > &data) override
array[indices[i]] += vals[i] Accumulates vals of elements into discontinuous indices of array....
bool m_ga_allocated
Definition DistrArrayGA.h:23
void set(index_type ind, value_type val) override
Set one element to a scalar. Global operation.
value_type at(index_type ind) const override
friend void swap(DistrArrayGA &a1, DistrArrayGA &a2) noexcept
swap content of two arrays. Not collective.
std::unique_ptr< LocalBuffer > local_buffer() override
Access the buffer local to this process.
DistrArrayGA(size_t dimension, MPI_Comm commun)
DistrArrayGA & operator=(const DistrArrayGA &source)
Copy source, allocating buffer if necessary.
int m_ga_pgroup
Global Array processor group handle.
Definition DistrArrayGA.h:21
void check_ga_ind_overlow(index_type ind) const
Checks if index will overflow when converted to int. Calls error() if it does.
std::unique_ptr< Distribution > m_distribution
Definition DistrArrayGA.h:28
const Distribution & distribution() const override
Access distribution of the array among processes.
int m_comm_size
size of process group
Definition DistrArrayGA.h:19
void get(index_type lo, index_type hi, value_type *buf) const override
Gets buffer[lo:hi) from global array (hi is past-the-end). Blocking.
DistrArrayGA(DistrArrayGA &&source) noexcept
Take ownership of source leaving it in undefined state. Not collective, no allocation/deallocation.
std::vector< value_type > get(index_type lo, index_type hi) const override
void put(index_type lo, index_type hi, const value_type *data) override
array[lo:hi) = data[:] (hi is past-the-end). Blocking
int m_comm_rank
rank in process group
Definition DistrArrayGA.h:18
void acc(index_type lo, index_type hi, const value_type *data) override
array[lo:hi) += scaling_constant * data[:] (hi is past-the-end). Blocking
DistrArrayGA & operator=(DistrArrayGA &&source) noexcept
Take ownership of source leaving it in undefined state. Not collective, no allocation/deallocation.
int m_ga_handle
Global Array handle, needed by GA libary.
Definition DistrArrayGA.h:20
void scatter(const std::vector< index_type > &indices, const std::vector< value_type > &data) override
array[indices[i]] = data[i] Puts vals of elements with discontinuous indices of array....
void sync() const override
Synchronizes all process in this group and ensures any outstanding operations on the array have compl...
std::unique_ptr< const LocalBuffer > local_buffer() const override
DistrArrayGA(const DistrArrayGA &source)
Make a copy of source, allocating buffer if necessary.
std::vector< value_type > gather(const std::vector< index_type > &indices) const override
gets elements with discontinuous indices from array. Blocking
Provides access to the local portion of the array.
Definition DistrArray.h:175
Array distributed across many processes supporting remote-memory-access, access to process local buff...
Definition DistrArray.h:137
double value_type
Definition DistrArray.h:140
size_t index_type
Definition DistrArray.h:141
Specifies distribution of a contiguous array into non-overlapping chunks.
Definition Distribution.h:16
Definition ArrayHandler.h:19