|
ADS
Algorithms and Data Structures
|
the executor on a ParallelFor of FastFlow More...
#include <ADS/parallel/FastFlowExecutor.h>
Public types | |
| using | lock_type = FastFlowLock |
| the lock of the data shared by the workers of run() | |
Public member functions | |
| FastFlowExecutor (std::size_t p=0, bool spin=true) | |
| the executor of \( p \) workers of FastFlow (the hardware threads if \( p = 0 \)), which spin between the calls if spin | |
| std::size_t | concurrency (void) const |
| the number of workers | |
| template<class F> | |
| void | bulk (std::size_t n, F &&f) |
| the calls \( f( 0 ) , \ldots , f( n - 1 ) \) on the workers, in order on the calling thread if it is inside a call | |
| 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 \) workers of FastFlow | |
the executor on a ParallelFor of FastFlow
the lock of the data shared by the workers of run()
|
inlineexplicit |
the executor of \( p \) workers of FastFlow (the hardware threads if \( p = 0 \)), which spin between the calls if spin
|
inline |
the calls \( f( 0 ) , \ldots , f( n - 1 ) \) on the workers, in order on the calling thread if it is inside a call
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{or} \ \text{inside a call of } f\ \textbf{then} \cr 3 & \qquad \textbf{for}\ i \gets 0\ \textbf{to}\ n - 1\ \textbf{do} \ f( i ) \cr 4 & \quad \textbf{else}\ \text{the } \mathrm{parallel\_for} \text{ of } \text{FastFlow on } [ 0 , \max\{ n , p \} ) \text{ in chunks of 1,} \cr & \qquad \text{on all the } p \text{ workers, the indices from } n \text{ doing nothing} \end{array}} \]
|
inlinenodiscard |
the number of workers
|
inline |
the calls \( f( 0 ) , \ldots , f( p - 1 ) \) of long-lived workers, at the same time on \( p \) workers of FastFlow
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{or}\ \text{inside a call of } f\ \textbf{then}\ \textbf{for}\ i \gets 0\ \textbf{to}\ p - 1 \ \textbf{do}\ f( i );\ \textbf{return} \cr 3 & \quad \text{the } \mathrm{parallel\_for} \text{ of FastFlow on } [ 0 , p ) \text{ in chunks of 1, on } p \text{ workers, the worker } i \text{ first given } i \cr 4 & \quad \text{throw again the first exception of the calls, if any} \end{array}} \]