26constexpr std::array<std::int64_t, 2>
local_range(
int index, std::int64_t N,
30 throw std::invalid_argument(
"local_range: index must be non-negative");
32 throw std::invalid_argument(
"local_range: N must be non-negative");
34 throw std::invalid_argument(
"local_range: size must be positive");
37 const std::int64_t n = N / size;
38 const std::int64_t r = N % size;
42 return {index * (n + 1), index * (n + 1) + n + 1};
44 return {index * n + r, index * n + r + n};
constexpr std::array< std::int64_t, 2 > local_range(int index, std::int64_t N, int size)
Partition a global range [0, N - 1] across callers into non-overlapping sub-partitions of almost equa...
Definition local_range.h:26