Open CASCADE Technology 7.8.0
|
Simple tool for code parallelization. More...
#include <OSD_Parallel.hxx>
Data Structures | |
class | FunctorInterface |
Interface class representing functor object. Intended to add polymorphic behaviour to For and ForEach functionality enabling execution of arbitrary function in parallel mode. More... | |
class | UniversalIterator |
Fixed-type iterator, implementing STL forward iterator interface, used for iteration over objects subject to parallel processing. It stores pointer to instance of polymorphic iterator inheriting from IteratorInterface, which contains actual type-specific iterator. More... | |
Static Public Member Functions | |
public methods | |
static Standard_Boolean | ToUseOcctThreads () |
Returns TRUE if OCCT threads should be used instead of auxiliary threads library; default value is FALSE if alternative library has been enabled while OCCT building and TRUE otherwise. | |
static void | SetUseOcctThreads (Standard_Boolean theToUseOcct) |
Sets if OCCT threads should be used instead of auxiliary threads library. Has no effect if OCCT has been built with no auxiliary threads library. | |
static Standard_Integer | NbLogicalProcessors () |
Returns number of logical processors. | |
template<typename InputIterator , typename Functor > | |
static void | ForEach (InputIterator theBegin, InputIterator theEnd, const Functor &theFunctor, const Standard_Boolean isForceSingleThreadExecution=Standard_False, Standard_Integer theNbItems=-1) |
Simple primitive for parallelization of "foreach" loops, equivalent to: | |
template<typename Functor > | |
static void | For (const Standard_Integer theBegin, const Standard_Integer theEnd, const Functor &theFunctor, const Standard_Boolean isForceSingleThreadExecution=Standard_False) |
Simple primitive for parallelization of "for" loops, equivalent to: | |
Simple tool for code parallelization.
OSD_Parallel class provides simple interface for parallel processing of tasks that can be formulated in terms of "for" or "foreach" loops.
To use this tool it is necessary to:
Iterators should satisfy requirements of STL forward iterator. Functor
The operator () should be implemented in a thread-safe way so that the same functor object can process different data items in parallel threads.
Iteration by index (For) is expected to be more efficient than using iterators (ForEach).
Implementation uses TBB if OCCT is built with support of TBB; otherwise it uses ad-hoc parallelization tool. In general, if TBB is available, it is more efficient to use it directly instead of using OSD_Parallel.
|
inlinestatic |
Simple primitive for parallelization of "for" loops, equivalent to:
theBegin | the first index (inclusive) |
theEnd | the last index (exclusive) |
theFunctor | functor providing an interface "void operator(int theIndex){}" performing task for specified index |
isForceSingleThreadExecution | if true, then no threads will be created |
|
inlinestatic |
Simple primitive for parallelization of "foreach" loops, equivalent to:
theBegin | the first index (inclusive) |
theEnd | the last index (exclusive) |
theFunctor | functor providing an interface "void operator(InputIterator theIter){}" performing task for specified iterator position |
isForceSingleThreadExecution | if true, then no threads will be created |
theNbItems | number of items passed by iterator, -1 if unknown |
|
static |
Returns number of logical processors.
|
static |
Sets if OCCT threads should be used instead of auxiliary threads library. Has no effect if OCCT has been built with no auxiliary threads library.
|
static |
Returns TRUE if OCCT threads should be used instead of auxiliary threads library; default value is FALSE if alternative library has been enabled while OCCT building and TRUE otherwise.