16#ifndef vtkSMPToolsAPI_h
17#define vtkSMPToolsAPI_h
19#include "vtkCommonCoreModule.h"
27#if VTK_SMP_ENABLE_SEQUENTIAL
28#include "SMP/Sequential/vtkSMPToolsImpl.txx"
30#if VTK_SMP_ENABLE_STDTHREAD
31#include "SMP/STDThread/vtkSMPToolsImpl.txx"
34#include "SMP/TBB/vtkSMPToolsImpl.txx"
36#if VTK_SMP_ENABLE_OPENMP
37#include "SMP/OpenMP/vtkSMPToolsImpl.txx"
83 template <
typename Config,
typename T>
86 const Config oldConfig(*
this);
101 template <
typename FunctorInternal>
104 switch (this->ActivatedBackend)
106 case BackendType::Sequential:
107 this->SequentialBackend->For(first, last, grain, fi);
109 case BackendType::STDThread:
110 this->STDThreadBackend->For(first, last, grain, fi);
112 case BackendType::TBB:
113 this->TBBBackend->For(first, last, grain, fi);
115 case BackendType::OpenMP:
116 this->OpenMPBackend->For(first, last, grain, fi);
122 template <
typename InputIt,
typename OutputIt,
typename Functor>
123 void Transform(InputIt inBegin, InputIt inEnd, OutputIt outBegin, Functor& transform)
125 switch (this->ActivatedBackend)
127 case BackendType::Sequential:
128 this->SequentialBackend->Transform(inBegin, inEnd, outBegin, transform);
130 case BackendType::STDThread:
131 this->STDThreadBackend->Transform(inBegin, inEnd, outBegin, transform);
133 case BackendType::TBB:
134 this->TBBBackend->Transform(inBegin, inEnd, outBegin, transform);
136 case BackendType::OpenMP:
137 this->OpenMPBackend->Transform(inBegin, inEnd, outBegin, transform);
143 template <
typename InputIt1,
typename InputIt2,
typename OutputIt,
typename Functor>
145 InputIt1 inBegin1, InputIt1 inEnd, InputIt2 inBegin2, OutputIt outBegin, Functor& transform)
147 switch (this->ActivatedBackend)
149 case BackendType::Sequential:
150 this->SequentialBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
152 case BackendType::STDThread:
153 this->STDThreadBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
155 case BackendType::TBB:
156 this->TBBBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
158 case BackendType::OpenMP:
159 this->OpenMPBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
165 template <
typename Iterator,
typename T>
166 void Fill(Iterator begin, Iterator end,
const T& value)
168 switch (this->ActivatedBackend)
170 case BackendType::Sequential:
171 this->SequentialBackend->Fill(begin, end, value);
173 case BackendType::STDThread:
174 this->STDThreadBackend->Fill(begin, end, value);
176 case BackendType::TBB:
177 this->TBBBackend->Fill(begin, end, value);
179 case BackendType::OpenMP:
180 this->OpenMPBackend->Fill(begin, end, value);
186 template <
typename RandomAccessIterator>
187 void Sort(RandomAccessIterator begin, RandomAccessIterator end)
189 switch (this->ActivatedBackend)
191 case BackendType::Sequential:
192 this->SequentialBackend->Sort(begin, end);
194 case BackendType::STDThread:
195 this->STDThreadBackend->Sort(begin, end);
197 case BackendType::TBB:
198 this->TBBBackend->Sort(begin, end);
200 case BackendType::OpenMP:
201 this->OpenMPBackend->Sort(begin, end);
207 template <
typename RandomAccessIterator,
typename Compare>
208 void Sort(RandomAccessIterator begin, RandomAccessIterator end, Compare comp)
210 switch (this->ActivatedBackend)
212 case BackendType::Sequential:
213 this->SequentialBackend->Sort(begin, end, comp);
215 case BackendType::STDThread:
216 this->STDThreadBackend->Sort(begin, end, comp);
218 case BackendType::TBB:
219 this->TBBBackend->Sort(begin, end, comp);
221 case BackendType::OpenMP:
222 this->OpenMPBackend->Sort(begin, end, comp);
236 void RefreshNumberOfThread();
241 template <
typename Config>
244 this->Initialize(config.MaxNumberOfThreads);
245 this->SetBackend(config.Backend.c_str());
246 this->SetNestedParallelism(config.NestedParallelism);
258 int DesiredNumberOfThread = 0;
263#if VTK_SMP_ENABLE_SEQUENTIAL
264 std::unique_ptr<vtkSMPToolsImpl<BackendType::Sequential>> SequentialBackend;
266 std::unique_ptr<vtkSMPToolsDefaultImpl> SequentialBackend;
272#if VTK_SMP_ENABLE_STDTHREAD
273 std::unique_ptr<vtkSMPToolsImpl<BackendType::STDThread>> STDThreadBackend;
275 std::unique_ptr<vtkSMPToolsDefaultImpl> STDThreadBackend;
281#if VTK_SMP_ENABLE_TBB
282 std::unique_ptr<vtkSMPToolsImpl<BackendType::TBB>> TBBBackend;
284 std::unique_ptr<vtkSMPToolsDefaultImpl> TBBBackend;
290#if VTK_SMP_ENABLE_OPENMP
291 std::unique_ptr<vtkSMPToolsImpl<BackendType::OpenMP>> OpenMPBackend;
293 std::unique_ptr<vtkSMPToolsDefaultImpl> OpenMPBackend;
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)