SPH
|
Scheduler encapsulating Intel Thread Building Blocks (TBB). More...
#include <Tbb.h>
Public Member Functions | |
Tbb (const Size numThreads=0, const Size granularity=1000) | |
~Tbb () | |
void | setGranularity (const Size newGranularity) |
void | setThreadCnt (const Size numThreads) |
virtual SharedPtr< ITask > | submit (const Function< void()> &task) override |
Submits a task to be potentially executed asynchronously. More... | |
virtual Optional< Size > | getThreadIdx () const override |
Returns the index of the calling thread. More... | |
virtual Size | getThreadCnt () const override |
Returns the number of threads used by this scheduler. More... | |
virtual Size | getRecommendedGranularity () const override |
Returns a value of granularity that is expected to perform well with the current thread count. More... | |
virtual void | parallelFor (const Size from, const Size to, const Size granularity, const Function< void(Size n1, Size n2)> &functor) override |
Processes the given range concurrently. More... | |
Public Member Functions inherited from Polymorphic | |
virtual | ~Polymorphic () |
Static Public Member Functions | |
static SharedPtr< Tbb > | getGlobalInstance () |
Scheduler encapsulating Intel Thread Building Blocks (TBB).
TBB libraries need to be linked in order to use this scheduler.
Tbb::~Tbb | ( | ) |
|
overridevirtual |
Returns a value of granularity that is expected to perform well with the current thread count.
Implements IScheduler.
|
overridevirtual |
Returns the number of threads used by this scheduler.
Note that this number is constant during the lifetime of the scheduler.
Implements IScheduler.
Returns the index of the calling thread.
If this thread was not invoked by the scheduler, returns NOTHING. The returned index is interval [0, getThreadCnt()-1].
Implements IScheduler.
|
overridevirtual |
Processes the given range concurrently.
Default implementation simply divides the range into chunks with size specified by granularity and submits them into the scheduler. It can be overriden by the derived class to provide an optimized variant of the parallel for.
from | First index of the processed range. |
to | One-past-last index of the processed range. |
granularity | Recommended size of the chunks passed to the functor. |
functor | Functor executed concurrently by the worker threads. Takes the first and the one-past-last index of the chunk to process sequentially within the thread. |
Reimplemented from IScheduler.
void Tbb::setGranularity | ( | const Size | newGranularity | ) |
void Tbb::setThreadCnt | ( | const Size | numThreads | ) |
Submits a task to be potentially executed asynchronously.
Implements IScheduler.