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"
21 #if VTK_SMP_ENABLE_TBB
22 #include "SMP/TBB/vtkSMPToolsImpl.txx"
24 #if VTK_SMP_ENABLE_OPENMP
25 #include "SMP/OpenMP/vtkSMPToolsImpl.txx"
34 VTK_ABI_NAMESPACE_BEGIN
48 const char* GetBackend();
51 bool SetBackend(
const char*
type);
54 void Initialize(
int numThreads = 0);
57 int GetEstimatedNumberOfThreads();
60 void SetNestedParallelism(
bool isNested);
63 bool GetNestedParallelism();
66 bool IsParallelScope();
69 bool GetSingleThread();
75 template <
typename Config,
typename T>
78 const Config oldConfig(*
this);
93 template <
typename FunctorInternal>
96 switch (this->ActivatedBackend)
99 this->SequentialBackend->For(first, last, grain, fi);
102 this->STDThreadBackend->For(first, last, grain, fi);
105 this->TBBBackend->For(first, last, grain, fi);
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)
120 this->SequentialBackend->Transform(inBegin, inEnd, outBegin, transform);
123 this->STDThreadBackend->Transform(inBegin, inEnd, outBegin, transform);
126 this->TBBBackend->Transform(inBegin, inEnd, outBegin, transform);
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)
142 this->SequentialBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
145 this->STDThreadBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
148 this->TBBBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
151 this->OpenMPBackend->Transform(inBegin1, inEnd, inBegin2, outBegin, transform);
157 template <
typename Iterator,
typename T>
160 switch (this->ActivatedBackend)
163 this->SequentialBackend->Fill(begin, end, value);
166 this->STDThreadBackend->Fill(begin, end, value);
169 this->TBBBackend->Fill(begin, end, value);
172 this->OpenMPBackend->Fill(begin, end, value);
178 template <
typename RandomAccessIterator>
179 void Sort(RandomAccessIterator begin, RandomAccessIterator end)
181 switch (this->ActivatedBackend)
184 this->SequentialBackend->Sort(begin, end);
187 this->STDThreadBackend->Sort(begin, end);
190 this->TBBBackend->Sort(begin, end);
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)
205 this->SequentialBackend->Sort(begin, end, comp);
208 this->STDThreadBackend->Sort(begin, end, comp);
211 this->TBBBackend->Sort(begin, end, comp);
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;
289 VTK_ABI_NAMESPACE_END
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)