Represents a partition of a range of indices [0, size) into a disjoint set of parts.
More...
|
size_type | get_size () const |
| Returns the total number of elements represented by this partition.
|
size_type | get_num_ranges () const noexcept |
| Returns the number of ranges stored by this partition.
|
comm_index_type | get_num_parts () const noexcept |
| Returns the number of parts represented in this partition.
|
comm_index_type | get_num_empty_parts () const noexcept |
| Returns the number of empty parts within this partition.
|
const global_index_type * | get_range_bounds () const noexcept |
| Returns the ranges boundary array stored by this partition.
|
const comm_index_type * | get_part_ids () const noexcept |
| Returns the part IDs of the ranges in this partition.
|
const local_index_type * | get_range_starting_indices () const noexcept |
| Returns the part-local starting index for each range in this partition.
|
const local_index_type * | get_part_sizes () const noexcept |
| Returns the part size array.
|
local_index_type | get_part_size (comm_index_type part) const |
| Returns the size of a part given by its part ID.
|
const segmented_array< size_type > & | get_ranges_by_part () const |
| Returns the range IDs segmented by their part ID.
|
bool | has_connected_parts () const |
| Checks if each part has no more than one contiguous range.
|
bool | has_ordered_parts () const |
| Checks if the ranges are ordered by their part index.
|
std::unique_ptr< Partition< int32, int64 > > | create_default (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< Partition< int32, int64 > > | clone (std::shared_ptr< const Executor > exec) const |
Partition< int32, int64 > * | copy_from (const PolymorphicObject *other) |
Partition< int32, int64 > * | move_from (ptr_param< PolymorphicObject > other) |
Partition< int32, int64 > * | clear () |
PolymorphicObject & | operator= (const PolymorphicObject &) |
std::unique_ptr< PolymorphicObject > | create_default (std::shared_ptr< const Executor > exec) const |
| Creates a new "default" object of the same dynamic type as this object.
|
std::unique_ptr< PolymorphicObject > | create_default () const |
| Creates a new "default" object of the same dynamic type as this object.
|
std::unique_ptr< PolymorphicObject > | clone (std::shared_ptr< const Executor > exec) const |
| Creates a clone of the object.
|
std::unique_ptr< PolymorphicObject > | clone () const |
| Creates a clone of the object.
|
PolymorphicObject * | copy_from (const PolymorphicObject *other) |
| Copies another object into this object.
|
template<typename Derived, typename Deleter> |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * | copy_from (std::unique_ptr< Derived, Deleter > &&other) |
| Moves another object into this object.
|
template<typename Derived, typename Deleter> |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * | copy_from (const std::unique_ptr< Derived, Deleter > &other) |
| Copies another object into this object.
|
PolymorphicObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
| Copies another object into this object.
|
PolymorphicObject * | move_from (ptr_param< PolymorphicObject > other) |
| Moves another object into this object.
|
PolymorphicObject * | clear () |
| Transforms the object into its default state.
|
std::shared_ptr< const Executor > | get_executor () const noexcept |
| Returns the Executor of the object.
|
void | add_logger (std::shared_ptr< const Logger > logger) override |
| Adds a new logger to the list of subscribed loggers.
|
void | remove_logger (const Logger *logger) override |
| Removes a logger from the list of subscribed loggers.
|
const std::vector< std::shared_ptr< const Logger > > & | get_loggers () const override |
| Returns the vector containing all loggers registered at this object.
|
void | clear_loggers () override |
| Remove all loggers registered at this object.
|
void | remove_logger (ptr_param< const Logger > logger) |
void | convert_to (result_type *result) const override |
void | move_to (result_type *result) override |
template<typename LocalIndexType = int32, typename GlobalIndexType = int64>
class gko::experimental::distributed::Partition< LocalIndexType, GlobalIndexType >
Represents a partition of a range of indices [0, size) into a disjoint set of parts.
The partition is stored as a set of consecutive ranges [begin, end) with an associated part ID and local index (number of indices in this part before begin). Global indices are stored as 64 bit signed integers (int64), part-local indices use LocalIndexType, Part IDs use 32 bit signed integers (int).
For example, consider the interval [0, 13) that is partitioned into the following ranges:
[0,3), [3, 6), [6, 8), [8, 10), [10, 13).
These ranges are distributed on three part with:
p_0 = [0, 3) + [6, 8) + [10, 13),
p_1 = [3, 6),
p_2 = [8, 10).
The part ids can be queried from the get_part_ids array, and the ranges are represented as offsets, accessed by get_range_bounds, leading to the offset array:
so that individual ranges are given by [r[i], r[i + 1]). Since each part may be associated with multiple ranges, it is possible to get the starting index for each range that is local to the owning part, see get_range_starting_indices. These indices can be used to easily iterate over part local data. For example, the above partition has the following starting indices
starting_index[0] = 0,
starting_index[1] = 0,
starting_index[2] = 3,
starting_index[3] = 0,
starting_index[4] = 5,
which you can use to iterate only over the the second range of part 0 (the third global range) with
for(int i = 0; i < r[3] - r[2]; ++i){
data[starting_index[2] + i] = val;
}
- Template Parameters
-
LocalIndexType | The index type used for part-local indices. To prevent overflows, no single part's size may exceed this index type's maximum value. |
GlobalIndexType | The index type used for the global indices. Needs to be at least as large a type as LocalIndexType. |