|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
#include <spin_pool.hpp>
Public Member Functions | |
| spin_pool (unsigned n, unsigned spin=default_spin) | |
| Construct a pool with n total logical workers (n-1 background threads + the caller); n < 1 is treated as 1 (serial). | |
| unsigned | size () const noexcept |
| Total logical workers, including the calling thread (>= 1). | |
| unsigned | spin () const noexcept |
| Spin iterations before a waiting thread sleeps. | |
| template<typename Fn> | |
| void | run (unsigned count, Fn &&fn) |
| Run task(tid) for tid in [0, count); thread_pool::run's contract. | |
| template<typename Body> | |
| void | parallel_for (std::size_t n, std::size_t grain, Body &&body) |
| thread_pool::parallel_for, on this pool. | |
| template<typename Body> | |
| void | parallel_for (std::size_t n, std::size_t grain, unsigned max_threads, Body &&body) |
| template<typename T, typename MapFn> | |
| T | parallel_reduce (std::size_t n, std::size_t grain, MapFn &&map) |
| thread_pool::parallel_reduce, on this pool. Allocates its partials. | |
| template<typename T, typename MapFn> | |
| T | parallel_reduce (std::size_t n, std::size_t grain, unsigned max_threads, MapFn &&map) |
| template<typename Acc, typename InitFn, typename MapFn, typename CombineFn> | |
| Acc | parallel_accumulate (std::size_t n, std::size_t grain, InitFn &&init, MapFn &&map, CombineFn &&combine) |
| thread_pool::parallel_accumulate, on this pool. Allocates its partials. | |
| template<typename Acc, typename InitFn, typename MapFn, typename CombineFn> | |
| Acc | parallel_accumulate (std::size_t n, std::size_t grain, unsigned max_threads, InitFn &&init, MapFn &&map, CombineFn &&combine) |
| spin_pool (const spin_pool &)=delete | |
| spin_pool & | operator= (const spin_pool &)=delete |
| ~spin_pool () | |
Static Public Member Functions | |
| static spin_pool & | instance () |
| Process-wide spin_pool, sized on first use as thread_pool's is (configure(), else MTL5_NUM_THREADS), with its spin from MTL5_POOL_SPIN. | |
Static Public Attributes | |
| static constexpr unsigned | default_spin = 4096 |
| Spin iterations before a waiting thread sleeps, when none is given. | |
|
inlineexplicit |
Construct a pool with n total logical workers (n-1 background threads + the caller); n < 1 is treated as 1 (serial).
A waiting worker, and the caller in its join, spin spin iterations before they sleep.
|
delete |
|
inline |
|
inlinestatic |
Process-wide spin_pool, sized on first use as thread_pool's is (configure(), else MTL5_NUM_THREADS), with its spin from MTL5_POOL_SPIN.
|
inline |
thread_pool::parallel_accumulate, on this pool. Allocates its partials.
|
inline |
|
inline |
thread_pool::parallel_for, on this pool.
|
inline |
|
inline |
thread_pool::parallel_reduce, on this pool. Allocates its partials.
|
inline |
|
inline |
Run task(tid) for tid in [0, count); thread_pool::run's contract.
Takes no lock and does not allocate.
|
inlinenoexcept |
Total logical workers, including the calling thread (>= 1).
|
inlinenoexcept |
Spin iterations before a waiting thread sleeps.
|
staticconstexpr |
Spin iterations before a waiting thread sleeps, when none is given.