Skip to content

Commit 1790625

Browse files
committed
ENH: make multi-threading option first class citizen
1 parent b88bb2d commit 1790625

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Core/ComponentBaseClasses/elxMetricBase.hxx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,23 @@ MetricBase< TElastix >
156156
thisAsAdvanced->SetScaleGradientWithRespectToMovingImageOrientation( wrtMoving );
157157
}
158158

159-
/** Temporary?: Use the multi-threaded version or not. Default true. */
160-
std::string tmp = this->m_Configuration->GetCommandLineArgument( "-mtm" ); // mtm: multi-threaded metrics
161-
if( tmp == "true" || tmp == "" )
159+
/** Should the metric use multi-threading? */
160+
bool useMultiThreading = true;
161+
this->GetConfiguration()->ReadParameter( useMultiThreading,
162+
"UseMultiThreadingForMetrics", this->GetComponentLabel(), level, 0 );
163+
164+
thisAsAdvanced->SetUseMultiThread( useMultiThreading );
165+
if( useMultiThreading )
162166
{
163-
thisAsAdvanced->SetUseMultiThread( true );
164-
std::string tmp2 = this->m_Configuration->GetCommandLineArgument( "-threads" );
165-
unsigned int nrOfThreads = atoi( tmp2.c_str() );
166-
if( tmp2 != "" )
167+
std::string tmp = this->m_Configuration->GetCommandLineArgument( "-threads" );
168+
if( tmp != "" )
167169
{
170+
const unsigned int nrOfThreads = atoi( tmp.c_str() );
168171
thisAsAdvanced->SetNumberOfThreads( nrOfThreads );
169172
}
170173
}
171-
else { thisAsAdvanced->SetUseMultiThread( false ); }
172174

173-
} // end Advanced metric
175+
} // end advanced metric
174176

175177
} // end BeforeEachResolutionBase()
176178

0 commit comments

Comments
 (0)