33#ifndef GKO_PUBLIC_CORE_DISTRIBUTED_MATRIX_HPP_
34#define GKO_PUBLIC_CORE_DISTRIBUTED_MATRIX_HPP_
37#include <ginkgo/config.hpp>
43#include <ginkgo/core/base/dense_cache.hpp>
44#include <ginkgo/core/base/mpi.hpp>
45#include <ginkgo/core/distributed/base.hpp>
46#include <ginkgo/core/distributed/lin_op.hpp>
53template <
typename ValueType,
typename IndexType>
67template <
typename Builder,
typename ValueType,
typename IndexType,
69struct is_matrix_type_builder : std::false_type {};
72template <
typename Builder,
typename ValueType,
typename IndexType>
73struct is_matrix_type_builder<
76 decltype(std::declval<Builder>().template create<ValueType, IndexType>(
77 std::declval<std::shared_ptr<const Executor>>()))>>
81template <
template <
typename,
typename>
class MatrixType,
83struct MatrixTypeBuilderFromValueAndIndex {
84 template <
typename ValueType,
typename IndexType, std::size_t...
I>
85 auto create_impl(std::shared_ptr<const Executor> exec,
86 std::index_sequence<I...>)
88 return MatrixType<ValueType, IndexType>::create(
89 exec, std::get<I>(create_args)...);
93 template <
typename ValueType,
typename IndexType>
94 auto create(std::shared_ptr<const Executor> exec)
97 static constexpr auto size =
sizeof...(CreateArgs);
99 std::move(exec), std::make_index_sequence<size>{});
140template <
template <
typename,
typename>
class MatrixType,
typename...
Args>
143 return detail::MatrixTypeBuilderFromValueAndIndex<
MatrixType,
Args...>{
144 std::forward_as_tuple(create_args...)};
148namespace experimental {
149namespace distributed {
152template <
typename LocalIndexType,
typename GlobalIndexType>
154template <
typename ValueType>
266 Matrix<ValueType, LocalIndexType, GlobalIndexType>>,
268 Matrix<ValueType, LocalIndexType, GlobalIndexType>>,
270 Matrix<next_precision<ValueType>, LocalIndexType, GlobalIndexType>>,
278 using value_type = ValueType;
294 global_index_type>*
result)
const override;
297 global_index_type>*
result)
override;
384 return non_local_mtx_;
429 explicit Matrix(std::shared_ptr<const Executor> exec,
451 typename = std::enable_if_t<detail::is_matrix_type_builder<
453 explicit Matrix(std::shared_ptr<const Executor> exec,
487 typename = std::enable_if_t<
492 explicit Matrix(std::shared_ptr<const Executor> exec,
516 explicit Matrix(std::shared_ptr<const Executor> exec,
534 explicit Matrix(std::shared_ptr<const Executor> exec,
549 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
552 LinOp* x)
const override;
555 std::vector<comm_index_type> send_offsets_;
556 std::vector<comm_index_type> send_sizes_;
557 std::vector<comm_index_type> recv_offsets_;
558 std::vector<comm_index_type> recv_sizes_;
561 gko::detail::DenseCache<value_type> one_scalar_;
562 gko::detail::DenseCache<value_type> host_send_buffer_;
563 gko::detail::DenseCache<value_type> host_recv_buffer_;
564 gko::detail::DenseCache<value_type> send_buffer_;
565 gko::detail::DenseCache<value_type> recv_buffer_;
566 std::shared_ptr<LinOp> local_mtx_;
567 std::shared_ptr<LinOp> non_local_mtx_;
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition polymorphic_object.hpp:499
This mixin implements a static create() method on ConcreteType that dynamically allocates the memory,...
Definition polymorphic_object.hpp:776
Definition lin_op.hpp:146
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:187
This type is a device-side equivalent to matrix_data.
Definition device_matrix_data.hpp:63
This mixin does the same as EnableLinOp, but for concrete types that are derived from distributed::Di...
Definition lin_op.hpp:73
This mixin does the same as EnablePolymorphicObject, but for concrete types that are derived from dis...
Definition polymorphic_object.hpp:82
A base class for distributed objects.
Definition base.hpp:60
The Matrix class defines a (MPI-)distributed matrix.
Definition matrix.hpp:271
std::shared_ptr< const LinOp > get_non_local_matrix() const
Get read access to the stored non-local matrix.
Definition matrix.hpp:382
void read_distributed(const matrix_data< value_type, global_index_type > &data, ptr_param< const Partition< local_index_type, global_index_type > > partition)
Reads a square matrix from the matrix_data structure and a global partition.
Matrix(Matrix &&other) noexcept
Move constructs a Matrix.
void read_distributed(const matrix_data< value_type, global_index_type > &data, ptr_param< const Partition< local_index_type, global_index_type > > row_partition, ptr_param< const Partition< local_index_type, global_index_type > > col_partition)
Reads a matrix from the matrix_data structure, a global row partition, and a global column partition.
std::shared_ptr< const LinOp > get_local_matrix() const
Get read access to the stored local matrix.
Definition matrix.hpp:375
void read_distributed(const device_matrix_data< value_type, global_index_type > &data, ptr_param< const Partition< local_index_type, global_index_type > > partition)
Reads a square matrix from the device_matrix_data structure and a global partition.
void read_distributed(const device_matrix_data< value_type, global_index_type > &data, ptr_param< const Partition< local_index_type, global_index_type > > row_partition, ptr_param< const Partition< local_index_type, global_index_type > > col_partition)
Reads a matrix from the device_matrix_data structure, a global row partition, and a global column par...
Matrix(const Matrix &other)
Copy constructs a Matrix.
Matrix & operator=(Matrix &&other)
Move assigns a Matrix.
Matrix & operator=(const Matrix &other)
Copy assigns a Matrix.
Represents a partition of a range of indices [0, size) into a disjoint set of parts.
Definition partition.hpp:112
Vector is a format which explicitly stores (multiple) distributed column vectors in a dense storage f...
Definition vector.hpp:92
A thin wrapper of MPI_Comm that supports most MPI calls.
Definition mpi.hpp:437
The request class is a light, move-only wrapper around the MPI_Request handle.
Definition mpi.hpp:348
This class is used for function parameters in the place of raw pointers.
Definition utils_helper.hpp:71
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:137
typename detail::next_precision_impl< T >::type next_precision
Obtains the next type in the singly-linked precision list.
Definition math.hpp:490
auto with_matrix_type(Args &&... create_args)
This function returns a type that delays a call to MatrixType::create.
Definition matrix.hpp:141
double default_precision
Precision used if no precision is explicitly specified.
Definition types.hpp:205
std::int64_t int64
64-bit signed integral type.
Definition types.hpp:143
This structure is used as an intermediate data type to store a sparse matrix.
Definition matrix_data.hpp:155