| 88 | // ``` |
| 89 | template <class Shape> |
| 90 | constexpr auto even_share(Shape n, std::size_t rank, std::size_t size) noexcept // |
| 91 | -> std::pair<Shape, Shape> |
| 92 | { |
| 93 | STDEXEC_ASSERT(n >= 0); |
| 94 | using ushape_t = std::make_unsigned_t<Shape>; |
| 95 | auto const avg_per_thread = static_cast<ushape_t>(n) / size; |
| 96 | auto const n_big_share = avg_per_thread + 1; |
| 97 | auto const big_shares = static_cast<ushape_t>(n) % size; |
| 98 | auto const is_big_share = rank < big_shares; |
| 99 | auto const begin = is_big_share |
| 100 | ? n_big_share * rank |
| 101 | : n_big_share * big_shares + (rank - big_shares) * avg_per_thread; |
| 102 | auto const end = begin + (is_big_share ? n_big_share : avg_per_thread); |
| 103 | |
| 104 | return std::make_pair(static_cast<Shape>(begin), static_cast<Shape>(end)); |
| 105 | } |
| 106 | |
| 107 | namespace schedule_all_ |
| 108 | { |
no outgoing calls
no test coverage detected