Ginkgo  Generated from pipelines/1706354773 branch based on develop. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
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 
20 namespace gko {
21 namespace experimental {
22 namespace mpi {
23 
24 
31 public:
33 
34  DenseCommunicator(const DenseCommunicator& other) = default;
35 
37 
38  DenseCommunicator& operator=(const DenseCommunicator& other) = default;
39 
40  DenseCommunicator& operator=(DenseCommunicator&& other);
41 
47  explicit DenseCommunicator(communicator base);
48 
62  template <typename LocalIndexType, typename GlobalIndexType>
64  communicator base,
66 
67  [[nodiscard]] std::unique_ptr<CollectiveCommunicator> create_with_same_type(
68  communicator base,
69  const distributed::index_map_variant& imap) const override;
70 
77  [[nodiscard]] std::unique_ptr<CollectiveCommunicator> create_inverse()
78  const override;
79 
80  [[nodiscard]] comm_index_type get_recv_size() const override;
81 
82  [[nodiscard]] comm_index_type get_send_size() const override;
83 
93  friend bool operator==(const DenseCommunicator& a,
94  const DenseCommunicator& b);
95 
101  friend bool operator!=(const DenseCommunicator& a,
102  const DenseCommunicator& b);
103 
104 protected:
111  request i_all_to_all_v_impl(std::shared_ptr<const Executor> exec,
112  const void* send_buffer, MPI_Datatype send_type,
113  void* recv_buffer,
114  MPI_Datatype recv_type) const override;
115 
116 private:
117  communicator comm_;
118 
119  std::vector<comm_index_type> send_sizes_;
120  std::vector<comm_index_type> send_offsets_;
121  std::vector<comm_index_type> recv_sizes_;
122  std::vector<comm_index_type> recv_offsets_;
123 };
124 
125 
126 } // namespace mpi
127 } // namespace experimental
128 } // namespace gko
129 
130 
131 #endif
132 #endif // GKO_PUBLIC_CORE_DISTRIBUTED_DENSE_COMMUNICATOR_HPP_
gko::experimental::mpi::DenseCommunicator
A CollectiveCommunicator that uses a dense communication.
Definition: dense_communicator.hpp:30
gko::experimental::mpi::DenseCommunicator::get_send_size
comm_index_type get_send_size() const override
Get the total number of sent elements this communication patterns expects.
gko::experimental::mpi::DenseCommunicator::create_inverse
std::unique_ptr< CollectiveCommunicator > create_inverse() const override
Creates the inverse DenseCommunicator by switching sources and destinations.
gko::experimental::mpi::CollectiveCommunicator::i_all_to_all_v
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:118
gko::experimental::mpi::request
The request class is a light, move-only wrapper around the MPI_Request handle.
Definition: mpi.hpp:327
gko::experimental::mpi::CollectiveCommunicator
Interface for a collective communicator.
Definition: collective_communicator.hpp:30
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::experimental::mpi::DenseCommunicator::operator==
friend bool operator==(const DenseCommunicator &a, const DenseCommunicator &b)
Compares two communicators for equality.
gko::experimental::mpi::communicator
A thin wrapper of MPI_Comm that supports most MPI calls.
Definition: mpi.hpp:416
gko::experimental::mpi::DenseCommunicator::operator!=
friend bool operator!=(const DenseCommunicator &a, const DenseCommunicator &b)
Compares two communicators for inequality.
gko::experimental::mpi::DenseCommunicator::get_recv_size
comm_index_type get_recv_size() const override
Get the total number of received elements this communication patterns expects.
gko::experimental::mpi::comm_index_type
int comm_index_type
Index type for enumerating processes in a distributed application.
Definition: types.hpp:967
gko::experimental::mpi::DenseCommunicator::create_with_same_type
std::unique_ptr< CollectiveCommunicator > create_with_same_type(communicator base, const distributed::index_map_variant &imap) const override
Creates a new CollectiveCommunicator with the same dynamic type.
gko::experimental::distributed::index_map
This class defines mappings between global and local indices.
Definition: index_map.hpp:68