libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg > Class Template Reference

Distribute the input range [begin, end) across the thread_pool_type recursively as a collection of tasks. More...

#include <subdivide_n_gen_wk.hpp>

Collaboration diagram for jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >:
[legend]

Classes

struct  algo_work_heap_type
 

Public Types

typedef TPB thread_pool_type
 
typedef thread_pool_type::pool_traits_type pool_traits_type
 
typedef void result_type
 
typedef Alg alg_wrap_t
 
typedef alg_wrap_t::container_type container_type
 
typedef alg_wrap_t::os_traits os_traits
 
typedef alg_wrap_t::work_wrap::in_iterator in_iterator
 
typedef alg_wrap_t::work_wrap::operation_type operation_type
 
typedef alg_wrap_t::ensure_wk_complete_t ensure_wk_complete_t
 An object that signals to the execution_context when all of the closure_base-derived closures has been process()ed, including being distributed across the threads_per_clique in the thread_pool via the tasks spawned by subdivide_n_gen_wk::process(). More...
 

Static Public Member Functions

static thread_pool_type::pool_type::size_type compute_threads_per_clique (typename thread_pool_type::pool_type::size_type num_threads, typename thread_pool_type::pool_type::size_type const cliques) noexcept(true) FORCE_INLINE
 
static thread_pool_type::pool_type::size_type compute_buffer_items (typename thread_pool_type::pool_type::size_type const num_threads_per_clique) noexcept(true) FORCE_INLINE
 

Public Attributes

const thread_pool_type::pool_type::size_type threads_per_clique
 

Static Public Attributes

static constexpr ppd::generic_traits::memory_access_modes memory_access_mode =alg_wrap_t::memory_access_mode
 

Protected Member Functions

in_iterator compute_end (typename std::iterator_traits< in_iterator >::difference_type const number_subranges) const noexcept(true) FORCE_INLINE
 
container_type::size_type num_wk_items_spawned () const noexcept(true) FORCE_INLINE
 
std::ptrdiff_t odd_third_buff_range () const noexcept(true) FORCE_INLINE
 
std::ptrdiff_t even_half_buff_range () const noexcept(true) FORCE_INLINE
 
algo_work_heap_type::buffer_type first_buff_part () const noexcept(true) FORCE_INLINE
 
algo_work_heap_type::buffer_type even_second_buff_part () const noexcept(true) FORCE_INLINE
 
algo_work_heap_type::buffer_type odd_second_buff_part () const noexcept(true) FORCE_INLINE
 
algo_work_heap_type::buffer_type odd_third_buff_part () const noexcept(true) FORCE_INLINE
 
__stdcall subdivide_n_gen_wk (thread_pool_type &p, operation_type &f, typename alg_wrap_t::work_complete_t &w, algo_work_heap_type const &wh) noexcept(true) FORCE_INLINE
 
__stdcall subdivide_n_gen_wk (thread_pool_type &p, operation_type &f, typename alg_wrap_t::work_complete_t &w, algo_work_heap_type const &wh, typename std::iterator_traits< in_iterator >::difference_type const number_subranges, typename thread_pool_type::pool_type::size_type const cliques) noexcept(true) FORCE_INLINE
 
__stdcall subdivide_n_gen_wk (thread_pool_type &p, operation_type &f, typename alg_wrap_t::work_complete_t &w, algo_work_heap_type const &wh, in_iterator const &b, in_iterator const &e) noexcept(true) FORCE_INLINE
 
__stdcall subdivide_n_gen_wk (thread_pool_type &p, operation_type &f, typename alg_wrap_t::work_complete_t &w, algo_work_heap_type const &wh, in_iterator const &b, in_iterator const &e, typename thread_pool_type::pool_type::size_type const t_per_c) noexcept(true) FORCE_INLINE
 
virtual ~subdivide_n_gen_wk () FORCE_INLINE
 

Protected Attributes

const algo_work_heap_type work_heap
 
thread_pool_typepool
 
operation_typefn
 
alg_wrap_t::work_complete_t & all_done
 
const in_iterator begin
 
const in_iterator end
 

Detailed Description

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
class jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >

Distribute the input range [begin, end) across the thread_pool_type recursively as a collection of tasks.

This algorithm recursively creates tasks non-joinably until it terminates, when it reaches the leaves which contain contiguous sub-ranges [begin, end) of the initial range and the functor, fn. i.e. it distributes the initial range across the threads_per_clique within the thread_pool_type. The algorithm contains all_done, a counter, that records the number of outstanding tasks, and when that counter reaches zero, the execution_context is released, as all of the sub-tasks have completed, the counter is required because the tasks are transferred non-joinably.

Definition at line 443 of file subdivide_n_gen_wk.hpp.

Member Typedef Documentation

◆ alg_wrap_t

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef Alg jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::alg_wrap_t

Definition at line 448 of file subdivide_n_gen_wk.hpp.

◆ container_type

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef alg_wrap_t::container_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::container_type

Definition at line 449 of file subdivide_n_gen_wk.hpp.

◆ ensure_wk_complete_t

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef alg_wrap_t::ensure_wk_complete_t jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::ensure_wk_complete_t

An object that signals to the execution_context when all of the closure_base-derived closures has been process()ed, including being distributed across the threads_per_clique in the thread_pool via the tasks spawned by subdivide_n_gen_wk::process().

This is used so that we don't have to generate an execution_context at each branch, and wait upon it, thus causing vertical pool_threads to be held, and horizontal_execution would have to occur instead, i.e. reducing resources consumed.

Definition at line 457 of file subdivide_n_gen_wk.hpp.

◆ in_iterator

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef alg_wrap_t::work_wrap::in_iterator jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::in_iterator

Definition at line 451 of file subdivide_n_gen_wk.hpp.

◆ operation_type

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef alg_wrap_t::work_wrap::operation_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::operation_type

Definition at line 452 of file subdivide_n_gen_wk.hpp.

◆ os_traits

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef alg_wrap_t::os_traits jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::os_traits

Definition at line 450 of file subdivide_n_gen_wk.hpp.

◆ pool_traits_type

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef thread_pool_type::pool_traits_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::pool_traits_type

Definition at line 446 of file subdivide_n_gen_wk.hpp.

◆ result_type

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef void jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::result_type

Definition at line 447 of file subdivide_n_gen_wk.hpp.

◆ thread_pool_type

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
typedef TPB jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::thread_pool_type

Definition at line 445 of file subdivide_n_gen_wk.hpp.

Constructor & Destructor Documentation

◆ subdivide_n_gen_wk() [1/4]

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::subdivide_n_gen_wk ( thread_pool_type p,
operation_type f,
typename alg_wrap_t::work_complete_t &  w,
algo_work_heap_type const &  wh 
)
inlineprotectednoexcept

Definition at line 204 of file subdivide_n_gen_wk_impl.hpp.

◆ subdivide_n_gen_wk() [2/4]

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::subdivide_n_gen_wk ( thread_pool_type p,
operation_type f,
typename alg_wrap_t::work_complete_t &  w,
algo_work_heap_type const &  wh,
typename std::iterator_traits< in_iterator >::difference_type const  number_subranges,
typename thread_pool_type::pool_type::size_type const  cliques 
)
inlineprotectednoexcept
Parameters
number_subrangesReduce the size of the range over which this algorithm operates by the amount specified by this number.

Definition at line 223 of file subdivide_n_gen_wk_impl.hpp.

◆ subdivide_n_gen_wk() [3/4]

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::subdivide_n_gen_wk ( thread_pool_type p,
operation_type f,
typename alg_wrap_t::work_complete_t &  w,
algo_work_heap_type const &  wh,
in_iterator const &  b,
in_iterator const &  e 
)
inlineprotectednoexcept

Definition at line 246 of file subdivide_n_gen_wk_impl.hpp.

◆ subdivide_n_gen_wk() [4/4]

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::subdivide_n_gen_wk ( thread_pool_type p,
operation_type f,
typename alg_wrap_t::work_complete_t &  w,
algo_work_heap_type const &  wh,
in_iterator const &  b,
in_iterator const &  e,
typename thread_pool_type::pool_type::size_type const  t_per_c 
)
inlineprotectednoexcept

Definition at line 265 of file subdivide_n_gen_wk_impl.hpp.

◆ ~subdivide_n_gen_wk()

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
virtual jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::~subdivide_n_gen_wk ( )
inlineprotectedvirtual

Definition at line 545 of file subdivide_n_gen_wk.hpp.

Member Function Documentation

◆ compute_buffer_items()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::thread_pool_type::pool_type::size_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::compute_buffer_items ( typename thread_pool_type::pool_type::size_type const  num_threads_per_clique)
inlinestaticnoexcept

This computation is intimately related to the way subdivide_n_gen_wk::process() spawns sub-tasks, and the two must operate in a similar manner, otherwise we might get memory-allocation errors. Note that it over-allocates memory, because it doesn't allow for memory re-use: children could re-use memory of parents.

Todo:
This is an O(n) operation, and we might want a faster algorithm, it doesn't have to be perfect, as long as the result is >= the true value.
Returns
The number of items allocated in the tree that subdivide_n_gen_wk::process() will generate. Not in bytes, but items.
See also
subdivide_n_gen_wk::process()

Definition at line 116 of file subdivide_n_gen_wk_impl.hpp.

◆ compute_end()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::in_iterator jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::compute_end ( typename std::iterator_traits< in_iterator >::difference_type const  number_subranges) const
inlineprotectednoexcept

Definition at line 137 of file subdivide_n_gen_wk_impl.hpp.

◆ compute_threads_per_clique()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::thread_pool_type::pool_type::size_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::compute_threads_per_clique ( typename thread_pool_type::pool_type::size_type  num_threads,
typename thread_pool_type::pool_type::size_type const  cliques 
)
inlinestaticnoexcept

Definition at line 107 of file subdivide_n_gen_wk_impl.hpp.

◆ even_half_buff_range()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
std::ptrdiff_t jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::even_half_buff_range ( ) const
inlineprotectednoexcept
Returns
This is units of items, not bytes.

Definition at line 164 of file subdivide_n_gen_wk_impl.hpp.

◆ even_second_buff_part()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::algo_work_heap_type::buffer_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::even_second_buff_part ( ) const
inlineprotectednoexcept

Definition at line 181 of file subdivide_n_gen_wk_impl.hpp.

◆ first_buff_part()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::algo_work_heap_type::buffer_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::first_buff_part ( ) const
inlineprotectednoexcept

Definition at line 173 of file subdivide_n_gen_wk_impl.hpp.

◆ num_wk_items_spawned()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::container_type::size_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::num_wk_items_spawned ( ) const
inlineprotectednoexcept

Definition at line 148 of file subdivide_n_gen_wk_impl.hpp.

◆ odd_second_buff_part()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::algo_work_heap_type::buffer_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::odd_second_buff_part ( ) const
inlineprotectednoexcept

Definition at line 189 of file subdivide_n_gen_wk_impl.hpp.

◆ odd_third_buff_part()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
subdivide_n_gen_wk< Ps, TPB, Alg >::algo_work_heap_type::buffer_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::odd_third_buff_part ( ) const
inlineprotectednoexcept

Definition at line 197 of file subdivide_n_gen_wk_impl.hpp.

◆ odd_third_buff_range()

template<pool_traits::size_mode_t Ps, class TPB , class Alg >
std::ptrdiff_t jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::odd_third_buff_range ( ) const
inlineprotectednoexcept
Returns
This is units of items, not bytes.

Definition at line 155 of file subdivide_n_gen_wk_impl.hpp.

Member Data Documentation

◆ all_done

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
alg_wrap_t::work_complete_t& jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::all_done
protected

Definition at line 489 of file subdivide_n_gen_wk.hpp.

◆ begin

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
const in_iterator jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::begin
protected

Definition at line 490 of file subdivide_n_gen_wk.hpp.

◆ end

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
const in_iterator jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::end
protected

Definition at line 491 of file subdivide_n_gen_wk.hpp.

◆ fn

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
operation_type& jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::fn
protected

Definition at line 488 of file subdivide_n_gen_wk.hpp.

◆ memory_access_mode

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
constexpr ppd::generic_traits::memory_access_modes jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::memory_access_mode =alg_wrap_t::memory_access_mode
staticconstexpr

To assist in allowing compile-time computation of the algorithmic order of the threading model.

Definition at line 466 of file subdivide_n_gen_wk.hpp.

◆ pool

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
thread_pool_type& jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::pool
protected

Definition at line 487 of file subdivide_n_gen_wk.hpp.

◆ threads_per_clique

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
const thread_pool_type::pool_type::size_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::threads_per_clique

Definition at line 468 of file subdivide_n_gen_wk.hpp.

◆ work_heap

template<pool_traits::size_mode_t Ps, class TPB, class Alg>
const algo_work_heap_type jmmcg::ppd::private_::subdivide_n_gen_wk< Ps, TPB, Alg >::work_heap
protected

Definition at line 486 of file subdivide_n_gen_wk.hpp.


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