SPH
|
Interface for executing tasks (potentially) asynchronously. More...
#include "common/ForwardDecl.h"
#include "objects/utility/IteratorAdapters.h"
#include "objects/wrappers/Function.h"
Go to the source code of this file.
Classes | |
class | ITask |
Handle used to control tasks submitted into the scheduler. More... | |
class | IScheduler |
Interface that allows unified implementation of sequential and parallelized versions of algorithms. More... | |
class | SequentialScheduler |
Dummy scheduler that simply executes the submitted tasks sequentially on calling thread. More... | |
Functions | |
template<typename TFunctor > | |
INLINE void | parallelFor (IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor) |
Executes a functor concurrently from all available threads. More... | |
template<typename TFunctor > | |
INLINE void | parallelFor (IScheduler &scheduler, const Size from, const Size to, const Size granularity, TFunctor &&functor) |
Executes a functor concurrently with given granularity. More... | |
template<typename TFunctor > | |
INLINE void | parallelFor (IScheduler &scheduler, const IndexSequence &sequence, TFunctor &&functor) |
Executes a functor concurrently from all available threads. More... | |
Variables | |
SequentialScheduler | SEQUENTIAL |
Global instance of the sequential scheduler. More... | |
Interface for executing tasks (potentially) asynchronously.
Definition in file Scheduler.h.
INLINE void parallelFor | ( | IScheduler & | scheduler, |
const IndexSequence & | sequence, | ||
TFunctor && | functor | ||
) |
Executes a functor concurrently from all available threads.
Overload using an index sequence.
Definition at line 130 of file Scheduler.h.
INLINE void parallelFor | ( | IScheduler & | scheduler, |
const Size | from, | ||
const Size | to, | ||
const Size | granularity, | ||
TFunctor && | functor | ||
) |
Executes a functor concurrently with given granularity.
Overload allowing to specify the granularity.
scheduler | Scheduler used for parallelization. |
from | First processed index. |
to | One-past-last processed index. |
granularity | Number of indices processed by the functor at once. It shall be a positive number less than or equal to (to-from). |
functor | Functor executed concurrently, takes an index as an argument. |
Definition at line 113 of file Scheduler.h.
INLINE void parallelFor | ( | IScheduler & | scheduler, |
const Size | from, | ||
const Size | to, | ||
TFunctor && | functor | ||
) |
Executes a functor concurrently from all available threads.
Syntax mimics typical usage of for loop; functor is executed with index as parameter, starting at 'from' and ending one before 'to', so that total number of executions is (to-from). The function blocks until parallel for is completed.
scheduler | Scheduler used for parallelization. If SequentialScheduler, this is essentailly ordinary for loop (with bigger overhead). |
from | First processed index. |
to | One-past-last processed index. |
functor | Functor executed (to-from) times in different threads; takes an index as an argument. |
Definition at line 98 of file Scheduler.h.
|
extern |
Global instance of the sequential scheduler.
It can be used to specify sequential execution policy for parallel algorithms, without creating unnecessary local instances of SequentialScheduler.
Definition at line 43 of file Scheduler.cpp.