VTK  9.1.0
vtkSMPToolsImpl.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkSMPToolsImpl.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
16#ifndef vtkSMPToolsImpl_h
17#define vtkSMPToolsImpl_h
18
19#include "vtkCommonCoreModule.h" // For export macro
20#include "vtkObject.h"
21#include "vtkSMP.h"
22
23#define VTK_SMP_MAX_BACKENDS_NB 4
24
25#define VTK_SMP_BACKEND_SEQUENTIAL 0
26#define VTK_SMP_BACKEND_STDTHREAD 1
27#define VTK_SMP_BACKEND_TBB 2
28#define VTK_SMP_BACKEND_OPENMP 3
29
30namespace vtk
31{
32namespace detail
33{
34namespace smp
35{
36
37enum class BackendType
38{
43};
44
45#if VTK_SMP_DEFAULT_IMPLEMENTATION_SEQUENTIAL
46const BackendType DefaultBackend = BackendType::Sequential;
47#elif VTK_SMP_DEFAULT_IMPLEMENTATION_STDTHREAD
48const BackendType DefaultBackend = BackendType::STDThread;
49#elif VTK_SMP_DEFAULT_IMPLEMENTATION_TBB
50const BackendType DefaultBackend = BackendType::TBB;
51#elif VTK_SMP_DEFAULT_IMPLEMENTATION_OPENMP
52const BackendType DefaultBackend = BackendType::OpenMP;
53#endif
54
55template <BackendType Backend>
56class VTKCOMMONCORE_EXPORT vtkSMPToolsImpl
57{
58public:
59 //--------------------------------------------------------------------------------
60 void Initialize(int numThreads = 0);
61
62 //--------------------------------------------------------------------------------
64
65 //--------------------------------------------------------------------------------
66 void SetNestedParallelism(bool isNested) { this->NestedActivated = isNested; }
67
68 //--------------------------------------------------------------------------------
69 bool GetNestedParallelism() { return this->NestedActivated; }
70
71 //--------------------------------------------------------------------------------
72 bool IsParallelScope() { return this->IsParallel; }
73
74 //--------------------------------------------------------------------------------
75 template <typename FunctorInternal>
76 void For(vtkIdType first, vtkIdType last, vtkIdType grain, FunctorInternal& fi);
77
78 //--------------------------------------------------------------------------------
79 template <typename InputIt, typename OutputIt, typename Functor>
80 void Transform(InputIt inBegin, InputIt inEnd, OutputIt outBegin, Functor transform);
81
82 //--------------------------------------------------------------------------------
83 template <typename InputIt1, typename InputIt2, typename OutputIt, typename Functor>
85 InputIt1 inBegin1, InputIt1 inEnd, InputIt2 inBegin2, OutputIt outBegin, Functor transform);
86
87 //--------------------------------------------------------------------------------
88 template <typename Iterator, typename T>
89 void Fill(Iterator begin, Iterator end, const T& value);
90
91 //--------------------------------------------------------------------------------
92 template <typename RandomAccessIterator>
93 void Sort(RandomAccessIterator begin, RandomAccessIterator end);
94
95 //--------------------------------------------------------------------------------
96 template <typename RandomAccessIterator, typename Compare>
97 void Sort(RandomAccessIterator begin, RandomAccessIterator end, Compare comp);
98
99private:
100 bool NestedActivated = true;
101 bool IsParallel = false;
102};
103
105
106} // namespace smp
107} // namespace detail
108} // namespace vtk
109
110#endif
void Sort(RandomAccessIterator begin, RandomAccessIterator end)
void For(vtkIdType first, vtkIdType last, vtkIdType grain, FunctorInternal &fi)
void Transform(InputIt inBegin, InputIt inEnd, OutputIt outBegin, Functor transform)
void SetNestedParallelism(bool isNested)
void Sort(RandomAccessIterator begin, RandomAccessIterator end, Compare comp)
void Fill(Iterator begin, Iterator end, const T &value)
void Transform(InputIt1 inBegin1, InputIt1 inEnd, InputIt2 inBegin2, OutputIt outBegin, Functor transform)
void Initialize(int numThreads=0)
@ value
Definition: vtkX3D.h:226
void(*)(void *, vtkIdType, vtkIdType, vtkIdType) ExecuteFunctorPtrType
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
#define VTK_SMP_BACKEND_TBB
#define VTK_SMP_BACKEND_STDTHREAD
#define VTK_SMP_BACKEND_SEQUENTIAL
#define VTK_SMP_BACKEND_OPENMP
int vtkIdType
Definition: vtkType.h:332