iterative-solver 0.0
 
Loading...
Searching...
No Matches
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>
5
6namespace molpro::linalg::array {
7class DistrArraySpan : public DistrArray {
8protected:
9 std::unique_ptr<Distribution> m_distribution;
10 bool m_allocated = false;
12
13public:
14 DistrArraySpan() = delete;
15 DistrArraySpan(size_t dimension, Span<value_type> buffer, MPI_Comm commun = molpro::mpi::comm_global());
16 DistrArraySpan(std::unique_ptr<Distribution> distribution, Span<value_type> buffer,
17 MPI_Comm commun = molpro::mpi::comm_global());
18 DistrArraySpan(const DistrArraySpan &source);
21 explicit DistrArraySpan(const DistrArray &source);
22 DistrArraySpan(DistrArraySpan &&source) noexcept;
24 DistrArraySpan &operator=(DistrArraySpan &&source) noexcept;
25
26 friend void swap(DistrArraySpan &a1, DistrArraySpan &a2) noexcept;
27 // void sync() const override;
29
30protected:
32 explicit LocalBufferSpan(DistrArraySpan &source);
33 explicit LocalBufferSpan(const DistrArraySpan &source);
34 };
35
36public:
37 [[nodiscard]] const Distribution &distribution() const override;
38 [[nodiscard]] std::unique_ptr<LocalBuffer> local_buffer() override;
39 [[nodiscard]] std::unique_ptr<const LocalBuffer> local_buffer() const override;
40 [[nodiscard]] value_type at(index_type ind) const override;
41 void set(index_type ind, value_type val) override;
42 void get(index_type lo, index_type hi, value_type *buf) const override;
43 [[nodiscard]] std::vector<value_type> get(index_type lo, index_type hi) const override;
44 void put(index_type lo, index_type hi, const value_type *data) override;
45 void acc(index_type lo, index_type hi, const value_type *data) override;
46 [[nodiscard]] std::vector<value_type> gather(const std::vector<index_type> &indices) const override;
47 void scatter(const std::vector<index_type> &indices, const std::vector<value_type> &data) override;
48 void scatter_acc(std::vector<index_type> &indices, const std::vector<value_type> &data) override;
49 [[nodiscard]] std::vector<value_type> vec() const override;
50};
51
52} // namespace molpro::linalg::array
53#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_DISTRARRAYSPAN_H
Definition DistrArraySpan.h:7
bool m_allocated
whether the window has been created
Definition DistrArraySpan.h:10
Span< value_type > m_span
Span over provided buffer.
Definition DistrArraySpan.h:11
void set(index_type ind, value_type val) override
Set one element to a scalar. Global operation.
Definition DistrArraySpan.cpp:158
std::vector< value_type > gather(const std::vector< index_type > &indices) const override
gets elements with discontinuous indices from array. Blocking
Definition DistrArraySpan.cpp:207
friend void swap(DistrArraySpan &a1, DistrArraySpan &a2) noexcept
Definition DistrArraySpan.cpp:93
const Distribution & distribution() const override
Access distribution of the array among processes.
Definition DistrArraySpan.cpp:138
std::unique_ptr< Distribution > m_distribution
describes distribution of array among processes
Definition DistrArraySpan.h:9
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:224
DistrArraySpan & operator=(const DistrArraySpan &source)
Definition DistrArraySpan.cpp:75
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:199
value_type at(index_type ind) const override
Definition DistrArraySpan.cpp:152
std::vector< value_type > vec() const override
Copies the whole buffer into a vector. Blocking.
Definition DistrArraySpan.cpp:248
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:160
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:241
std::unique_ptr< LocalBuffer > local_buffer() override
Access the buffer local to this process.
Definition DistrArraySpan.cpp:144
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:184
void allocate_buffer(Span< value_type > buffer)
Definition DistrArraySpan.cpp:102
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
Non-owning container taking a pointer to the data buffer and its size and exposing routines for itera...
Definition Span.h:31
Specifies distribution of a contiguous array into non-overlapping chunks.
Definition Distribution.h:16
Definition ArrayHandler.h:19