MCPcopy Create free account
hub / github.com/NVIDIA/stdexec / even_share

Function even_share

include/exec/static_thread_pool.hpp:90–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 11

operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
bulk_shared_stateMethod · 0.85
bulk_enqueueMethod · 0.85
bulk_taskMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected