|
dispenso 1.4.1
A library for task parallelism
|
#include <cmath>#include <limits>#include <memory>#include <dispenso/detail/can_invoke.h>#include <dispenso/detail/per_thread_info.h>#include <dispenso/task_set.h>Go to the source code of this file.
Classes | |
| struct | dispenso::ParForOptions |
Enumerations | |
| enum class | dispenso::ParForChunking { } |
Functions | |
| template<typename IntegerA , typename IntegerB > | |
| ChunkedRange< std::common_type_t< IntegerA, IntegerB > > | dispenso::makeChunkedRange (IntegerA start, IntegerB end, ParForChunking chunking=ParForChunking::kStatic) |
| template<typename IntegerA , typename IntegerB , typename IntegerC > | |
| ChunkedRange< std::common_type_t< IntegerA, IntegerB > > | dispenso::makeChunkedRange (IntegerA start, IntegerB end, IntegerC chunkSize) |
| template<typename TaskSetT , typename IntegerT , typename F , typename StateContainer , typename StateGen > | |
| void | dispenso::parallel_for (TaskSetT &taskSet, StateContainer &states, const StateGen &defaultState, const ChunkedRange< IntegerT > &range, F &&f, ParForOptions options={}) |
| template<typename TaskSetT , typename IntegerT , typename F > | |
| void | dispenso::parallel_for (TaskSetT &taskSet, const ChunkedRange< IntegerT > &range, F &&f, ParForOptions options={}) |
| template<typename IntegerT , typename F > | |
| void | dispenso::parallel_for (const ChunkedRange< IntegerT > &range, F &&f, ParForOptions options={}) |
| template<typename F , typename IntegerT , typename StateContainer , typename StateGen > | |
| void | dispenso::parallel_for (StateContainer &states, const StateGen &defaultState, const ChunkedRange< IntegerT > &range, F &&f, ParForOptions options={}) |
| template<typename TaskSetT , typename IntegerA , typename IntegerB , typename F , std::enable_if_t< std::is_integral< IntegerA >::value, bool > = true, std::enable_if_t< std::is_integral< IntegerB >::value, bool > = true, std::enable_if_t< detail::CanInvoke< F(IntegerA)>::value, bool > = true> | |
| void | dispenso::parallel_for (TaskSetT &taskSet, IntegerA start, IntegerB end, F &&f, ParForOptions options={}) |
| template<typename IntegerA , typename IntegerB , typename F , std::enable_if_t< std::is_integral< IntegerA >::value, bool > = true, std::enable_if_t< std::is_integral< IntegerB >::value, bool > = true> | |
| void | dispenso::parallel_for (IntegerA start, IntegerB end, F &&f, ParForOptions options={}) |
| template<typename TaskSetT , typename IntegerA , typename IntegerB , typename F , typename StateContainer , typename StateGen , std::enable_if_t< std::is_integral< IntegerA >::value, bool > = true, std::enable_if_t< std::is_integral< IntegerB >::value, bool > = true, std::enable_if_t< detail::CanInvoke< F(typename StateContainer::reference, IntegerA)>::value, bool > = true> | |
| void | dispenso::parallel_for (TaskSetT &taskSet, StateContainer &states, const StateGen &defaultState, IntegerA start, IntegerB end, F &&f, ParForOptions options={}) |
| template<typename IntegerA , typename IntegerB , typename F , typename StateContainer , typename StateGen , std::enable_if_t< std::is_integral< IntegerA >::value, bool > = true, std::enable_if_t< std::is_integral< IntegerB >::value, bool > = true> | |
| void | dispenso::parallel_for (StateContainer &states, const StateGen &defaultState, IntegerA start, IntegerB end, F &&f, ParForOptions options={}) |
Functions for performing parallel for loops.
Definition in file parallel_for.h.
|
strong |
Chunking strategy. Typically if the cost of each loop iteration is roughly constant, kStatic load balancing is preferred. Additionally, when making a non-waiting parallel_for call in conjunction with other parallel_for calls or with other task submissions to a TaskSet, some dynamic load balancing is automatically introduced, and selecting kStatic load balancing here can be better. If the workload per iteration deviates a lot from constant, and some ranges may be much cheaper than others, select kAuto.
Definition at line 72 of file parallel_for.h.
|
inline |
Create a ChunkedRange with specific chunk size
| start | The start of the range. |
| end | The end of the range. |
| chunkSize | The chunk size. |
Definition at line 232 of file parallel_for.h.
|
inline |
Create a ChunkedRange with specified chunking strategy.
| start | The start of the range. |
| end | The end of the range. |
| chunking | The strategy to use for chunking. |
Definition at line 216 of file parallel_for.h.
| void dispenso::parallel_for | ( | const ChunkedRange< IntegerT > & | range, |
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel on the global thread pool, and wait until complete.
| range | The range defining the loop extents as well as chunking strategy. |
| f | The functor to execute in parallel. Must have a signature like void(size_t begin, size_t end). |
| options | See ParForOptions for details. options.wait will always be reset to true. |
Definition at line 581 of file parallel_for.h.
| void dispenso::parallel_for | ( | IntegerA | start, |
| IntegerB | end, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel on the global thread pool and block on loop completion.
| start | The start of the loop extents. |
| end | The end of the loop extents. |
| f | The functor to execute in parallel. Must have a signature like void(size_t index) or void(size_t begin, size_t end). |
| options | See ParForOptions for details. options.wait will always be reset to true. |
Definition at line 689 of file parallel_for.h.
| void dispenso::parallel_for | ( | StateContainer & | states, |
| const StateGen & | defaultState, | ||
| const ChunkedRange< IntegerT > & | range, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel on the global thread pool and block until loop completion.
| states | A container of State (actual type of State TBD by user). The container will be resized to hold a State object per executing thread. Container must provide emplace_back() and must be forward-iterable. Examples include std::vector, std::deque, and std::list. These are the states passed into f, and states must remain a valid object until work is completed. |
| defaultState | A functor with signature State(). It will be called to initialize the objects for states. |
| range | The range defining the loop extents as well as chunking strategy. |
| f | The functor to execute in parallel. Must have a signature like void(State &s, size_t begin, size_t end). |
| options | See ParForOptions for details. options.wait will always be reset to true. |
Definition at line 605 of file parallel_for.h.
| void dispenso::parallel_for | ( | StateContainer & | states, |
| const StateGen & | defaultState, | ||
| IntegerA | start, | ||
| IntegerB | end, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel on the global thread pool and block until loop completion.
| states | A container of State (actual type of State TBD by user). The container will be resized to hold a State object per executing thread. Container must provide emplace_back() and must be forward-iterable. Examples include std::vector, std::deque, and std::list. These are the states passed into f, and states must remain a valid object until work is completed. |
| defaultState | A functor with signature State(). It will be called to initialize the objects for states. |
| start | The start of the loop extents. |
| end | The end of the loop extents. |
| f | The functor to execute in parallel. Must have a signature like void(State &s, size_t index) or void(State &s, size_t begin, size_t end). |
| options | See ParForOptions for details. options.wait will always be reset to true. |
Definition at line 800 of file parallel_for.h.
| void dispenso::parallel_for | ( | TaskSetT & | taskSet, |
| const ChunkedRange< IntegerT > & | range, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel.
| taskSet | The task set to schedule the loop on. |
| range | The range defining the loop extents as well as chunking strategy. |
| f | The functor to execute in parallel. Must have a signature like void(size_t begin, size_t end). |
| options | See ParForOptions for details. |
Definition at line 555 of file parallel_for.h.
| void dispenso::parallel_for | ( | TaskSetT & | taskSet, |
| IntegerA | start, | ||
| IntegerB | end, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel.
| taskSet | The task set to schedule the loop on. |
| start | The start of the loop extents. |
| end | The end of the loop extents. |
| f | The functor to execute in parallel. Must have a signature like void(size_t index) or void(size_t begin, size_t end). |
| options | See ParForOptions for details. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 634 of file parallel_for.h.
| void dispenso::parallel_for | ( | TaskSetT & | taskSet, |
| StateContainer & | states, | ||
| const StateGen & | defaultState, | ||
| const ChunkedRange< IntegerT > & | range, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel.
| taskSet | The task set to schedule the loop on. |
| states | A container of State (actual type of State TBD by user). The container will be resized to hold a State object per executing thread. Container must provide emplace_back() and must be forward-iterable. Examples include std::vector, std::deque, and std::list. These are the states passed into f, and states must remain a valid object until work is completed. |
| defaultState | A functor with signature State(). It will be called to initialize the objects for states. |
| range | The range defining the loop extents as well as chunking strategy. |
| f | The functor to execute in parallel. Must have a signature like void(State &s, size_t begin, size_t end). |
| options | See ParForOptions for details. |
Definition at line 383 of file parallel_for.h.
| void dispenso::parallel_for | ( | TaskSetT & | taskSet, |
| StateContainer & | states, | ||
| const StateGen & | defaultState, | ||
| IntegerA | start, | ||
| IntegerB | end, | ||
| F && | f, | ||
| ParForOptions | options = {} ) |
Execute loop over the range in parallel.
| taskSet | The task set to schedule the loop on. |
| states | A container of State (actual type of State TBD by user). The container will be resized to hold a State object per executing thread. Container must provide emplace_back() and must be forward-iterable. Examples include std::vector, std::deque, and std::list. These are the states passed into f, and states must remain a valid object until work is completed. |
| defaultState | A functor with signature State(). It will be called to initialize the objects for states. |
| start | The start of the loop extents. |
| end | The end of the loop extents. |
| f | The functor to execute in parallel. Must have a signature like void(State &s, size_t index) or void(State &s, size_t begin, size_t end). |
| options | See ParForOptions for details. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 725 of file parallel_for.h.