Ginkgo  Generated from pipelines/2897303314 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
index_map.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_DISTRIBUTED_INDEX_MAP_HPP_
6 #define GKO_PUBLIC_CORE_DISTRIBUTED_INDEX_MAP_HPP_
7 
8 
9 #include <ginkgo/core/base/segmented_array.hpp>
10 #include <ginkgo/core/distributed/partition.hpp>
11 
12 
13 namespace gko {
14 namespace experimental {
15 namespace distributed {
16 
17 
23 enum class index_space {
24  local,
25  non_local,
26  combined
27 };
28 
29 
69 template <typename LocalIndexType, typename GlobalIndexType = int64>
70 class index_map {
71 public:
73 
85  index_space index_space_v) const;
86 
87 
99  const array<LocalIndexType>& local_idxs,
100  index_space index_space_v) const;
101 
105  size_type get_global_size() const;
106 
110  size_type get_local_size() const;
111 
116 
130  index_map(std::shared_ptr<const Executor> exec,
131  std::shared_ptr<const partition_type> partition,
132  comm_index_type rank,
133  const array<GlobalIndexType>& recv_connections);
134 
138  index_map(std::shared_ptr<const Executor> exec);
139 
146 
163 
171 
175  std::shared_ptr<const partition_type> get_partition() const;
176 
180  std::shared_ptr<const Executor> get_executor() const;
181 
182  index_map(const index_map& other);
183 
184  index_map(index_map&& other) noexcept;
185 
186  index_map& operator=(const index_map& other);
187 
188  index_map& operator=(index_map&& other);
189 
190 private:
191  std::shared_ptr<const Executor> exec_;
192  std::shared_ptr<const partition_type> partition_;
193  comm_index_type rank_;
194 
195  array<comm_index_type> remote_target_ids_;
196  segmented_array<LocalIndexType> remote_local_idxs_;
197  segmented_array<GlobalIndexType> remote_global_idxs_;
198 };
199 
200 
201 } // namespace distributed
202 } // namespace experimental
203 } // namespace gko
204 
205 
206 #endif // GKO_PUBLIC_CORE_DISTRIBUTED_INDEX_MAP_HPP_
gko::experimental::distributed::index_space::combined
both local and non_local indices
gko::experimental::distributed::index_map::get_executor
std::shared_ptr< const Executor > get_executor() const
get the associated executor.
gko::experimental::distributed::index_space::local
indices that are locally owned
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:101
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
gko::experimental::distributed::index_map::get_remote_local_idxs
const segmented_array< LocalIndexType > & get_remote_local_idxs() const
get the index set , but mapped to their respective local index space.
gko::array< LocalIndexType >
gko::experimental::distributed::index_map::get_remote_global_idxs
const segmented_array< GlobalIndexType > & get_remote_global_idxs() const
get the index set for this rank.
gko::segmented_array< GlobalIndexType >
gko::experimental::distributed::index_map::get_global_size
size_type get_global_size() const
get size of the global index space
gko::experimental::distributed::index_map::get_non_local_size
size_type get_non_local_size() const
get size of index_space::non_local
gko::experimental::distributed::Partition
Represents a partition of a range of indices [0, size) into a disjoint set of parts.
Definition: assembly.hpp:26
gko::experimental::distributed::index_space::non_local
indices that are owned by other processes
gko::experimental::distributed::index_map::get_remote_target_ids
const array< comm_index_type > & get_remote_target_ids() const
get the rank ids which contain indices accessed by this rank.
gko::experimental::distributed::index_map::map_to_local
array< LocalIndexType > map_to_local(const array< GlobalIndexType > &global_ids, index_space index_space_v) const
Maps global indices to local indices.
gko::experimental::distributed::index_map::index_map
index_map(std::shared_ptr< const Executor > exec, std::shared_ptr< const partition_type > partition, comm_index_type rank, const array< GlobalIndexType > &recv_connections)
Creates a new index map.
gko::experimental::distributed::index_map::get_partition
std::shared_ptr< const partition_type > get_partition() const
get the partition associated with this index map.
gko::experimental::distributed::index_map
This class defines mappings between global and local indices.
Definition: index_map.hpp:70
gko::experimental::distributed::index_space
index_space
Index space classification for the locally stored indices.
Definition: index_map.hpp:23
gko::experimental::distributed::index_map::get_local_size
size_type get_local_size() const
get size of index_space::local
gko::experimental::distributed::index_map::map_to_global
array< GlobalIndexType > map_to_global(const array< LocalIndexType > &local_idxs, index_space index_space_v) const
Maps local indices to global indices.