Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Make threading related data of metrics private #645

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions Common/CostFunctions/itkParzenWindowHistogramImageToImageMetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,33 +294,6 @@ class ITK_TEMPLATE_EXPORT ParzenWindowHistogramImageToImageMetric
KernelFunctionPointer m_MovingKernel;
KernelFunctionPointer m_DerivativeMovingKernel;

/** Threading related parameters. */
mutable std::vector<JointPDFPointer> m_ThreaderJointPDFs;

/** Helper structs that multi-threads the computation of
* the metric derivative using ITK threads.
*/
struct ParzenWindowHistogramMultiThreaderParameterType // can't we use the one from AdvancedImageToImageMetric ?
{
Self * m_Metric;
};
ParzenWindowHistogramMultiThreaderParameterType m_ParzenWindowHistogramThreaderParameters;

struct ParzenWindowHistogramGetValueAndDerivativePerThreadStruct
{
SizeValueType st_NumberOfPixelsCounted;
JointPDFPointer st_JointPDF;
};
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT,
ParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct);
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct);
mutable AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct *
m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
mutable ThreadIdType m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariablesSize;

/** Initialize threading related parameters. */
void
InitializeThreadingParameters() const override;
Expand Down Expand Up @@ -505,6 +478,33 @@ class ITK_TEMPLATE_EXPORT ParzenWindowHistogramImageToImageMetric
void
operator=(const Self &) = delete;

/** Threading related parameters. */
mutable std::vector<JointPDFPointer> m_ThreaderJointPDFs;

/** Helper structs that multi-threads the computation of
* the metric derivative using ITK threads.
*/
struct ParzenWindowHistogramMultiThreaderParameterType // can't we use the one from AdvancedImageToImageMetric ?
{
Self * m_Metric;
};
ParzenWindowHistogramMultiThreaderParameterType m_ParzenWindowHistogramThreaderParameters;

struct ParzenWindowHistogramGetValueAndDerivativePerThreadStruct
{
SizeValueType st_NumberOfPixelsCounted;
JointPDFPointer st_JointPDF;
};
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT,
ParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct);
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct);
mutable AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct *
m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
mutable ThreadIdType m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariablesSize;

/** Variables that can/should be accessed by their Set/Get functions. */
unsigned long m_NumberOfFixedHistogramBins;
unsigned long m_NumberOfMovingHistogramBins;
Expand Down
48 changes: 24 additions & 24 deletions Components/Metrics/PCAMetric/itkPCAMetric_F_multithreaded.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,30 +163,6 @@ class ITK_TEMPLATE_EXPORT PCAMetric : public AdvancedImageToImageMetric<TFixedIm
const MovingImageDerivativeType & movingImageDerivative,
DerivativeType & imageJacobian) const override;

struct PCAMetricMultiThreaderParameterType
{
Self * m_Metric;
};

PCAMetricMultiThreaderParameterType m_PCAMetricThreaderParameters;

struct PCAMetricGetSamplesPerThreadStruct
{
SizeValueType st_NumberOfPixelsCounted;
MatrixType st_DataBlock;
std::vector<FixedImagePointType> st_ApprovedSamples;
DerivativeType st_Derivative;
};

itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, PCAMetricGetSamplesPerThreadStruct, PaddedPCAMetricGetSamplesPerThreadStruct);

itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
PaddedPCAMetricGetSamplesPerThreadStruct,
AlignedPCAMetricGetSamplesPerThreadStruct);

mutable AlignedPCAMetricGetSamplesPerThreadStruct * m_PCAMetricGetSamplesPerThreadVariables;
mutable ThreadIdType m_PCAMetricGetSamplesPerThreadVariablesSize;

/** Get value and derivatives for each thread. */
inline void
ThreadedGetSamples(ThreadIdType threadID);
Expand Down Expand Up @@ -224,6 +200,30 @@ class ITK_TEMPLATE_EXPORT PCAMetric : public AdvancedImageToImageMetric<TFixedIm
void
operator=(const Self &) = delete;

struct PCAMetricMultiThreaderParameterType
{
Self * m_Metric;
};

PCAMetricMultiThreaderParameterType m_PCAMetricThreaderParameters;

struct PCAMetricGetSamplesPerThreadStruct
{
SizeValueType st_NumberOfPixelsCounted;
MatrixType st_DataBlock;
std::vector<FixedImagePointType> st_ApprovedSamples;
DerivativeType st_Derivative;
};

itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, PCAMetricGetSamplesPerThreadStruct, PaddedPCAMetricGetSamplesPerThreadStruct);

itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
PaddedPCAMetricGetSamplesPerThreadStruct,
AlignedPCAMetricGetSamplesPerThreadStruct);

mutable AlignedPCAMetricGetSamplesPerThreadStruct * m_PCAMetricGetSamplesPerThreadVariables;
mutable ThreadIdType m_PCAMetricGetSamplesPerThreadVariablesSize;

unsigned int m_G;
unsigned int m_LastDimIndex;

Expand Down