Ginkgo: ginkgo/core/distributed/vector_cache.hpp Source File

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
vector_cache.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_DISTRIBUTED_VECTOR_CACHE_HPP_
6#define GKO_PUBLIC_CORE_DISTRIBUTED_VECTOR_CACHE_HPP_
7
8
9#include <memory>
10
11#include <ginkgo/config.hpp>
12#include <ginkgo/core/base/executor.hpp>
13#include <ginkgo/core/base/mpi.hpp>
14#include <ginkgo/core/distributed/vector.hpp>
15
16
17#if GINKGO_BUILD_MPI
18
19
20namespace gko {
21namespace experimental {
22namespace distributed {
23namespace detail {
24
25
35template <typename ValueType>
36class VectorCache {
37public:
38 VectorCache() = default;
39 ~VectorCache() = default;
40 VectorCache(const VectorCache&) {}
41 VectorCache(VectorCache&&) noexcept {}
42 VectorCache& operator=(const VectorCache&) { return *this; }
43 VectorCache& operator=(VectorCache&&) noexcept { return *this; }
44 mutable std::unique_ptr<Vector<ValueType>> vec{};
45
46
61 void init_from(const Vector<ValueType>* template_vec) const;
62
75 void init(std::shared_ptr<const Executor> exec,
76 gko::experimental::mpi::communicator comm, dim<2> global_size,
77 dim<2> local_size) const;
78
84 Vector<ValueType>& operator*() const { return *vec; }
85
90 Vector<ValueType>* operator->() const { return vec.get(); }
91
96 Vector<ValueType>* get() const { return vec.get(); }
97};
98
99
100// helper to access private member for testing
101class GenericVectorCacheAccessor;
102
103
114class GenericVectorCache {
115public:
116 friend class GenericVectorCacheAccessor;
117
118 GenericVectorCache() = default;
119 ~GenericVectorCache() = default;
120 GenericVectorCache(const GenericVectorCache&);
121 GenericVectorCache(GenericVectorCache&&) noexcept;
122 GenericVectorCache& operator=(const GenericVectorCache&);
123 GenericVectorCache& operator=(GenericVectorCache&&) noexcept;
124
140 template <typename ValueType>
141 std::shared_ptr<Vector<ValueType>> get(
142 std::shared_ptr<const Executor> exec,
143 gko::experimental::mpi::communicator comm, dim<2> global_size,
144 dim<2> local_size) const;
145
146private:
147 mutable array<char> workspace;
148};
149
150
151} // namespace detail
152} // namespace distributed
153} // namespace experimental
154} // namespace gko
155
156
157#endif // GINKGO_BUILD_MPI
158#endif // GKO_PUBLIC_CORE_DISTRIBUTED_VECTOR_CACHE_HPP_
gko::experimental::distributed
The distributed namespace.
Definition polymorphic_object.hpp:19
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::layout_type::array
@ array
The matrix should be written as dense matrix in column-major order.
Definition mtx_io.hpp:97