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

ENH: Add NumberOfWorkUnits to ElastixMain, used by CreateComponent #728

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions Core/Kernel/elxElastixMain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,16 @@ ElastixMain::CreateComponent(const ComponentDescriptionType & name)
itkExceptionMacro(<< "The following component could not be created: " << name);
}

if (m_NumberOfWorkUnits > 0)
{
const auto processObject = dynamic_cast<itk::ProcessObject *>(component.GetPointer());

if (processObject)
{
processObject->SetNumberOfWorkUnits(m_NumberOfWorkUnits);
}
}

return component;

} // end CreateComponent()
Expand Down
9 changes: 9 additions & 0 deletions Core/Kernel/elxElastixMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ class ElastixMain : public itk::Object
virtual ParameterMapType
GetTransformParametersMap() const;

void
SetNumberOfWorkUnits(const itk::ThreadIdType newValue)
{
m_NumberOfWorkUnits = newValue;
}


protected:
ElastixMain();
~ElastixMain() override;
Expand Down Expand Up @@ -399,6 +406,8 @@ class ElastixMain : public itk::Object
ElastixMain(const Self &) = delete;
void
operator=(const Self &) = delete;

itk::ThreadIdType m_NumberOfWorkUnits{ 0 };
};

} // end namespace elastix
Expand Down
1 change: 1 addition & 0 deletions Core/Main/itkElastixRegistrationMethod.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ ElastixRegistrationMethod<TFixedImage, TMovingImage>::GenerateData()

// Create new instance of ElastixMain
elx::DefaultConstruct<ElastixMainType> elastixMain;
elastixMain.SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());

// Set elastix levels
elastixMain.SetElastixLevel(i);
Expand Down
1 change: 1 addition & 0 deletions Core/Main/itkTransformixFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ TransformixFilter<TMovingImage>::GenerateData()

// Instantiate transformix
elx::DefaultConstruct<TransformixMainType> transformixMain;
transformixMain.SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());

// Setup transformix for warping input image if given
DataObjectContainerPointer inputImageContainer = nullptr;
Expand Down