ITK
4.13.0
Insight Segmentation and Registration Toolkit
|
#include <itkDomainThreader.h>
Multi-threaded processing on a domain by processing sub-domains per thread.
This class uses a ThreadedDomainPartitioner as a helper to split the domain into subdomains. Each subdomain is then processed in the ThreadedExecution
method.
The data on which to perform the processing is assumed to be members of an associating class. Therefore, to perform a threaded operation in a class, the associating class usually will declare derived versions of this class as a friend class.
To use this class, at a minimum,
If a 'threaded method' is desired to perform some data processing in a class, a derived version of this class can be defined to perform the threaded operation. Since a threaded operation is relatively complex compared to a simple serial operation, a class instead of a simple method is required. Inside this class, the method to partition the data is handled, the logic for determining the number of threads is determined, and operations surrounding the threading are encapsulated into the class with the DetermineNumberOfThreadsToUse
, BeforeThreadedExecution
, ThreadedExecution
, and AfterThreadedExecution
virtual methods.
TDomainPartitioner | A class that inherits from ThreadedDomainPartitioner. |
TAssociate | The associated class that uses a derived version of this class as a "threaded method". The associated class usually declares derived version of this class as nested classes so there is easy access to its protected and private members in ThreadedExecution. |
Definition at line 66 of file itkDomainThreader.h.
Classes | |
struct | ThreadStruct |
Public Types | |
typedef TAssociate | AssociateType |
typedef SmartPointer< const Self > | ConstPointer |
typedef TDomainPartitioner | DomainPartitionerType |
typedef DomainPartitionerType::DomainType | DomainType |
typedef SmartPointer< Self > | Pointer |
typedef DomainThreader | Self |
typedef Object | Superclass |
Public Types inherited from itk::Object | |
typedef SmartPointer< const Self > | ConstPointer |
typedef SmartPointer< Self > | Pointer |
typedef Object | Self |
typedef LightObject | Superclass |
Public Types inherited from itk::LightObject | |
typedef SmartPointer< const Self > | ConstPointer |
typedef SmartPointer< Self > | Pointer |
typedef LightObject | Self |
Public Member Functions | |
void | Execute (AssociateType *enclosingClass, const DomainType &domain) |
MultiThreader * | GetMultiThreader () const |
virtual const char * | GetNameOfClass () const |
virtual ThreadIdType | GetNumberOfThreadsUsed () const |
virtual void | SetDomainPartitioner (DomainPartitionerType *_arg) |
virtual DomainPartitionerType * | GetModifiableDomainPartitioner () |
virtual const DomainPartitionerType * | GetDomainPartitioner () const |
ThreadIdType | GetMaximumNumberOfThreads () const |
void | SetMaximumNumberOfThreads (const ThreadIdType threads) |
Public Member Functions inherited from itk::Object | |
unsigned long | AddObserver (const EventObject &event, Command *) |
unsigned long | AddObserver (const EventObject &event, Command *) const |
virtual LightObject::Pointer | CreateAnother () const override |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
virtual const TimeStamp & | GetTimeStamp () const |
bool | HasObserver (const EventObject &event) const |
void | InvokeEvent (const EventObject &) |
void | InvokeEvent (const EventObject &) const |
virtual void | Modified () const |
virtual void | Register () const override |
void | RemoveAllObservers () |
void | RemoveObserver (unsigned long tag) |
void | SetDebug (bool debugFlag) const |
void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
virtual void | SetReferenceCount (int) override |
virtual void | UnRegister () const noexceptoverride |
virtual void | SetObjectName (std::string _arg) |
virtual const std::string & | GetObjectName () const |
Public Member Functions inherited from itk::LightObject | |
virtual void | Delete () |
virtual int | GetReferenceCount () const |
itkCloneMacro (Self) | |
void | Print (std::ostream &os, Indent indent=0) const |
Protected Member Functions | |
virtual void | AfterThreadedExecution () |
virtual void | BeforeThreadedExecution () |
virtual void | DetermineNumberOfThreadsUsed () |
DomainThreader () | |
virtual void | SetMultiThreader (MultiThreader *_arg) |
virtual void | ThreadedExecution (const DomainType &subdomain, const ThreadIdType threadId)=0 |
virtual | ~DomainThreader () override |
Protected Member Functions inherited from itk::Object | |
Object () | |
bool | PrintObservers (std::ostream &os, Indent indent) const |
virtual void | PrintSelf (std::ostream &os, Indent indent) const override |
virtual void | SetTimeStamp (const TimeStamp &time) |
virtual | ~Object () override |
Protected Member Functions inherited from itk::LightObject | |
virtual LightObject::Pointer | InternalClone () const |
LightObject () | |
virtual void | PrintHeader (std::ostream &os, Indent indent) const |
virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
virtual | ~LightObject () |
Static Protected Member Functions | |
static ITK_THREAD_RETURN_TYPE | ThreaderCallback (void *arg) |
Protected Attributes | |
AssociateType * | m_Associate |
Protected Attributes inherited from itk::LightObject | |
AtomicInt< int > | m_ReferenceCount |
Private Member Functions | |
void | StartThreadingSequence () |
Private Attributes | |
DomainType | m_CompleteDomain |
DomainPartitionerType::Pointer | m_DomainPartitioner |
MultiThreader::Pointer | m_MultiThreader |
ThreadIdType | m_NumberOfThreadsUsed |
Additional Inherited Members | |
Static Public Member Functions inherited from itk::Object | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool flag) |
Static Public Member Functions inherited from itk::LightObject | |
static void | BreakOnError () |
static Pointer | New () |
typedef TAssociate itk::DomainThreader< TDomainPartitioner, TAssociate >::AssociateType |
Definition at line 78 of file itkDomainThreader.h.
typedef SmartPointer< const Self > itk::DomainThreader< TDomainPartitioner, TAssociate >::ConstPointer |
Definition at line 73 of file itkDomainThreader.h.
typedef TDomainPartitioner itk::DomainThreader< TDomainPartitioner, TAssociate >::DomainPartitionerType |
Definition at line 75 of file itkDomainThreader.h.
typedef DomainPartitionerType::DomainType itk::DomainThreader< TDomainPartitioner, TAssociate >::DomainType |
Definition at line 76 of file itkDomainThreader.h.
typedef SmartPointer< Self > itk::DomainThreader< TDomainPartitioner, TAssociate >::Pointer |
Definition at line 72 of file itkDomainThreader.h.
typedef DomainThreader itk::DomainThreader< TDomainPartitioner, TAssociate >::Self |
Standard class typedefs.
Definition at line 70 of file itkDomainThreader.h.
typedef Object itk::DomainThreader< TDomainPartitioner, TAssociate >::Superclass |
Definition at line 71 of file itkDomainThreader.h.
|
protected |
|
overrideprotectedvirtual |
|
inlineprotectedvirtual |
When Execute
in run, this method is run single-threaded after ThreadedExecution
. Optionally collect results, etc. E.g. calculate the global minimum from the minimums calculated per thread.
Reimplemented in itk::LevelSetEvolutionComputeIterationThreader< WhitakerSparseLevelSetImage< TOutput, VDimension >, ThreadedIteratorRangePartitioner< WhitakerSparseLevelSetImage< TOutput, VDimension >::LayerConstIterator >, TLevelSetEvolution >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< TDomainPartitioner, TImageToImageMetricv4 >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedImageRegionPartitioner< TImageToImageMetricv4::VirtualImageDimension >, TImageToImageMetricv4 >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< TDomainPartitioner, TJointHistogramMetric >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< ThreadedImageRegionPartitioner< TJointHistogramMetric::VirtualImageDimension >, TJointHistogramMetric >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< ThreadedIndexedContainerPartitioner, TJointHistogramMetric >, and itk::LevelSetEvolutionUpdateLevelSetsThreader< LevelSetDenseImage< TImage >, ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution >.
Definition at line 137 of file itkDomainThreader.h.
|
inlineprotectedvirtual |
When Execute
is run, this method is run singled-threaded before ThreadedExecution
. Inside this method optional operations such as creating instance variables needed per thread may be performed.
Reimplemented in itk::LevelSetEvolutionComputeIterationThreader< WhitakerSparseLevelSetImage< TOutput, VDimension >, ThreadedIteratorRangePartitioner< WhitakerSparseLevelSetImage< TOutput, VDimension >::LayerConstIterator >, TLevelSetEvolution >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< TDomainPartitioner, TImageToImageMetricv4 >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedImageRegionPartitioner< TImageToImageMetricv4::VirtualImageDimension >, TImageToImageMetricv4 >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >, itk::LevelSetEvolutionUpdateLevelSetsThreader< LevelSetDenseImage< TImage >, ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< TDomainPartitioner, TJointHistogramMetric >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< ThreadedImageRegionPartitioner< TJointHistogramMetric::VirtualImageDimension >, TJointHistogramMetric >, and itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< ThreadedIndexedContainerPartitioner, TJointHistogramMetric >.
Definition at line 121 of file itkDomainThreader.h.
|
protectedvirtual |
This is evauated at the beginning of Execute() so that it can be used in BeforeThreadedExecution().
Reimplemented in itk::ProcessObject::ProcessObjectDomainThreader< TDomainPartitioner, TAssociate >.
void itk::DomainThreader< TDomainPartitioner, TAssociate >::Execute | ( | AssociateType * | enclosingClass, |
const DomainType & | domain | ||
) |
Run the multi-threaded operation on the given domain.
The domain is first partitioned by the ThreadedDomainPartitioner, then the virtual methods BeforeThreadedExecution
, ThreadedExecution
, and AfterThreadedExecution
. are run, in order.
|
virtual |
Set/Get the DomainPartitioner.
ThreadIdType itk::DomainThreader< TDomainPartitioner, TAssociate >::GetMaximumNumberOfThreads | ( | ) | const |
Convenience methods to set/get the maximum number of threads to use.
|
virtual |
Set/Get the DomainPartitioner.
MultiThreader* itk::DomainThreader< TDomainPartitioner, TAssociate >::GetMultiThreader | ( | ) | const |
Return the multithreader used by this class.
|
virtual |
Run-time type information (and related methods).
Reimplemented from itk::Object.
Reimplemented in itk::ProcessObject::ProcessObjectDomainThreader< TDomainPartitioner, TAssociate >, itk::LevelSetEvolutionComputeIterationThreader< WhitakerSparseLevelSetImage< TOutput, VDimension >, ThreadedIteratorRangePartitioner< WhitakerSparseLevelSetImage< TOutput, VDimension >::LayerConstIterator >, TLevelSetEvolution >, itk::ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >, itk::LevelSetEvolutionComputeIterationThreader< LevelSetDenseImage< TImage >, ThreadedIteratorRangePartitioner< TLevelSetEvolution::DomainMapImageFilterType::DomainMapType::const_iterator >, TLevelSetEvolution >, itk::JointHistogramMutualInformationComputeJointPDFThreader< ThreadedIndexedContainerPartitioner, TJointHistogramMetric >, itk::ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< TImageToImageMetricv4::VirtualImageDimension >, TImageToImageMetricv4 >, itk::JointHistogramMutualInformationComputeJointPDFThreader< ThreadedImageRegionPartitioner< TJointHistogramMetric::VirtualImageDimension >, TJointHistogramMetric >, itk::LevelSetEvolutionComputeIterationThreader< LevelSetDenseImage< TImage >, ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< TDomainPartitioner, TImageToImageMetricv4 >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedImageRegionPartitioner< TImageToImageMetricv4::VirtualImageDimension >, TImageToImageMetricv4 >, itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >, itk::LevelSetEvolutionUpdateLevelSetsThreader< LevelSetDenseImage< TImage >, ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution >, itk::GradientDescentOptimizerBasev4ModifyGradientByLearningRateThreaderTemplate< TInternalComputationValueType >, itk::GradientDescentOptimizerBasev4ModifyGradientByScalesThreaderTemplate< TInternalComputationValueType >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< TDomainPartitioner, TJointHistogramMetric >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< ThreadedImageRegionPartitioner< TJointHistogramMetric::VirtualImageDimension >, TJointHistogramMetric >, itk::JointHistogramMutualInformationComputeJointPDFThreaderBase< ThreadedIndexedContainerPartitioner, TJointHistogramMetric >, and itk::QuasiNewtonOptimizerv4EstimateNewtonStepThreaderTemplate< TInternalComputationValueType >.
|
virtual |
Accessor for number of threads that were actually used in the last ThreadedExecution.
|
virtual |
Set/Get the DomainPartitioner.
void itk::DomainThreader< TDomainPartitioner, TAssociate >::SetMaximumNumberOfThreads | ( | const ThreadIdType | threads | ) |
Convenience methods to set/get the maximum number of threads to use.
|
protectedvirtual |
|
private |
|
protectedpure virtual |
Do the threaded operation, somewhat like ThreadedGenerateData
in an ImageSource.
subdomain | The subdomain to operate on. |
threadId | The identifier for the current thread. Data to perform the operation on can be accessed by dereferencing this->m_Associate, which has direct access to private and protected members the enclosing class. |
Implemented in itk::ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >, and itk::JointHistogramMutualInformationComputeJointPDFThreader< ThreadedImageRegionPartitioner< TJointHistogramMetric::VirtualImageDimension >, TJointHistogramMetric >.
|
staticprotected |
Static function used as a "callback" by the MultiThreader. The threading library will call this routine for each thread, which will delegate the control to the ThreadFunctor.
|
protected |
Definition at line 146 of file itkDomainThreader.h.
|
private |
Definition at line 165 of file itkDomainThreader.h.
|
private |
Definition at line 164 of file itkDomainThreader.h.
|
private |
Definition at line 166 of file itkDomainThreader.h.
|
private |
Store the actual number of threads used, which may be less than the number allocated by the threader if the object does not split well into that number. This value is determined at the beginning of Execute()
.
Definition at line 163 of file itkDomainThreader.h.