4#ifndef vtkSMPToolsAPI_h
5#define vtkSMPToolsAPI_h
7#include "vtkCommonCoreModule.h"
15#if VTK_SMP_ENABLE_SEQUENTIAL
16#include "SMP/Sequential/vtkSMPToolsImpl.txx"
18#if VTK_SMP_ENABLE_STDTHREAD
19#include "SMP/STDThread/vtkSMPToolsImpl.txx"
22#include "SMP/TBB/vtkSMPToolsImpl.txx"
24#if VTK_SMP_ENABLE_OPENMP
25#include "SMP/OpenMP/vtkSMPToolsImpl.txx"
34VTK_ABI_NAMESPACE_BEGIN
75 template <
typename Config,
typename T>
78 const Config oldConfig(*
this);
93 template <
typename FunctorInternal>
96 switch (this->ActivatedBackend)
98 case BackendType::Sequential:
99 this->SequentialBackend->For(first, last, grain, fi);
101 case BackendType::STDThread:
102 this->STDThreadBackend->For(first, last, grain, fi);
104 case BackendType::TBB:
105 this->TBBBackend->For(first, last, grain, fi);
107 case BackendType::OpenMP:
108 this->OpenMPBackend->For(first, last, grain, fi);
114 template <
typename InputIt,
typename OutputIt,
typename Functor>
115 void Transform(InputIt inBegin, InputIt inEnd, OutputIt outBegin, Functor& transform)
117 switch (this->ActivatedBackend)
119 case BackendType::Sequential:
120 this->SequentialBackend->Transform(inBegin, inEnd, outBegin, transform);
122 case BackendType::STDThread:
123 this->STDThreadBackend->Transform(inBegin, inEnd, outBegin, transform);
125 case BackendType::TBB:
126 this->TBBBackend->Transform(inBegin, inEnd, outBegin, transform);
128 case BackendType::OpenMP:
129 this->OpenMPBackend->Transform(inBegin, inEnd, outBegin, transform);
135 template <
typename InputIt1,
typename InputIt2,
typename OutputIt,
typename Functor>
137 InputIt1 inBegin1, InputIt1 inEnd, InputIt2 inBegin2, OutputIt outBegin, Functor& transform)
139 switch (this->ActivatedBackend)
141 case BackendType::Sequential:
142 this->SequentialBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
144 case BackendType::STDThread:
145 this->STDThreadBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
147 case BackendType::TBB:
148 this->TBBBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
150 case BackendType::OpenMP:
151 this->OpenMPBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
157 template <
typename Iterator,
typename T>
158 void Fill(Iterator begin, Iterator end,
const T& value)
160 switch (this->ActivatedBackend)
162 case BackendType::Sequential:
163 this->SequentialBackend->Fill(begin, end, value);
165 case BackendType::STDThread:
166 this->STDThreadBackend->Fill(begin, end, value);
168 case BackendType::TBB:
169 this->TBBBackend->Fill(begin, end, value);
171 case BackendType::OpenMP:
172 this->OpenMPBackend->Fill(begin, end, value);
178 template <
typename RandomAccessIterator>
179 void Sort(RandomAccessIterator begin, RandomAccessIterator end)
181 switch (this->ActivatedBackend)
183 case BackendType::Sequential:
184 this->SequentialBackend->Sort(begin, end);
186 case BackendType::STDThread:
187 this->STDThreadBackend->Sort(begin, end);
189 case BackendType::TBB:
190 this->TBBBackend->Sort(begin, end);
192 case BackendType::OpenMP:
193 this->OpenMPBackend->Sort(begin, end);
199 template <
typename RandomAccessIterator,
typename Compare>
200 void Sort(RandomAccessIterator begin, RandomAccessIterator end, Compare comp)
202 switch (this->ActivatedBackend)
204 case BackendType::Sequential:
205 this->SequentialBackend->Sort(begin, end, comp);
207 case BackendType::STDThread:
208 this->STDThreadBackend->Sort(begin, end, comp);
210 case BackendType::TBB:
211 this->TBBBackend->Sort(begin, end, comp);
213 case BackendType::OpenMP:
214 this->OpenMPBackend->Sort(begin, end, comp);
228 void RefreshNumberOfThread();
233 template <
typename Config>
236 this->Initialize(config.MaxNumberOfThreads);
237 this->SetBackend(config.Backend.c_str());
238 this->SetNestedParallelism(config.NestedParallelism);
250 int DesiredNumberOfThread = 0;
255#if VTK_SMP_ENABLE_SEQUENTIAL
256 std::unique_ptr<vtkSMPToolsImpl<BackendType::Sequential>> SequentialBackend;
258 std::unique_ptr<vtkSMPToolsDefaultImpl> SequentialBackend;
264#if VTK_SMP_ENABLE_STDTHREAD
265 std::unique_ptr<vtkSMPToolsImpl<BackendType::STDThread>> STDThreadBackend;
267 std::unique_ptr<vtkSMPToolsDefaultImpl> STDThreadBackend;
273#if VTK_SMP_ENABLE_TBB
274 std::unique_ptr<vtkSMPToolsImpl<BackendType::TBB>> TBBBackend;
276 std::unique_ptr<vtkSMPToolsDefaultImpl> TBBBackend;
282#if VTK_SMP_ENABLE_OPENMP
283 std::unique_ptr<vtkSMPToolsImpl<BackendType::OpenMP>> OpenMPBackend;
285 std::unique_ptr<vtkSMPToolsDefaultImpl> OpenMPBackend;
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)