iterative-solver 0.0
DistrArraySpan.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYSPAN_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYSPAN_H
3#include <molpro/linalg/array/DistrArray.h>
4#include <molpro/mpi.h>
5using molpro::mpi::comm_global;
6
7namespace molpro::linalg::array {
8class DistrArraySpan : public DistrArray {
9protected:
10 std::unique_ptr<Distribution> m_distribution;
11 bool m_allocated = false;
13
14public:
15 DistrArraySpan() = delete;
16 DistrArraySpan(size_t dimension, Span<value_type> buffer, MPI_Comm commun = comm_global());
17 DistrArraySpan(std::unique_ptr<Distribution> distribution, Span<value_type> buffer, MPI_Comm commun = comm_global());
18 DistrArraySpan(const DistrArraySpan &source);
19 explicit DistrArraySpan(const DistrArray &source);
20 DistrArraySpan(DistrArraySpan &&source) noexcept;
22 DistrArraySpan &operator=(DistrArraySpan &&source) noexcept;
23
24 friend void swap(DistrArraySpan &a1, DistrArraySpan &a2) noexcept;
25 // void sync() const override;
27
28protected:
30 explicit LocalBufferSpan(DistrArraySpan &source);
31 explicit LocalBufferSpan(const DistrArraySpan &source);
32 };
33
34public:
35 [[nodiscard]] const Distribution &distribution() const override;
36 [[nodiscard]] std::unique_ptr<LocalBuffer> local_buffer() override;
37 [[nodiscard]] std::unique_ptr<const LocalBuffer> local_buffer() const override;
38 [[nodiscard]] value_type at(index_type ind) const override;
39 void set(index_type ind, value_type val) override;
40 void get(index_type lo, index_type hi, value_type *buf) const override;
41 [[nodiscard]] std::vector<value_type> get(index_type lo, index_type hi) const override;
42 void put(index_type lo, index_type hi, const value_type *data) override;
43 void acc(index_type lo, index_type hi, const value_type *data) override;
44 [[nodiscard]] std::vector<value_type> gather(const std::vector<index_type> &indices) const override;
45 void scatter(const std::vector<index_type> &indices, const std::vector<value_type> &data) override;
46 void scatter_acc(std::vector<index_type> &indices, const std::vector<value_type> &data) override;
47 [[nodiscard]] std::vector<value_type> vec() const override;
48};
49
50} // namespace molpro::linalg::array
51#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYSPAN_H
Definition: DistrArraySpan.h:8
bool m_allocated
whether the window has been created
Definition: DistrArraySpan.h:11
Span< value_type > m_span
Span over provided buffer.
Definition: DistrArraySpan.h:12
void set(index_type ind, value_type val) override
Set one element to a scalar. Global operation.
Definition: DistrArraySpan.cpp:145
std::vector< value_type > gather(const std::vector< index_type > &indices) const override
gets elements with discontinuous indices from array. Blocking
Definition: DistrArraySpan.cpp:194
friend void swap(DistrArraySpan &a1, DistrArraySpan &a2) noexcept
Definition: DistrArraySpan.cpp:80
const Distribution & distribution() const override
Access distribution of the array among processes.
Definition: DistrArraySpan.cpp:125
std::unique_ptr< Distribution > m_distribution
describes distribution of array among processes
Definition: DistrArraySpan.h:10
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....
Definition: DistrArraySpan.cpp:209
DistrArraySpan & operator=(const DistrArraySpan &source)
Definition: DistrArraySpan.cpp:62
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
Definition: DistrArraySpan.cpp:186
value_type at(index_type ind) const override
Definition: DistrArraySpan.cpp:139
std::vector< value_type > vec() const override
Copies the whole buffer into a vector. Blocking.
Definition: DistrArraySpan.cpp:231
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.
Definition: DistrArraySpan.cpp:147
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....
Definition: DistrArraySpan.cpp:224
std::unique_ptr< LocalBuffer > local_buffer() override
Access the buffer local to this process.
Definition: DistrArraySpan.cpp:131
void put(index_type lo, index_type hi, const value_type *data) override
array[lo:hi) = data[:] (hi is past-the-end). Blocking
Definition: DistrArraySpan.cpp:171
void allocate_buffer(Span< value_type > buffer)
Definition: DistrArraySpan.cpp:89
Provides access to the local portion of the array.
Definition: DistrArray.h:123
Array distributed across many processes supporting remote-memory-access, access to process local buff...
Definition: DistrArray.h:90
double value_type
Definition: DistrArray.h:93
size_t index_type
Definition: DistrArray.h:94
Non-owning container taking a pointer to the data buffer and its size and exposing routines for itera...
Definition: Span.h:28
Specifies distribution of a contiguous array into non-overlapping chunks.
Definition: Distribution.h:16
Definition: ArrayHandler.h:22
LocalBufferSpan(DistrArraySpan &source)
Definition: DistrArraySpan.cpp:101