OCCT3D OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    OSD_Parallel Class Reference

    Simple tool for code parallelization. More...

    #include <OSD_Parallel.hxx>

    Data Structures

    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...
    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...

    Static Public Member Functions

    public methods

    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 bool ToUseOcctThreads ()
     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 void SetUseOcctThreads (bool 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 int NbLogicalProcessors ()
     Returns number of logical processors.
    template<typename InputIterator, typename Functor>
    static void ForEach (InputIterator theBegin, InputIterator theEnd, const Functor &theFunctor, const bool isForceSingleThreadExecution=false, int theNbItems=-1)
     Simple primitive for parallelization of "foreach" loops, equivalent to:
    template<typename Functor>
    static void For (const int theBegin, const int theEnd, const Functor &theFunctor, const bool isForceSingleThreadExecution=false)
     Simple primitive for parallelization of "for" loops, equivalent to:

    Detailed Description

    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:

    • organize the data to be processed in a collection accessible by iteration (usually array or vector);
    • implement a functor class providing operator () accepting iterator (or index in array) that does the job;
    • call either For() or ForEach() providing begin and end iterators and a functor object.

    Iterators should satisfy requirements of STL forward iterator. Functor

    class Functor
    {
    public:
    void operator() ([processing instance]) const
    {
    //...
    }
    };

    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.

    Member Function Documentation

    ◆ For()

    template<typename Functor>
    void OSD_Parallel::For ( const int theBegin,
    const int theEnd,
    const Functor & theFunctor,
    const bool isForceSingleThreadExecution = false )
    inlinestatic

    Simple primitive for parallelization of "for" loops, equivalent to:

    for (int anIter = theBegin; anIter != theEnd; ++anIter) {
    theFunctor(anIter);
    }
    Parameters
    theBeginthe first index (inclusive)
    theEndthe last index (exclusive)
    theFunctorfunctor providing an interface "void operator(int theIndex){}" performing task for specified index
    isForceSingleThreadExecutionif true, then no threads will be created

    ◆ ForEach()

    template<typename InputIterator, typename Functor>
    void OSD_Parallel::ForEach ( InputIterator theBegin,
    InputIterator theEnd,
    const Functor & theFunctor,
    const bool isForceSingleThreadExecution = false,
    int theNbItems = -1 )
    inlinestatic

    Simple primitive for parallelization of "foreach" loops, equivalent to:

    for (auto anIter = theBegin; anIter != theEnd; ++anIter) {
    theFunctor(*anIter);
    }
    Parameters
    theBeginthe first index (inclusive)
    theEndthe last index (exclusive)
    theFunctorfunctor providing an interface "void operator(InputIterator theIter){}" performing task for specified iterator position
    isForceSingleThreadExecutionif true, then no threads will be created
    theNbItemsnumber of items passed by iterator, -1 if unknown

    ◆ NbLogicalProcessors()

    int OSD_Parallel::NbLogicalProcessors ( )
    static

    Returns number of logical processors.

    ◆ SetUseOcctThreads()

    void OSD_Parallel::SetUseOcctThreads ( bool theToUseOcct)
    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.

    ◆ ToUseOcctThreads()

    bool OSD_Parallel::ToUseOcctThreads ( )
    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.


    The documentation for this class was generated from the following file: