Ginkgo
Generated from pipelines/1589998975 branch based on develop. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
|
Represents a partition of a range of indices [0, size) into a disjoint set of parts. More...
#include <ginkgo/core/distributed/partition.hpp>
Public Types | |
using | local_index_type = LocalIndexType |
using | global_index_type = GlobalIndexType |
Public Types inherited from gko::EnablePolymorphicAssignment< Partition< LocalIndexType, GlobalIndexType > > | |
using | result_type = Partition< LocalIndexType, GlobalIndexType > |
Public Types inherited from gko::ConvertibleTo< Partition< LocalIndexType, GlobalIndexType > > | |
using | result_type = Partition< LocalIndexType, GlobalIndexType > |
Public Member Functions | |
size_type | get_size () const |
Returns the total number of elements represented by this partition. More... | |
size_type | get_num_ranges () const noexcept |
Returns the number of ranges stored by this partition. More... | |
comm_index_type | get_num_parts () const noexcept |
Returns the number of parts represented in this partition. More... | |
comm_index_type | get_num_empty_parts () const noexcept |
Returns the number of empty parts within this partition. More... | |
const global_index_type * | get_range_bounds () const noexcept |
Returns the ranges boundary array stored by this partition. More... | |
const comm_index_type * | get_part_ids () const noexcept |
Returns the part IDs of the ranges in this partition. More... | |
const local_index_type * | get_range_starting_indices () const noexcept |
Returns the part-local starting index for each range in this partition. More... | |
const local_index_type * | get_part_sizes () const noexcept |
Returns the part size array. More... | |
local_index_type | get_part_size (comm_index_type part) const |
Returns the size of a part given by its part ID. More... | |
bool | has_connected_parts () const |
Checks if each part has no more than one contiguous range. More... | |
bool | has_ordered_parts () const |
Checks if the ranges are ordered by their part index. More... | |
Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< Partition< LocalIndexType, GlobalIndexType >, PolymorphicObject > | |
std::unique_ptr< Partition< LocalIndexType, GlobalIndexType > > | create_default (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< Partition< LocalIndexType, GlobalIndexType > > | create_default () const |
std::unique_ptr< Partition< LocalIndexType, GlobalIndexType > > | clone (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< Partition< LocalIndexType, GlobalIndexType > > | clone () const |
Partition< LocalIndexType, GlobalIndexType > * | copy_from (const PolymorphicObject *other) |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Partition< LocalIndexType, GlobalIndexType > > * | copy_from (std::unique_ptr< Derived > &&other) |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Partition< LocalIndexType, GlobalIndexType > > * | copy_from (const std::unique_ptr< Derived > &other) |
Partition< LocalIndexType, GlobalIndexType > * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
Partition< LocalIndexType, GlobalIndexType > * | move_from (ptr_param< PolymorphicObject > other) |
Partition< LocalIndexType, GlobalIndexType > * | clear () |
Public Member Functions inherited from gko::PolymorphicObject | |
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. More... | |
std::unique_ptr< PolymorphicObject > | create_default () const |
Creates a new "default" object of the same dynamic type as this object. More... | |
std::unique_ptr< PolymorphicObject > | clone (std::shared_ptr< const Executor > exec) const |
Creates a clone of the object. More... | |
std::unique_ptr< PolymorphicObject > | clone () const |
Creates a clone of the object. More... | |
PolymorphicObject * | copy_from (const PolymorphicObject *other) |
Copies another object into this object. More... | |
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. More... | |
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. More... | |
PolymorphicObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
Copies another object into this object. More... | |
PolymorphicObject * | move_from (ptr_param< PolymorphicObject > other) |
Moves another object into this object. More... | |
PolymorphicObject * | clear () |
Transforms the object into its default state. More... | |
std::shared_ptr< const Executor > | get_executor () const noexcept |
Returns the Executor of the object. More... | |
Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject > | |
void | add_logger (std::shared_ptr< const Logger > logger) override |
void | remove_logger (const Logger *logger) override |
void | remove_logger (ptr_param< const Logger > logger) |
const std::vector< std::shared_ptr< const Logger > > & | get_loggers () const override |
void | clear_loggers () override |
Public Member Functions inherited from gko::log::Loggable | |
void | remove_logger (ptr_param< const Logger > logger) |
Public Member Functions inherited from gko::EnablePolymorphicAssignment< Partition< LocalIndexType, GlobalIndexType > > | |
void | convert_to (result_type *result) const override |
Converts the implementer to an object of type result_type. More... | |
void | move_to (result_type *result) override |
Converts the implementer to an object of type result_type by moving data from this object. More... | |
Public Member Functions inherited from gko::ConvertibleTo< Partition< LocalIndexType, GlobalIndexType > > | |
void | convert_to (ptr_param< result_type > result) const |
void | move_to (ptr_param< result_type > result) |
Static Public Member Functions | |
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. More... | |
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. More... | |
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. More... | |
Friends | |
class | EnablePolymorphicObject< Partition > |
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:
These ranges are distributed on three part with:
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
which you can use to iterate only over the the second range of part 0 (the third global range) with
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. |
|
static |
Builds a partition consisting of contiguous ranges, one for each part.
exec | the Executor on which the partition should be built |
ranges | the boundaries of the ranges representing each part. Part part_id[i] contains the indices [ranges[i], ranges[i + 1]). Has to contain at least one element. The first element has to be 0. |
part_ids | the part ids of the provided ranges. If empty, then it will assume range i belongs to part i. |
|
static |
Builds a partition by evenly distributing the global range.
exec | the Executor on which the partition should be built |
num_parts | the number of parst used in this partition |
global_size | the global size of this partition |
floor(global_size/num_parts)
or floor(global_size/num_parts) + 1
indices.
|
static |
Builds a partition from a given mapping global_index -> part_id.
exec | the Executor on which the partition should be built |
mapping | the mapping from global indices to part IDs. |
num_parts | the number of parts used in the mapping. |
|
inlinenoexcept |
Returns the number of empty parts within this partition.
|
inlinenoexcept |
Returns the number of parts represented in this partition.
|
inlinenoexcept |
Returns the number of ranges stored by this partition.
This size refers to the data returned by get_range_bounds().
References gko::array< ValueType >::get_size().
|
inlinenoexcept |
Returns the part IDs of the ranges in this partition.
For each range from get_range_bounds(), it stores the part ID in the interval [0, get_num_parts() - 1].
References gko::array< ValueType >::get_const_data().
local_index_type gko::experimental::distributed::Partition< LocalIndexType, GlobalIndexType >::get_part_size | ( | comm_index_type | part | ) | const |
Returns the size of a part given by its part ID.
part | the part ID. |
|
inlinenoexcept |
Returns the part size array.
part_sizes[p] stores the total number of indices in part p
.
References gko::array< ValueType >::get_const_data().
|
inlinenoexcept |
Returns the ranges boundary array stored by this partition.
range_bounds[i]
is the beginning (inclusive) and range_bounds[i + 1]
is the end (exclusive) of the ith range.
References gko::array< ValueType >::get_const_data().
|
inlinenoexcept |
Returns the part-local starting index for each range in this partition.
Consider the partition on [0, 10)
with
Then range_starting_indices[0] = 0
, range_starting_indices[1] = 0
, range_starting_indices[2] = 4
.
References gko::array< ValueType >::get_const_data().
|
inline |
Returns the total number of elements represented by this partition.
bool gko::experimental::distributed::Partition< LocalIndexType, GlobalIndexType >::has_connected_parts | ( | ) | const |
Checks if each part has no more than one contiguous range.
bool gko::experimental::distributed::Partition< LocalIndexType, GlobalIndexType >::has_ordered_parts | ( | ) | const |
Checks if the ranges are ordered by their part index.
Implies that the partition is connected.