Ginkgo Generated from branch based on main. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
dense_communicator.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_DISTRIBUTED_DENSE_COMMUNICATOR_HPP_
6#define GKO_PUBLIC_CORE_DISTRIBUTED_DENSE_COMMUNICATOR_HPP_
7
8
9#include <ginkgo/config.hpp>
10
11
12#if GINKGO_BUILD_MPI
13
14
15#include <ginkgo/core/base/mpi.hpp>
16#include <ginkgo/core/distributed/collective_communicator.hpp>
17#include <ginkgo/core/distributed/index_map.hpp>
18
19
20namespace gko {
21namespace experimental {
22namespace mpi {
23
24
30class DenseCommunicator final : public CollectiveCommunicator {
31public:
33
34 DenseCommunicator(const DenseCommunicator& other) = default;
35
36 DenseCommunicator(DenseCommunicator&& other);
37
38 DenseCommunicator& operator=(const DenseCommunicator& other) = default;
39
40 DenseCommunicator& operator=(DenseCommunicator&& other);
41
48
62 template <typename LocalIndexType, typename GlobalIndexType>
64 communicator base,
66
67 [[nodiscard]] std::unique_ptr<CollectiveCommunicator> create_with_same_type(
68 communicator base, index_map_ptr imap) const override;
69
76 [[nodiscard]] std::unique_ptr<CollectiveCommunicator> create_inverse()
77 const override;
78
79 [[nodiscard]] comm_index_type get_recv_size() const override;
80
81 [[nodiscard]] comm_index_type get_send_size() const override;
82
92 friend bool operator==(const DenseCommunicator& a,
93 const DenseCommunicator& b);
94
100 friend bool operator!=(const DenseCommunicator& a,
101 const DenseCommunicator& b);
102
103protected:
110 request i_all_to_all_v_impl(std::shared_ptr<const Executor> exec,
111 const void* send_buffer, MPI_Datatype send_type,
112 void* recv_buffer,
113 MPI_Datatype recv_type) const override;
114
115private:
116 communicator comm_;
117
118 std::vector<comm_index_type> send_sizes_;
119 std::vector<comm_index_type> send_offsets_;
120 std::vector<comm_index_type> recv_sizes_;
121 std::vector<comm_index_type> recv_offsets_;
122};
123
124
125} // namespace mpi
126} // namespace experimental
127} // namespace gko
128
129
130#endif
131#endif // GKO_PUBLIC_CORE_DISTRIBUTED_DENSE_COMMUNICATOR_HPP_
This class defines mappings between global and local indices.
Definition index_map.hpp:68
std::variant< const distributed::index_map< int32, int32 > *, const distributed::index_map< int32, int64 > *, const distributed::index_map< int64, int64 > * > index_map_ptr
All allowed index_map types (as const *)
Definition collective_communicator.hpp:36
request i_all_to_all_v(std::shared_ptr< const Executor > exec, const SendType *send_buffer, RecvType *recv_buffer) const
Non-blocking all-to-all communication.
Definition collective_communicator.hpp:126
std::unique_ptr< CollectiveCommunicator > create_inverse() const override
Creates the inverse DenseCommunicator by switching sources and destinations.
friend bool operator!=(const DenseCommunicator &a, const DenseCommunicator &b)
Compares two communicators for inequality.
DenseCommunicator(communicator base)
Default constructor with empty communication pattern.
comm_index_type get_recv_size() const override
Get the number of elements received by this process within this communication pattern.
comm_index_type get_send_size() const override
Get the number of elements sent by this process within this communication pattern.
friend bool operator==(const DenseCommunicator &a, const DenseCommunicator &b)
Compares two communicators for equality.
DenseCommunicator(communicator base, const distributed::index_map< LocalIndexType, GlobalIndexType > &imap)
Create a DenseCommunicator from an index map.
std::unique_ptr< CollectiveCommunicator > create_with_same_type(communicator base, index_map_ptr imap) const override
Creates a new CollectiveCommunicator with the same dynamic type.
A thin wrapper of MPI_Comm that supports most MPI calls.
Definition mpi.hpp:419
The request class is a light, move-only wrapper around the MPI_Request handle.
Definition mpi.hpp:331
The mpi namespace, contains wrapper for many MPI functions.
Definition mpi.hpp:36
int comm_index_type
Index type for enumerating processes in a distributed application.
Definition types.hpp:1060
The Ginkgo namespace.
Definition abstract_factory.hpp:20