VTK
9.1.0
|
A set of parallel (multi-threaded) utility functions. More...
#include <vtkSMPTools.h>
Classes | |
struct | Config |
Structure used to specify configuration for LocalScope() method. More... | |
Static Public Member Functions | |
static const char * | GetBackend () |
Get the backend in use. More... | |
static bool | SetBackend (const char *backend) |
/!\ This method is not thread safe. More... | |
static void | Initialize (int numThreads=0) |
/!\ This method is not thread safe. More... | |
static int | GetEstimatedNumberOfThreads () |
Get the estimated number of threads being used by the backend. More... | |
static void | SetNestedParallelism (bool isNested) |
/!\ This method is not thread safe. More... | |
static bool | GetNestedParallelism () |
Get true if the nested parallelism is enabled. More... | |
static bool | IsParallelScope () |
Return true if it is called from a parallel scope. More... | |
template<typename T > | |
static void | LocalScope (Config const &config, T &&lambda) |
/!\ This method is not thread safe. More... | |
template<typename InputIt , typename OutputIt , typename Functor > | |
static void | Transform (InputIt inBegin, InputIt inEnd, OutputIt outBegin, Functor transform) |
A convenience method for transforming data. More... | |
template<typename InputIt1 , typename InputIt2 , typename OutputIt , typename Functor > | |
static void | Transform (InputIt1 inBegin1, InputIt1 inEnd, InputIt2 inBegin2, OutputIt outBegin, Functor transform) |
A convenience method for transforming data. More... | |
template<typename Iterator , typename T > | |
static void | Fill (Iterator begin, Iterator end, const T &value) |
A convenience method for filling data. More... | |
template<typename RandomAccessIterator > | |
static void | Sort (RandomAccessIterator begin, RandomAccessIterator end) |
A convenience method for sorting data. More... | |
template<typename RandomAccessIterator , typename Compare > | |
static void | Sort (RandomAccessIterator begin, RandomAccessIterator end, Compare comp) |
A convenience method for sorting data. More... | |
template<typename Functor > | |
static void | For (vtkIdType first, vtkIdType last, vtkIdType grain, Functor &f) |
Execute a for operation in parallel. More... | |
template<typename Functor > | |
static void | For (vtkIdType first, vtkIdType last, vtkIdType grain, Functor const &f) |
Execute a for operation in parallel. More... | |
template<typename Functor > | |
static void | For (vtkIdType first, vtkIdType last, Functor &f) |
Execute a for operation in parallel. More... | |
template<typename Functor > | |
static void | For (vtkIdType first, vtkIdType last, Functor const &f) |
Execute a for operation in parallel. More... | |
template<typename Iter , typename Functor > | |
static vtk::detail::smp::resolvedNotInt< Iter > | For (Iter begin, Iter end, vtkIdType grain, Functor &f) |
Execute a for operation in parallel. More... | |
template<typename Iter , typename Functor > | |
static vtk::detail::smp::resolvedNotInt< Iter > | For (Iter begin, Iter end, vtkIdType grain, Functor const &f) |
Execute a for operation in parallel. More... | |
template<typename Iter , typename Functor > | |
static vtk::detail::smp::resolvedNotInt< Iter > | For (Iter begin, Iter end, Functor &f) |
Execute a for operation in parallel. More... | |
template<typename Iter , typename Functor > | |
static vtk::detail::smp::resolvedNotInt< Iter > | For (Iter begin, Iter end, Functor const &f) |
Execute a for operation in parallel. More... | |
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, OpenMP and STDThread) that actual execution is delegated to.
Definition at line 229 of file vtkSMPTools.h.
|
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 243 of file vtkSMPTools.h.
|
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 250 of file vtkSMPTools.h.
|
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 268 of file vtkSMPTools.h.
|
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 274 of file vtkSMPTools.h.
|
inlinestatic |
Execute a for operation in parallel.
Begin and end iterators 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() ).
Usage example:
Lambda are also supported through Functor const& function overload:
Definition at line 317 of file vtkSMPTools.h.
|
inlinestatic |
Execute a for operation in parallel.
Begin and end iterators 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() ).
Usage example:
Lambda are also supported through Functor const& function overload:
Definition at line 326 of file vtkSMPTools.h.
|
inlinestatic |
Execute a for operation in parallel.
Begin and end iterators define the range over which to operate (which is defined by the operator). The operation executed is defined by operator() of the functor object. Uses a default value for the grain.
Usage example:
Lambda are also supported through Functor const& function overload:
Definition at line 370 of file vtkSMPTools.h.
|
inlinestatic |
Execute a for operation in parallel.
Begin and end iterators define the range over which to operate (which is defined by the operator). The operation executed is defined by operator() of the functor object. Uses a default value for the grain.
Usage example:
Lambda are also supported through Functor const& function overload:
Definition at line 376 of file vtkSMPTools.h.
|
static |
Get the backend in use.
|
static |
/!\ This method is not thread safe.
Change the backend in use. The options can be: "Sequential", "STDThread", "TBB" or "OpenMP"
VTK_SMP_BACKEND_IN_USE env variable can also be used to set the default SMPTools backend, in that case SetBackend() doesn't need to be called. The backend selected with SetBackend() have the priority over VTK_SMP_BACKEND_IN_USE.
SetBackend() will return true if the backend was found and available.
|
static |
/!\ This method is not thread safe.
Initialize the underlying libraries for execution. This is not required as it is automatically defined by the libaries. However, it can be used to control the maximum number of thread used. Make sure to call it before the parallel operation.
If Initialize is called without argument it will reset to the maximum number of threads or use the VTK_SMP_MAX_THREADS env variable if it is defined.
Note: If VTK_SMP_MAX_THREADS env variable is defined the SMPTools will try to use it to set the maximum number of threads. Initialize() doesn't need to be called.
|
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.
|
static |
/!\ This method is not thread safe.
If true enable nested parallelism for underlying backends. When enabled the comportement is different for each backend:
omp_set_nested
to true so that it is supported.Default to true
|
static |
Get true if the nested parallelism is enabled.
|
static |
Return true if it is called from a parallel scope.
|
inlinestatic |
/!\ This method is not thread safe.
Change the number of threads locally within this scope and call a functor which should contains a vtkSMPTools method.
Usage example:
Definition at line 502 of file vtkSMPTools.h.
|
inlinestatic |
A convenience method for transforming data.
It is a drop in replacement for std::transform(), it does a unary operation on the input ranges. The data array must have the same length. The performed transformation is defined by operator() of the functor object.
Usage example with vtkDataArray:
Please visit vtkDataArrayRange.h documentation for more information and optimisation.
Definition at line 524 of file vtkSMPTools.h.
|
inlinestatic |
A convenience method for transforming data.
It is a drop in replacement for std::transform(), it does a binary operation on the input ranges. The data array must have the same length. The performed transformation is defined by operator() of the functor object.
Usage example with vtkDataArray:
Please visit vtkDataArrayRange.h documentation for more information and optimisation.
Definition at line 547 of file vtkSMPTools.h.
|
inlinestatic |
A convenience method for filling data.
It is a drop in replacement for std::fill(), it assign the given value to the element in ranges.
Usage example with vtkDataArray:
Please visit vtkDataArrayRange.h documentation for more information and optimisation.
Definition at line 569 of file vtkSMPTools.h.
|
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 581 of file vtkSMPTools.h.
|
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 594 of file vtkSMPTools.h.