Ginkgo: ginkgo/core/distributed/neighborhood_communicator.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
neighborhood_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_NEIGHBORHOOD_COMMUNICATOR_HPP_
6#define GKO_PUBLIC_CORE_DISTRIBUTED_NEIGHBORHOOD_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
33 class NeighborhoodCommunicator final : public CollectiveCommunicator {
34public:
35 using CollectiveCommunicator::i_all_to_all_v;
36
37 NeighborhoodCommunicator(const NeighborhoodCommunicator& other) = default;
38
39 NeighborhoodCommunicator(NeighborhoodCommunicator&& other);
40
41 NeighborhoodCommunicator& operator=(const NeighborhoodCommunicator& other) =
42 default;
43
44 NeighborhoodCommunicator& operator=(NeighborhoodCommunicator&& other);
45
51 explicit NeighborhoodCommunicator(communicator base);
52
66 template <typename LocalIndexType, typename GlobalIndexType>
67 NeighborhoodCommunicator(
68 communicator base,
69 const distributed::index_map<LocalIndexType, GlobalIndexType>& imap);
70
71 std::unique_ptr<CollectiveCommunicator> create_with_same_type(
72 communicator base, index_map_ptr imap) const override;
73
80 [[nodiscard]] std::unique_ptr<CollectiveCommunicator> create_inverse()
81 const override;
82
83 [[nodiscard]] comm_index_type get_recv_size() const override;
84
85 [[nodiscard]] comm_index_type get_send_size() const override;
86
96 friend bool operator==(const NeighborhoodCommunicator& a,
97 const NeighborhoodCommunicator& b);
98
104 friend bool operator!=(const NeighborhoodCommunicator& a,
105 const NeighborhoodCommunicator& b);
106
107protected:
114 request i_all_to_all_v_impl(std::shared_ptr<const Executor> exec,
115 const void* send_buffer, MPI_Datatype send_type,
116 void* recv_buffer,
117 MPI_Datatype recv_type) const override;
118
119private:
120 communicator comm_;
121
122 std::vector<comm_index_type> send_sizes_;
123 std::vector<comm_index_type> send_offsets_;
124 std::vector<comm_index_type> recv_sizes_;
125 std::vector<comm_index_type> recv_offsets_;
126};
127
128
129} // namespace mpi
130} // namespace experimental
131} // namespace gko
132
133
134#endif
135#endif // GKO_PUBLIC_CORE_DISTRIBUTED_NEIGHBORHOOD_COMMUNICATOR_HPP_
gko::experimental::distributed::index_map
This class defines mappings between global and local indices.
Definition index_map.hpp:68
gko::experimental::mpi::CollectiveCommunicator::index_map_ptr
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
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:126
gko::experimental::mpi::NeighborhoodCommunicator::create_inverse
std::unique_ptr< CollectiveCommunicator > create_inverse() const override
Creates the inverse NeighborhoodCommunicator by switching sources and destinations.
gko::experimental::mpi::NeighborhoodCommunicator::operator!=
friend bool operator!=(const NeighborhoodCommunicator &a, const NeighborhoodCommunicator &b)
Compares two communicators for inequality.
gko::experimental::mpi::NeighborhoodCommunicator::operator==
friend bool operator==(const NeighborhoodCommunicator &a, const NeighborhoodCommunicator &b)
Compares two communicators for equality locally.
gko::experimental::mpi::NeighborhoodCommunicator::get_recv_size
comm_index_type get_recv_size() const override
Get the number of elements received by this process within this communication pattern.
gko::experimental::mpi::NeighborhoodCommunicator::create_with_same_type
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.
gko::experimental::mpi::NeighborhoodCommunicator::NeighborhoodCommunicator
NeighborhoodCommunicator(communicator base)
Default constructor with empty communication pattern.
gko::experimental::mpi::NeighborhoodCommunicator::get_send_size
comm_index_type get_send_size() const override
Get the number of elements sent by this process within this communication pattern.
gko::experimental::mpi::NeighborhoodCommunicator::NeighborhoodCommunicator
NeighborhoodCommunicator(communicator base, const distributed::index_map< LocalIndexType, GlobalIndexType > &imap)
Create a NeighborhoodCommunicator from an index map.
gko::experimental::mpi::communicator
A thin wrapper of MPI_Comm that supports most MPI calls.
Definition mpi.hpp:419
gko::experimental::mpi::request
The request class is a light, move-only wrapper around the MPI_Request handle.
Definition mpi.hpp:331
gko::experimental::mpi
The mpi namespace, contains wrapper for many MPI functions.
Definition mpi.hpp:36
gko::experimental::mpi::comm_index_type
int comm_index_type
Index type for enumerating processes in a distributed application.
Definition types.hpp:1124
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20