diff --git a/core/distributed/partition.cpp b/core/distributed/partition.cpp index 575ca83aba6..22f0fdb3d94 100644 --- a/core/distributed/partition.cpp +++ b/core/distributed/partition.cpp @@ -123,7 +123,7 @@ void Partition::finalize_construction() template -bool Partition::has_connected_parts() +bool Partition::has_connected_parts() const { return this->get_num_parts() - this->get_num_empty_parts() == this->get_num_ranges(); @@ -131,7 +131,7 @@ bool Partition::has_connected_parts() template -bool Partition::has_ordered_parts() +bool Partition::has_ordered_parts() const { if (this->has_connected_parts()) { auto exec = this->get_executor(); diff --git a/include/ginkgo/core/distributed/partition.hpp b/include/ginkgo/core/distributed/partition.hpp index fa8b2739400..a40f30f7137 100644 --- a/include/ginkgo/core/distributed/partition.hpp +++ b/include/ginkgo/core/distributed/partition.hpp @@ -231,7 +231,7 @@ class Partition * * @return true if each part has no more than one contiguous range. */ - bool has_connected_parts(); + bool has_connected_parts() const; /** * Checks if the ranges are ordered by their part index. @@ -240,7 +240,7 @@ class Partition * * @return true if the ranges are ordered by their part index. */ - bool has_ordered_parts(); + bool has_ordered_parts() const; /** * Builds a partition from a given mapping global_index -> part_id. diff --git a/include/ginkgo/core/distributed/partition_helpers.hpp b/include/ginkgo/core/distributed/partition_helpers.hpp index d9b2fee3d14..889347674c8 100644 --- a/include/ginkgo/core/distributed/partition_helpers.hpp +++ b/include/ginkgo/core/distributed/partition_helpers.hpp @@ -56,12 +56,14 @@ class Partition; * Builds a partition from a local range. * * @param exec the Executor on which the partition should be built. - * @param local_range the start and end indices of the local range. * @param comm the communicator used to determine the global partition. + * @param local_range the start and end indices of the local range. * - * @warning The local ranges have to be continuous and ascending. This means - * that for a process `i` with `range[i] = [s_i, e_i)` then for process - * `j = i+1` `range[j] = [s_j = e_i, e_j)`. + * @warning This throws, if the resulting partition would contain gaps. + * That means that for a partition of size `n` every local range `r_i + * = [s_i, e_i)` either `s_i != 0` and another local range `r_j = + * [s_j, e_j = s_i)` exists, or `e_i != n` and another local range + * `r_j = [s_j = e_i, e_j)` exists. * * @return a Partition where each range has the individual local_start * and local_ends. @@ -76,8 +78,8 @@ build_partition_from_local_range(std::shared_ptr exec, * Builds a partition from a local size. * * @param exec the Executor on which the partition should be built. - * @param local_range the number of the locally owned indices * @param comm the communicator used to determine the global partition. + * @param local_range the number of the locally owned indices * * @return a Partition where each range has the specified local size. More * specifically, if this is called on process i with local_size `s_i`, diff --git a/test/distributed/partition_helper_kernels.cpp b/test/distributed/partition_helper_kernels.cpp index 441da3b8bd4..3cc472cd3b6 100644 --- a/test/distributed/partition_helper_kernels.cpp +++ b/test/distributed/partition_helper_kernels.cpp @@ -64,7 +64,7 @@ template std::vector create_iota(IndexType min, IndexType max) { std::vector iota( - clamp(max - min, static_cast(0), max)); + clamp(max - min, IndexType(0), max)); std::iota(iota.begin(), iota.end(), min); return iota; } @@ -98,7 +98,7 @@ std::vector sample_unique(std::size_t min, std::size_t max, std::default_random_engine engine; auto values = create_iota(min, max); std::shuffle(values.begin(), values.end(), engine); - values.erase(values.begin() + clamp(n, 0ul, values.size()), values.end()); + values.erase(values.begin() + clamp(n, gko::size_type(0), values.size()), values.end()); return values; }