Brad,<div><br></div><div>The false sharing issue is a good point - however, i dont think this is the cause of the performance degradation. This part of the class (m_Threader, etc) has not changed since 3.20. (I used the optimized metrics in my 3.20 builds, so its in Review/itkOptMeanSquares....) It also does not explain the performance drop in single threaded mode.</div>
<div><br></div><div>Testing will tell... Seems like a Friday afternoon project to me, unless someone else gets there first.</div><div><br></div><div>Rupert</div><div><br clear="all">--------------------------------------------------------------<br>
Rupert Brooks<br><a href="mailto:rupert.brooks@gmail.com">rupert.brooks@gmail.com</a><br><br>
<br><br><div class="gmail_quote">On Wed, Jul 25, 2012 at 5:18 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hello,<div><br></div><div>Continuing to glance at the class.... I also see the following member variables for the MeanSquares class:</div><div><br></div><div><div> MeasureType * m_ThreaderMSE;</div>
<div> DerivativeType *m_ThreaderMSEDerivatives;</div></div><div><br></div><div>Where these are index by the thread ID and access simultaneously across the threads causes the potential for False Sharing, which can be a MAJOR problem with threaded algorithms.</div>
<div><br></div><div>I would think a good solution would be to create a per-thread data structure consisting of the Jacobin, MeasureType, and DerivativeType, plus padding to prevent false sharing, or equivalently assigning max data alignment to the structure.</div>
<div><br></div><div>Rupert, Would like to take a stab at this fix?</div><div><br></div><div>Brad</div><div><div class="h5"><div><br></div><div><br><div><div>On Jul 25, 2012, at 4:31 PM, Rupert Brooks wrote:</div><br><blockquote type="cite">
Sorry if this repeats - i just got a bounce from Insight Developers, so im trimming the message and resending....<br clear="all">--------------------------------------------------------------<br>Rupert Brooks<br><a href="mailto:rupert.brooks@gmail.com" target="_blank">rupert.brooks@gmail.com</a><br>
<br>
<br><br><div class="gmail_quote">On Wed, Jul 25, 2012 at 4:12 PM, Rupert Brooks <span dir="ltr"><<a href="mailto:rupert.brooks@gmail.com" target="_blank">rupert.brooks@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Aha. Heres around line 183 of itkTranslationTransform.<div><div><br></div><div>// Compute the Jacobian in one position</div><div>template <class TScalarType, unsigned int NDimensions></div><div>void</div><div>TranslationTransform<TScalarType, NDimensions>::ComputeJacobianWithRespectToParameters(</div>
<div> const InputPointType &,</div><div> JacobianType & jacobian) const</div><div>{</div><div> // the Jacobian is constant for this transform, and it has already been</div><div> // initialized in the constructor, so we just need to return it here.</div>
<div> jacobian = this->m_IdentityJacobian;</div><div> return;</div><div>}</div><div><br></div><div>Thats probably the culprit, although the root cause may be the reallocating of the jacobian every time through the loop.</div>
<div>
<div><br></div><div>Rupert</div><div><br></div><div><snipped></div></div></div></blockquote></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div>