28#ifndef itkMultiThreaderBase_h
29#define itkMultiThreaderBase_h
78 ITK_PROCESS_ABORTED_EXCEPTION,
84extern ITKCommon_EXPORT std::ostream &
86extern ITKCommon_EXPORT std::ostream &
104struct MultiThreaderBaseGlobals;
143 itkGetConstMacro(UpdateProgress,
bool);
161 itkLegacyMacro(
static void SetGlobalDefaultUseThreadPool(
const bool GlobalDefaultUseThreadPool);)
162 itkLegacyMacro(
static bool GetGlobalDefaultUseThreadPool();)
166#if !defined(ITK_LEGACY_REMOVE)
168 static constexpr ThreaderEnum Platform = ThreaderEnum::Platform;
169 static constexpr ThreaderEnum First = ThreaderEnum::First;
170 static constexpr ThreaderEnum Pool = ThreaderEnum::Pool;
172 static constexpr ThreaderEnum Last = ThreaderEnum::Last;
173 static constexpr ThreaderEnum Unknown = ThreaderEnum::Unknown;
186 case ThreaderEnum::Platform:
188 case ThreaderEnum::Pool:
190 case ThreaderEnum::TBB:
192 case ThreaderEnum::Unknown:
226#if !defined(ITK_LEGACY_REMOVE)
229 itkLegacyMacro(
virtual void SetNumberOfThreads(
ThreadIdType numberOfThreads))
231 this->SetMaximumNumberOfThreads(numberOfThreads);
232 this->SetNumberOfWorkUnits(this->GetMaximumNumberOfThreads());
234 itkLegacyMacro(
virtual ThreadIdType GetNumberOfThreads())
236 return this->GetNumberOfWorkUnits();
249ITK_GCC_PRAGMA_DIAG_PUSH()
250ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
251INTEL_PRAGMA_WARN_PUSH
252INTEL_SUPPRESS_warning_1292
254# ifdef ITK_LEGACY_SILENT
255 struct ThreadInfoStruct
257 struct [[deprecated("Use WorkUnitInfo, ThreadInfoStruct is deprecated since ITK 5.0")]] ThreadInfoStruct
271 ITK_PROCESS_ABORTED_EXCEPTION,
277ITK_GCC_PRAGMA_DIAG_POP()
296#if !defined(ITK_LEGACY_REMOVE)
299 static constexpr ThreadExitCodeEnum ITK_EXCEPTION = ThreadExitCodeEnum::ITK_EXCEPTION;
301 ThreadExitCodeEnum::ITK_PROCESS_ABORTED_EXCEPTION;
302 static constexpr ThreadExitCodeEnum STD_EXCEPTION = ThreadExitCodeEnum::STD_EXCEPTION;
326#ifndef ITK_FUTURE_LEGACY_REMOVE
329 template <
unsigned int VDimension>
352 template <
unsigned int VDimension,
typename TFunction>
353 ITK_TEMPLATE_EXPORT
void
356 this->ParallelizeImageRegion(
361 ImageRegion<VDimension> region;
362 for (unsigned int d = 0; d < VDimension; ++d)
364 region.SetIndex(d, index[d]);
365 region.SetSize(d, size[d]);
376 template <
unsigned int VDimension,
typename TFunction>
377 ITK_TEMPLATE_EXPORT
void
383 if constexpr (VDimension <= 1)
387 funcP(requestedRegion);
391 constexpr unsigned int SplitDimension = VDimension - 1;
395 for (
unsigned int splitDimension = 0, dimension = 0; dimension < VDimension; ++dimension)
397 if (dimension != restrictedDirection)
399 splitIndex[splitDimension] = requestedRegion.
GetIndex(dimension);
400 splitSize[splitDimension] = requestedRegion.
GetSize(dimension);
405 this->ParallelizeImageRegion(
407 splitIndex.m_InternalArray,
408 splitSize.m_InternalArray,
410 ImageRegion<VDimension> restrictedRequestedRegion;
411 restrictedRequestedRegion.SetIndex(restrictedDirection, requestedRegion.GetIndex(restrictedDirection));
412 restrictedRequestedRegion.SetSize(restrictedDirection, requestedRegion.GetSize(restrictedDirection));
413 for (unsigned int splitDimension = 0, dimension = 0; dimension < VDimension; ++dimension)
415 if (dimension != restrictedDirection)
417 restrictedRequestedRegion.SetIndex(dimension, index[splitDimension]);
418 restrictedRequestedRegion.SetSize(dimension, size[splitDimension]);
422 funcP(restrictedRequestedRegion);
492 void * m_SingleData{
nullptr };
503 std::atomic<bool> m_UpdateProgress{
true };
SizeValueType GetNumberOfPixels() const
const IndexType & GetIndex() const
const SizeType & GetSize() const
Control indentation during Print() invocation.
Light weight base class for most itk classes.
enums for MultiThreaderBase
A class for performing multithreaded execution.
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ParallelizeArrayHelper(void *arg)
ITK_TEMPLATE_EXPORT void ParallelizeImageRegion(const ImageRegion< VDimension > &requestedRegion, TFunction funcP, ProcessObject *filter)
ITK_TEMPLATE_EXPORT void ParallelizeImageRegionRestrictDirection(unsigned int restrictedDirection, const ImageRegion< VDimension > &requestedRegion, TFunction funcP, ProcessObject *filter)
virtual void SetMaximumNumberOfThreads(ThreadIdType numberOfThreads)
void SetSingleMethodAndExecute(ThreadFunctionType func, void *data)
static std::string ThreaderTypeToString(ThreaderEnum threader)
static ThreaderEnum GetGlobalDefaultThreaderPrivate()
static void SetGlobalDefaultThreaderPrivate(ThreaderEnum threaderType)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION SingleMethodProxy(void *arg)
static ThreaderEnum GetGlobalDefaultThreader()
static void SetGlobalDefaultThreader(ThreaderEnum threaderType)
static MultiThreaderBaseGlobals * m_PimplGlobals
static ThreaderEnum ThreaderTypeFromString(std::string threaderString)
static ThreadIdType GetGlobalMaximumNumberOfThreads()
virtual void SetNumberOfWorkUnits(ThreadIdType numberOfWorkUnits)
itkLegacyMacro(static void SetGlobalDefaultUseThreadPool(const bool GlobalDefaultUseThreadPool);) itkLegacyMacro(static bool GetGlobalDefaultUseThreadPool()
virtual void SetUpdateProgress(bool updates)
static ThreadIdType GetGlobalDefaultNumberOfThreadsByPlatform()
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void SetSingleMethod(ThreadFunctionType, void *data)=0
itkGetGlobalDeclarationMacro(MultiThreaderBaseGlobals, PimplGlobals)
virtual void ParallelizeImageRegion(unsigned int dimension, const IndexValueType index[], const SizeValueType size[], ThreadingFunctorType funcP, ProcessObject *filter)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ParallelizeImageRegionHelper(void *arg)
static ThreadIdType GetGlobalDefaultNumberOfThreads()
virtual void SingleMethodExecute()=0
std::function< void(SizeValueType)> ArrayThreadingFunctorType
~MultiThreaderBase() override
std::function< void(const IndexValueType index[], const SizeValueType size[])> ThreadingFunctorType
static void SetGlobalMaximumNumberOfThreads(ThreadIdType val)
static void SetGlobalDefaultNumberOfThreads(ThreadIdType val)
virtual void ParallelizeArray(SizeValueType firstIndex, SizeValueType lastIndexPlus1, ArrayThreadingFunctorType aFunc, ProcessObject *filter)
Base class for most ITK classes.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements progress tracking for a filter.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
unsigned int ThreadIdType
void(*)(void *) ThreadFunctionType
unsigned long SizeValueType
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
Represent a n-dimensional index in a n-dimensional image.
IndexValueType m_InternalArray[VDimension]
const SizeValueType firstIndex
const SizeValueType lastIndexPlus1
ArrayThreadingFunctorType functor
ThreadingFunctorType functor
const IndexValueType * index
const SizeValueType * size
ThreadExitCodeEnum ThreadExitCode
ThreadFunctionType ThreadFunction
ThreadIdType NumberOfWorkUnits
Represent a n-dimensional size (bounds) of a n-dimensional image.
SizeValueType m_InternalArray[VDimension]