28 #ifndef itkMultiThreaderBase_h
29 #define itkMultiThreaderBase_h
83 extern ITKCommon_EXPORT std::ostream &
85 extern ITKCommon_EXPORT std::ostream &
102 struct MultiThreaderBaseGlobals;
127 SetMaximumNumberOfThreads(
ThreadIdType numberOfThreads);
140 SetUpdateProgress(
bool updates);
141 itkGetConstMacro(UpdateProgress,
bool);
151 GetGlobalMaximumNumberOfThreads();
159 itkLegacyMacro(
static void SetGlobalDefaultUseThreadPool(
const bool GlobalDefaultUseThreadPool));
160 itkLegacyMacro(
static bool GetGlobalDefaultUseThreadPool());
164 #if !defined(ITK_LEGACY_REMOVE)
166 static constexpr
ThreaderEnum Platform = ThreaderEnum::Platform;
167 static constexpr
ThreaderEnum First = ThreaderEnum::First;
168 static constexpr
ThreaderEnum Pool = ThreaderEnum::Pool;
170 static constexpr
ThreaderEnum Last = ThreaderEnum::Last;
171 static constexpr
ThreaderEnum Unknown = ThreaderEnum::Unknown;
176 ThreaderTypeFromString(std::string threaderString);
184 case ThreaderEnum::Platform:
187 case ThreaderEnum::Pool:
190 case ThreaderEnum::TBB:
193 case ThreaderEnum::Unknown:
213 SetGlobalDefaultThreader(ThreaderEnum threaderType);
215 GetGlobalDefaultThreader();
225 GetGlobalDefaultNumberOfThreads();
228 #if !defined(ITK_LEGACY_REMOVE)
231 itkLegacyMacro(
virtual void SetNumberOfThreads(
ThreadIdType numberOfThreads))
233 this->SetMaximumNumberOfThreads(numberOfThreads);
234 this->SetNumberOfWorkUnits(this->GetMaximumNumberOfThreads());
236 itkLegacyMacro(
virtual ThreadIdType GetNumberOfThreads()) {
return this->GetNumberOfWorkUnits(); }
248 ITK_GCC_PRAGMA_DIAG_PUSH()
249 ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
250 INTEL_PRAGMA_WARN_PUSH
251 INTEL_SUPPRESS_warning_1292
253 CLANG_SUPPRESS_Wc__14_extensions
255 # ifdef ITK_LEGACY_SILENT
256 struct ThreadInfoStruct
258 struct [[deprecated("Use WorkUnitInfo, ThreadInfoStruct is deprecated since ITK 5.0")]] ThreadInfoStruct
262 INTEL_PRAGMA_WARN_POP
273 ITK_PROCESS_ABORTED_EXCEPTION,
279 ITK_GCC_PRAGMA_DIAG_POP()
281 #endif // ITK_LEGACY_REMOVE
298 #if !defined(ITK_LEGACY_REMOVE)
301 static constexpr
ThreadExitCodeEnum ITK_EXCEPTION = ThreadExitCodeEnum::ITK_EXCEPTION;
303 ThreadExitCodeEnum::ITK_PROCESS_ABORTED_EXCEPTION;
304 static constexpr
ThreadExitCodeEnum STD_EXCEPTION = ThreadExitCodeEnum::STD_EXCEPTION;
315 SingleMethodExecute() = 0;
324 template <
unsigned int VDimension>
343 template <
unsigned int VDimension>
344 ITK_TEMPLATE_EXPORT
void
349 this->ParallelizeImageRegion(
355 for (
unsigned int d = 0; d < VDimension; ++d)
369 template <
unsigned int VDimension>
370 ITK_TEMPLATE_EXPORT
void
380 funcP(requestedRegion);
384 constexpr
unsigned int SplitDimension = (VDimension - 1) ? VDimension - 1 : VDimension;
387 SplitRegionType splitRegion;
388 for (
unsigned int splitDimension = 0, dimension = 0; dimension < VDimension; ++dimension)
390 if (dimension == restrictedDirection)
395 splitRegion.SetSize(splitDimension, requestedRegion.
GetSize(dimension));
399 this->ParallelizeImageRegion(
401 splitRegion.GetIndex().m_InternalArray,
402 splitRegion.GetSize().m_InternalArray,
405 restrictedRequestedRegion.
SetIndex(restrictedDirection, requestedRegion.
GetIndex(restrictedDirection));
406 restrictedRequestedRegion.
SetSize(restrictedDirection, requestedRegion.
GetSize(restrictedDirection));
407 for (
unsigned int splitDimension = 0, dimension = 0; dimension < VDimension; ++dimension)
409 if (dimension == restrictedDirection)
413 restrictedRequestedRegion.
SetIndex(dimension, index[splitDimension]);
414 restrictedRequestedRegion.
SetSize(dimension, size[splitDimension]);
417 funcP(restrictedRequestedRegion);
426 ParallelizeImageRegion(
unsigned int dimension,
429 ThreadingFunctorType funcP,
436 PrintSelf(std::ostream & os,
Indent indent)
const override;
447 ParallelizeArrayHelper(
void * arg);
460 ParallelizeImageRegionHelper(
void * arg);
482 SingleMethodProxy(
void * arg);
488 void * m_SingleData{
nullptr };
494 bool m_UpdateProgress{
true };
504 GetGlobalDefaultNumberOfThreadsByPlatform();