MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::parallel::pool_local_noexc::spin_pool Class Reference

#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.

Constructor & Destructor Documentation

◆ spin_pool() [1/2]

mtl::parallel::pool_local_noexc::spin_pool::spin_pool ( unsigned n,
unsigned spin = default_spin )
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.

◆ spin_pool() [2/2]

mtl::parallel::pool_local_noexc::spin_pool::spin_pool ( const spin_pool & )
delete

◆ ~spin_pool()

mtl::parallel::pool_local_noexc::spin_pool::~spin_pool ( )
inline

Member Function Documentation

◆ instance()

spin_pool & mtl::parallel::pool_local_noexc::spin_pool::instance ( )
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.

◆ operator=()

spin_pool & mtl::parallel::pool_local_noexc::spin_pool::operator= ( const spin_pool & )
delete

◆ parallel_accumulate() [1/2]

template<typename Acc, typename InitFn, typename MapFn, typename CombineFn>
Acc mtl::parallel::pool_local_noexc::spin_pool::parallel_accumulate ( std::size_t n,
std::size_t grain,
InitFn && init,
MapFn && map,
CombineFn && combine )
inline

thread_pool::parallel_accumulate, on this pool. Allocates its partials.

◆ parallel_accumulate() [2/2]

template<typename Acc, typename InitFn, typename MapFn, typename CombineFn>
Acc mtl::parallel::pool_local_noexc::spin_pool::parallel_accumulate ( std::size_t n,
std::size_t grain,
unsigned max_threads,
InitFn && init,
MapFn && map,
CombineFn && combine )
inline

◆ parallel_for() [1/2]

template<typename Body>
void mtl::parallel::pool_local_noexc::spin_pool::parallel_for ( std::size_t n,
std::size_t grain,
Body && body )
inline

thread_pool::parallel_for, on this pool.

◆ parallel_for() [2/2]

template<typename Body>
void mtl::parallel::pool_local_noexc::spin_pool::parallel_for ( std::size_t n,
std::size_t grain,
unsigned max_threads,
Body && body )
inline

◆ parallel_reduce() [1/2]

template<typename T, typename MapFn>
T mtl::parallel::pool_local_noexc::spin_pool::parallel_reduce ( std::size_t n,
std::size_t grain,
MapFn && map )
inline

thread_pool::parallel_reduce, on this pool. Allocates its partials.

◆ parallel_reduce() [2/2]

template<typename T, typename MapFn>
T mtl::parallel::pool_local_noexc::spin_pool::parallel_reduce ( std::size_t n,
std::size_t grain,
unsigned max_threads,
MapFn && map )
inline

◆ run()

template<typename Fn>
void mtl::parallel::pool_local_noexc::spin_pool::run ( unsigned count,
Fn && fn )
inline

Run task(tid) for tid in [0, count); thread_pool::run's contract.

Takes no lock and does not allocate.

◆ size()

unsigned mtl::parallel::pool_local_noexc::spin_pool::size ( ) const
inlinenoexcept

Total logical workers, including the calling thread (>= 1).

◆ spin()

unsigned mtl::parallel::pool_local_noexc::spin_pool::spin ( ) const
inlinenoexcept

Spin iterations before a waiting thread sleeps.

Member Data Documentation

◆ default_spin

unsigned mtl::parallel::pool_local_noexc::spin_pool::default_spin = 4096
staticconstexpr

Spin iterations before a waiting thread sleeps, when none is given.


The documentation for this class was generated from the following file: