28#ifndef itkMultiThreaderBase_h
29#define itkMultiThreaderBase_h
84extern ITKCommon_EXPORT std::ostream &
86extern ITKCommon_EXPORT std::ostream &
103struct MultiThreaderBaseGlobals;
142 itkGetConstMacro(UpdateProgress,
bool);
165#if !defined(ITK_LEGACY_REMOVE)
167 static constexpr ThreaderEnum Platform = ThreaderEnum::Platform;
168 static constexpr ThreaderEnum First = ThreaderEnum::First;
169 static constexpr ThreaderEnum Pool = ThreaderEnum::Pool;
171 static constexpr ThreaderEnum Last = ThreaderEnum::Last;
172 static constexpr ThreaderEnum Unknown = ThreaderEnum::Unknown;
185 case ThreaderEnum::Platform:
187 case ThreaderEnum::Pool:
189 case ThreaderEnum::TBB:
191 case ThreaderEnum::Unknown:
224#if !defined(ITK_LEGACY_REMOVE)
228 itkLegacyMacro(
virtual void SetNumberOfThreads(
ThreadIdType numberOfThreads))
233 itkLegacyMacro(
virtual ThreadIdType GetNumberOfThreads())
235 return this->GetNumberOfWorkUnits();
248ITK_GCC_PRAGMA_DIAG_PUSH()
249ITK_GCC_PRAGMA_DIAG(ignored
"-Wattributes")
250INTEL_PRAGMA_WARN_PUSH
251INTEL_SUPPRESS_warning_1292
253# ifdef ITK_LEGACY_SILENT
254 struct ThreadInfoStruct
256 struct [[deprecated(
"Use WorkUnitInfo, ThreadInfoStruct is deprecated since ITK 5.0")]] ThreadInfoStruct
262 ThreadIdType ThreadID;
263 ThreadIdType NumberOfThreads;
265 ThreadFunctionType ThreadFunction;
270 ITK_PROCESS_ABORTED_EXCEPTION,
276ITK_GCC_PRAGMA_DIAG_POP()
295#if !defined(ITK_LEGACY_REMOVE)
298 static constexpr ThreadExitCodeEnum ITK_EXCEPTION = ThreadExitCodeEnum::ITK_EXCEPTION;
300 ThreadExitCodeEnum::ITK_PROCESS_ABORTED_EXCEPTION;
301 static constexpr ThreadExitCodeEnum STD_EXCEPTION = ThreadExitCodeEnum::STD_EXCEPTION;
324#ifndef ITK_FUTURE_LEGACY_REMOVE
327 template <
unsigned int VDimension>
350 template <
unsigned int VDimension,
typename TFunction>
351 ITK_TEMPLATE_EXPORT
void
359 ImageRegion<VDimension> region;
360 for (unsigned int d = 0; d < VDimension; ++d)
362 region.SetIndex(d, index[d]);
363 region.SetSize(d, size[d]);
373 template <
unsigned int VDimension,
typename TFunction>
374 ITK_TEMPLATE_EXPORT
void
380 if constexpr (VDimension <= 1)
384 funcP(requestedRegion);
388 constexpr unsigned int SplitDimension = VDimension - 1;
392 for (
unsigned int splitDimension = 0, dimension = 0; dimension < VDimension; ++dimension)
394 if (dimension != restrictedDirection)
396 splitIndex[splitDimension] = requestedRegion.
GetIndex(dimension);
397 splitSize[splitDimension] = requestedRegion.
GetSize(dimension);
404 splitIndex.m_InternalArray,
405 splitSize.m_InternalArray,
407 ImageRegion<VDimension> restrictedRequestedRegion;
408 restrictedRequestedRegion.SetIndex(restrictedDirection, requestedRegion.GetIndex(restrictedDirection));
409 restrictedRequestedRegion.SetSize(restrictedDirection, requestedRegion.GetSize(restrictedDirection));
410 for (unsigned int splitDimension = 0, dimension = 0; dimension < VDimension; ++dimension)
412 if (dimension != restrictedDirection)
414 restrictedRequestedRegion.SetIndex(dimension, index[splitDimension]);
415 restrictedRequestedRegion.SetSize(dimension, size[splitDimension]);
419 funcP(restrictedRequestedRegion);
An image region represents a structured region of data.
SizeValueType GetNumberOfPixels() const
const IndexType & GetIndex() const
const SizeType & GetSize() const
Control indentation during Print() invocation.
enums for MultiThreaderBase
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ParallelizeArrayHelper(void *arg)
static bool GetGlobalDefaultUseThreadPool()
ThreadIdType m_NumberOfWorkUnits
ITK_TEMPLATE_EXPORT void ParallelizeImageRegion(const ImageRegion< VDimension > &requestedRegion, TFunction funcP, ProcessObject *filter)
MultiThreaderBaseEnums::Threader ThreaderEnum
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 void SetGlobalDefaultUseThreadPool(const bool GlobalDefaultUseThreadPool)
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)
SmartPointer< Self > Pointer
static MultiThreaderBaseGlobals * m_PimplGlobals
static ThreaderEnum ThreaderTypeFromString(std::string threaderString)
ThreadFunctionType m_SingleMethod
static ThreadIdType GetGlobalMaximumNumberOfThreads()
virtual void SetNumberOfWorkUnits(ThreadIdType numberOfWorkUnits)
SmartPointer< const Self > ConstPointer
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 ThreadIdType GetMaximumNumberOfThreads() const
virtual void SingleMethodExecute()=0
std::function< void(SizeValueType)> ArrayThreadingFunctorType
~MultiThreaderBase() override
std::function< void(const IndexValueType index[], const SizeValueType size[])> ThreadingFunctorType
ThreadIdType m_MaximumNumberOfThreads
static void SetGlobalMaximumNumberOfThreads(ThreadIdType val)
static void SetGlobalDefaultNumberOfThreads(ThreadIdType val)
virtual void ParallelizeArray(SizeValueType firstIndex, SizeValueType lastIndexPlus1, ArrayThreadingFunctorType aFunc, ProcessObject *filter)
friend class ProcessObject
std::atomic< bool > m_UpdateProgress
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implements progress tracking for a filter.
Implements transparent reference counting.
@ ITK_PROCESS_ABORTED_EXCEPTION
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned int ThreadIdType
unsigned long SizeValueType
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
void(*)(void *) ThreadFunctionType
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
MultiThreaderBaseEnums::ThreadExitCode ThreadExitCodeEnum
ThreadIdType NumberOfWorkUnits
Represent a n-dimensional size (bounds) of a n-dimensional image.
SizeValueType m_InternalArray[VDimension]