the executor on an arena of oneTBB
More...
#include <ADS/parallel/TBBExecutor.h>
|
| struct | Current |
| | the tag of the executor on the arena of the calling thread More...
|
|
| using | lock_type = tbb::spin_mutex |
| | the lock of the data shared by the workers of run()
|
|
| | TBBExecutor (std::size_t p=0) |
| | the executor of an arena of its own, of \( p \) threads (the hardware threads if \( p = 0 \))
|
| | TBBExecutor (tbb::task_arena &arena) |
| | the executor on the arena of the program, which it does not own and which must outlive it; its threads are those of the arena
|
| | TBBExecutor (Current) |
| | the executor on the arena of the thread that makes each call (the arena of a loop of oneTBB that calls an algorithm of ADS, the implicit arena of the process elsewhere); its threads are those of that arena
|
| std::size_t | concurrency (void) const |
| | the number of threads of the arena: \( p \) for its own, the concurrency of the arena of the program, or of the current one
|
| template<class F> |
| void | bulk (std::size_t n, F &&f) |
| | the calls \( f( 0 ) , \ldots , f( n - 1 ) \) on the threads of the arena
|
| template<class F, class G> |
| void | invoke (F &&f, G &&g) |
| | the calls f() and g() in parallel, by the parallel_invoke of oneTBB in the arena
|
| template<class F> |
| void | run (std::size_t p, F &&f) |
| | the calls \( f( 0 ) , \ldots , f( p - 1 ) \) of long-lived workers, at the same time on \( p \) threads of the arena
|
the executor on an arena of oneTBB
◆ lock_type
the lock of the data shared by the workers of run()
◆ TBBExecutor() [1/3]
| ADS::TBBExecutor::TBBExecutor |
( |
std::size_t | p = 0 | ) |
|
|
inlineexplicit |
the executor of an arena of its own, of \( p \) threads (the hardware threads if \( p = 0 \))
- Precondition
- \( p \ge 1 \) once the hardware threads are counted
◆ TBBExecutor() [2/3]
| ADS::TBBExecutor::TBBExecutor |
( |
tbb::task_arena & | arena | ) |
|
|
inlineexplicit |
the executor on the arena of the program, which it does not own and which must outlive it; its threads are those of the arena
◆ TBBExecutor() [3/3]
| ADS::TBBExecutor::TBBExecutor |
( |
Current | | ) |
|
|
inlineexplicit |
the executor on the arena of the thread that makes each call (the arena of a loop of oneTBB that calls an algorithm of ADS, the implicit arena of the process elsewhere); its threads are those of that arena
◆ bulk()
template<class F>
| void ADS::TBBExecutor::bulk |
( |
std::size_t | n, |
|
|
F && | f ) |
|
inline |
the calls \( f( 0 ) , \ldots , f( n - 1 ) \) on the threads of the arena
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{bulk}( n , f ) \cr
2 & \quad \textbf{if}\ n \le 1\ \textbf{or}\ p = 1\ \textbf{then}
\ \textbf{for}\ i \gets 0\ \textbf{to}\ n - 1\ \textbf{do}\ f( i ) \cr
3 & \quad \textbf{else}\ \text{in the arena, the } \mathrm{parallel\_for}
\text{ of oneTBB on } [ 0 , n ) \text{, a task per index}
\end{array}}
\]
◆ concurrency()
| std::size_t ADS::TBBExecutor::concurrency |
( |
void | | ) |
const |
|
inlinenodiscard |
the number of threads of the arena: \( p \) for its own, the concurrency of the arena of the program, or of the current one
◆ invoke()
template<class F, class G>
| void ADS::TBBExecutor::invoke |
( |
F && | f, |
|
|
G && | g ) |
|
inline |
the calls f() and g() in parallel, by the parallel_invoke of oneTBB in the arena
◆ run()
template<class F>
| void ADS::TBBExecutor::run |
( |
std::size_t | p, |
|
|
F && | f ) |
|
inline |
the calls \( f( 0 ) , \ldots , f( p - 1 ) \) of long-lived workers, at the same time on \( p \) threads of the arena
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{run}( p , f ) \cr
2 & \quad \textbf{if}\ p \le 1\ \textbf{then}\ \textbf{for}\ i \gets 0
\ \textbf{to}\ p - 1\ \textbf{do}\ f( i );\ \textbf{return} \cr
3 & \quad \text{in the arena, the } \mathrm{parallel\_for} \text{ of }
\text{oneTBB on } [ 0 , p ) \text{, a task per index } i
\text{ making } f( i ) \cr
& \qquad \text{inside } \mathrm{isolate}() \cr
4 & \quad \text{throw again the first exception of the calls, if any}
\end{array}}
\]
- Precondition
- \( p \le \) concurrency(), and not more than the hardware threads
◆ current
| Current ADS::TBBExecutor::current {} |
|
staticconstexpr |
The documentation for this class was generated from the following file: