VTK
Static Public Member Functions | List of all members
vtkSMPTools Class Reference

A set of parallel (multi-threaded) utility functions. More...

#include <vtkSMPTools.h>

Static Public Member Functions

static void Initialize (int numThreads=0)
 
static int GetEstimatedNumberOfThreads ()
 
template<typename Functor >
static void For (vtkIdType first, vtkIdType last, vtkIdType grain, Functor &f)
 
template<typename Functor >
static void For (vtkIdType first, vtkIdType last, vtkIdType grain, Functor const &f)
 
template<typename Functor >
static void For (vtkIdType first, vtkIdType last, Functor &f)
 
template<typename Functor >
static void For (vtkIdType first, vtkIdType last, Functor const &f)
 
template<typename RandomAccessIterator >
static void Sort (RandomAccessIterator begin, RandomAccessIterator end)
 
template<typename RandomAccessIterator , typename Compare >
static void Sort (RandomAccessIterator begin, RandomAccessIterator end, Compare comp)
 

Detailed Description

A set of parallel (multi-threaded) utility functions.

vtkSMPTools provides a set of utility functions that can be used to parallelize parts of VTK code using multiple threads. There are several back-end implementations of parallel functionality (currently Sequential, TBB and X-Kaapi) that actual execution is delegated to.

Tests:
vtkSMPTools (Tests)

Definition at line 140 of file vtkSMPTools.h.

Member Function Documentation

template<typename Functor >
static void vtkSMPTools::For ( vtkIdType  first,
vtkIdType  last,
vtkIdType  grain,
Functor &  f 
)
inlinestatic

Execute a for operation in parallel. First and last define the range over which to operate (which is defined by the operator). The operation executed is defined by operator() of the functor object. The grain gives the parallel engine a hint about the coarseness over which to parallelize the function (as defined by last-first of each execution of operator() ).

Definition at line 152 of file vtkSMPTools.h.

template<typename Functor >
static void vtkSMPTools::For ( vtkIdType  first,
vtkIdType  last,
vtkIdType  grain,
Functor const &  f 
)
inlinestatic

Execute a for operation in parallel. First and last define the range over which to operate (which is defined by the operator). The operation executed is defined by operator() of the functor object. The grain gives the parallel engine a hint about the coarseness over which to parallelize the function (as defined by last-first of each execution of operator() ).

Definition at line 167 of file vtkSMPTools.h.

template<typename Functor >
static void vtkSMPTools::For ( vtkIdType  first,
vtkIdType  last,
Functor &  f 
)
inlinestatic

Execute a for operation in parallel. First and last define the range over which to operate (which is defined by the operator). The operation executed is defined by operator() of the functor object. The grain gives the parallel engine a hint about the coarseness over which to parallelize the function (as defined by last-first of each execution of operator() ). Uses a default value for the grain.

Definition at line 182 of file vtkSMPTools.h.

template<typename Functor >
static void vtkSMPTools::For ( vtkIdType  first,
vtkIdType  last,
Functor const &  f 
)
inlinestatic

Execute a for operation in parallel. First and last define the range over which to operate (which is defined by the operator). The operation executed is defined by operator() of the functor object. The grain gives the parallel engine a hint about the coarseness over which to parallelize the function (as defined by last-first of each execution of operator() ). Uses a default value for the grain.

Definition at line 196 of file vtkSMPTools.h.

static void vtkSMPTools::Initialize ( int  numThreads = 0)
static

Initialize the underlying libraries for execution. This is not required as it is automatically called before the first execution of any parallel code. However, it can be used to control the maximum number of threads used when the back-end supports it (currently Simple and TBB only). Make sure to call it before any other parallel operation. When using Kaapi, use the KAAPI_CPUCOUNT env. variable to control the number of threads used in the thread pool.

static int vtkSMPTools::GetEstimatedNumberOfThreads ( )
static

Get the estimated number of threads being used by the backend. This should be used as just an estimate since the number of threads may vary dynamically and a particular task may not be executed on all the available threads.

template<typename RandomAccessIterator >
static void vtkSMPTools::Sort ( RandomAccessIterator  begin,
RandomAccessIterator  end 
)
inlinestatic

A convenience method for sorting data. It is a drop in replacement for std::sort(). Under the hood different methods are used. For example, tbb::parallel_sort is used in TBB.

Definition at line 222 of file vtkSMPTools.h.

template<typename RandomAccessIterator , typename Compare >
static void vtkSMPTools::Sort ( RandomAccessIterator  begin,
RandomAccessIterator  end,
Compare  comp 
)
inlinestatic

A convenience method for sorting data. It is a drop in replacement for std::sort(). Under the hood different methods are used. For example, tbb::parallel_sort is used in TBB. This version of Sort() takes a comparison class.

Definition at line 234 of file vtkSMPTools.h.


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