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
78 template <
typename Config,
typename T>
81 const Config oldConfig(*
this);
96 template <
typename FunctorInternal>
99 switch (this->ActivatedBackend)
101 case BackendType::Sequential:
102 this->SequentialBackend->For(first, last, grain, fi);
104 case BackendType::STDThread:
105 this->STDThreadBackend->For(first, last, grain, fi);
107 case BackendType::TBB:
108 this->TBBBackend->For(first, last, grain, fi);
110 case BackendType::OpenMP:
111 this->OpenMPBackend->For(first, last, grain, fi);
117 template <
typename InputIt,
typename OutputIt,
typename Functor>
118 void Transform(InputIt inBegin, InputIt inEnd, OutputIt outBegin, Functor& transform)
120 switch (this->ActivatedBackend)
122 case BackendType::Sequential:
123 this->SequentialBackend->Transform(inBegin, inEnd, outBegin, transform);
125 case BackendType::STDThread:
126 this->STDThreadBackend->Transform(inBegin, inEnd, outBegin, transform);
128 case BackendType::TBB:
129 this->TBBBackend->Transform(inBegin, inEnd, outBegin, transform);
131 case BackendType::OpenMP:
132 this->OpenMPBackend->Transform(inBegin, inEnd, outBegin, transform);
138 template <
typename InputIt1,
typename InputIt2,
typename OutputIt,
typename Functor>
140 InputIt1 inBegin1, InputIt1 inEnd, InputIt2 inBegin2, OutputIt outBegin, Functor& transform)
142 switch (this->ActivatedBackend)
144 case BackendType::Sequential:
145 this->SequentialBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
147 case BackendType::STDThread:
148 this->STDThreadBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
150 case BackendType::TBB:
151 this->TBBBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
153 case BackendType::OpenMP:
154 this->OpenMPBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
160 template <
typename Iterator,
typename T>
161 void Fill(Iterator begin, Iterator end,
const T& value)
163 switch (this->ActivatedBackend)
165 case BackendType::Sequential:
166 this->SequentialBackend->Fill(begin, end, value);
168 case BackendType::STDThread:
169 this->STDThreadBackend->Fill(begin, end, value);
171 case BackendType::TBB:
172 this->TBBBackend->Fill(begin, end, value);
174 case BackendType::OpenMP:
175 this->OpenMPBackend->Fill(begin, end, value);
181 template <
typename RandomAccessIterator>
182 void Sort(RandomAccessIterator begin, RandomAccessIterator end)
184 switch (this->ActivatedBackend)
186 case BackendType::Sequential:
187 this->SequentialBackend->Sort(begin, end);
189 case BackendType::STDThread:
190 this->STDThreadBackend->Sort(begin, end);
192 case BackendType::TBB:
193 this->TBBBackend->Sort(begin, end);
195 case BackendType::OpenMP:
196 this->OpenMPBackend->Sort(begin, end);
202 template <
typename RandomAccessIterator,
typename Compare>
203 void Sort(RandomAccessIterator begin, RandomAccessIterator end, Compare comp)
205 switch (this->ActivatedBackend)
207 case BackendType::Sequential:
208 this->SequentialBackend->Sort(begin, end, comp);
210 case BackendType::STDThread:
211 this->STDThreadBackend->Sort(begin, end, comp);
213 case BackendType::TBB:
214 this->TBBBackend->Sort(begin, end, comp);
216 case BackendType::OpenMP:
217 this->OpenMPBackend->Sort(begin, end, comp);
239 void RefreshNumberOfThread();
244 template <
typename Config>
247 this->Initialize(config.MaxNumberOfThreads);
248 this->SetBackend(config.Backend.c_str());
249 this->SetNestedParallelism(config.NestedParallelism);
261 int DesiredNumberOfThread = 0;
266#if VTK_SMP_ENABLE_SEQUENTIAL
267 std::unique_ptr<vtkSMPToolsImpl<BackendType::Sequential>> SequentialBackend;
269 std::unique_ptr<vtkSMPToolsDefaultImpl> SequentialBackend;
275#if VTK_SMP_ENABLE_STDTHREAD
276 std::unique_ptr<vtkSMPToolsImpl<BackendType::STDThread>> STDThreadBackend;
278 std::unique_ptr<vtkSMPToolsDefaultImpl> STDThreadBackend;
284#if VTK_SMP_ENABLE_TBB
285 std::unique_ptr<vtkSMPToolsImpl<BackendType::TBB>> TBBBackend;
287 std::unique_ptr<vtkSMPToolsDefaultImpl> TBBBackend;
293#if VTK_SMP_ENABLE_OPENMP
294 std::unique_ptr<vtkSMPToolsImpl<BackendType::OpenMP>> OpenMPBackend;
296 std::unique_ptr<vtkSMPToolsDefaultImpl> OpenMPBackend;
static vtkSMPToolsAPIInitialize vtkSMPToolsAPIInitializer
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)