|
| unsigned | resolve_pool_spin (unsigned fallback) |
| | Spin iterations from MTL5_POOL_SPIN; fallback when unset or invalid: signed, out of range, empty or not all digits (env_unsigned, issue 876).
|
| unsigned | clamp_pool_threads (unsigned long v) |
| | Clamp a requested thread count to [1, hardware concurrency].
|
| bool | env_unsigned (const char *name, unsigned &out) |
| | Read environment variable name as a whole unsigned decimal: digits only, no sign, space or trailing characters, at most 0xFFFFFFFF.
|
| unsigned | resolve_pool_threads () |
| | Resolve the pool size from MTL5_NUM_THREADS (clamped to hardware concurrency); 1 when unset/invalid (see env_unsigned).
|
| pool_config & | config () |
| region_thread & | this_region_thread () noexcept |
| bool | in_region () noexcept |
| | True while this thread runs a tid of an MTL5 region (see the contract at the top of this header).
|
| bool | on_pool_worker () noexcept |
| | True on the pool's worker threads, which are inside a region whenever they run anything at all.
|
| unsigned | claim_pool_size () |
| unsigned | team_for (std::size_t n, std::size_t grain, unsigned max_threads, unsigned pool_size) noexcept |
| | Team for a chunked loop over n units on a pool of pool_size: the pool, or max_threads if that is smaller and nonzero, cut so each chunk holds >= grain units; 1 (serial) when the pool is serial or n < 2 * grain.
|
| template<typename Pool, typename Body> |
| void | chunked_for (Pool &pool, std::size_t n, std::size_t grain, unsigned max_threads, Body &&body) |
| | parallel_for on pool; see thread_pool::parallel_for.
|
| template<typename T, typename Pool, typename MapFn> |
| T | chunked_reduce (Pool &pool, std::size_t n, std::size_t grain, unsigned max_threads, MapFn &&map) |
| | parallel_reduce on pool; see thread_pool::parallel_reduce.
|
| template<typename Acc, typename Pool, typename InitFn, typename MapFn, typename CombineFn> |
| Acc | chunked_accumulate (Pool &pool, std::size_t n, std::size_t grain, unsigned max_threads, InitFn &&init, MapFn &&map, CombineFn &&combine) |
| | parallel_accumulate on pool; see thread_pool::parallel_accumulate.
|
| void | cpu_relax () noexcept |
| | One spin-wait iteration: a pause hint to the core, nothing else.
|
| void | spin_step (unsigned i) noexcept |
| | One iteration of a spin wait: a pause, and every 64th iteration a yield, so a thread the scheduler has queued on this core behind the spinner runs within a few microseconds instead of after the whole spin.
|
| bool mtl::parallel::pool_local_noexc::detail::env_unsigned |
( |
const char * | name, |
|
|
unsigned & | out ) |
|
inline |
Read environment variable name as a whole unsigned decimal: digits only, no sign, space or trailing characters, at most 0xFFFFFFFF.
False when it is unset or not such a number. strtoul, which both pool variables used, accepts a leading '-' and wraps: MTL5_POOL_SPIN=-1 became the largest spin, 4294967295 iterations (issue 876).