5#ifndef GKO_PUBLIC_CORE_DISTRIBUTED_PARTITION_HPP_
6#define GKO_PUBLIC_CORE_DISTRIBUTED_PARTITION_HPP_
9#include <ginkgo/core/base/array.hpp>
10#include <ginkgo/core/base/polymorphic_object.hpp>
11#include <ginkgo/core/base/segmented_array.hpp>
12#include <ginkgo/core/base/types.hpp>
16namespace experimental {
79template <
typename LocalIndexType =
int32,
typename GlobalIndexType =
int64>
81 Partition<LocalIndexType, GlobalIndexType>>,
83 Partition<LocalIndexType, GlobalIndexType>> {
85 static_assert(
sizeof(GlobalIndexType) >=
sizeof(LocalIndexType),
86 "GlobalIndexType must be at least as large as "
93 using local_index_type = LocalIndexType;
94 using global_index_type = GlobalIndexType;
111 return offsets_.get_size() - 1;
128 return num_empty_parts_;
140 return offsets_.get_const_data();
152 return part_ids_.get_const_data();
170 return starting_indices_.get_const_data();
181 return part_sizes_.get_const_data();
201 return ranges_by_part_;
230 std::shared_ptr<const Executor> exec,
247 std::shared_ptr<const Executor> exec,
264 global_index_type global_size);
267 Partition(std::shared_ptr<const Executor> exec,
270 static std::unique_ptr<Partition> create(
279 void finalize_construction();
283 global_index_type size_;
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition polymorphic_object.hpp:743
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:668
An array is a container which encapsulates fixed-sized arrays, stored on the Executor tied to the arr...
Definition array.hpp:166
comm_index_type get_num_empty_parts() const noexcept
Returns the number of empty parts within this partition.
Definition partition.hpp:126
size_type get_num_ranges() const noexcept
Returns the number of ranges stored by this partition.
Definition partition.hpp:109
const local_index_type * get_part_sizes() const noexcept
Returns the part size array.
Definition partition.hpp:179
const local_index_type * get_range_starting_indices() const noexcept
Returns the part-local starting index for each range in this partition.
Definition partition.hpp:168
const segmented_array< size_type > & get_ranges_by_part() const
Returns the range IDs segmented by their part ID.
Definition partition.hpp:199
static std::unique_ptr< Partition > build_from_global_size_uniform(std::shared_ptr< const Executor > exec, comm_index_type num_parts, global_index_type global_size)
Builds a partition by evenly distributing the global range.
bool has_connected_parts() const
Checks if each part has no more than one contiguous range.
const comm_index_type * get_part_ids() const noexcept
Returns the part IDs of the ranges in this partition.
Definition partition.hpp:150
local_index_type get_part_size(comm_index_type part) const
Returns the size of a part given by its part ID.
size_type get_size() const
Returns the total number of elements represented by this partition.
Definition partition.hpp:101
comm_index_type get_num_parts() const noexcept
Returns the number of parts represented in this partition.
Definition partition.hpp:119
static std::unique_ptr< Partition > build_from_contiguous(std::shared_ptr< const Executor > exec, const array< global_index_type > &ranges, const array< comm_index_type > &part_ids={})
Builds a partition consisting of contiguous ranges, one for each part.
static std::unique_ptr< Partition > build_from_mapping(std::shared_ptr< const Executor > exec, const array< comm_index_type > &mapping, comm_index_type num_parts)
Builds a partition from a given mapping global_index -> part_id.
bool has_ordered_parts() const
Checks if the ranges are ordered by their part index.
const global_index_type * get_range_bounds() const noexcept
Returns the ranges boundary array stored by this partition.
Definition partition.hpp:138
The distributed namespace.
Definition polymorphic_object.hpp:19
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
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90
A minimal interface for a segmented array.
Definition segmented_array.hpp:27