<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19258"></HEAD>
<BODY
style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space">
<DIV dir=ltr align=left><SPAN class=843014015-26072012><FONT size=2
face=Verdana>Brad,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843014015-26072012><FONT size=2
face=Verdana></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=843014015-26072012><FONT size=2
face=Verdana>The false sharing possibility is very interesting. I'll look
to see if this may be effecting performance in the v4 metrics, where I provide
an array of pre-allocated, per-thread Jacobian objects to avoid
instantiation of the Jacobian object at each point.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=843014015-26072012></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=843014015-26072012><FONT size=2
face=Verdana>-M</FONT> </SPAN></DIV><BR>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> insight-developers-bounces@itk.org
[mailto:insight-developers-bounces@itk.org] <B>On Behalf Of </B>Bradley
Lowekamp<BR><B>Sent:</B> Wednesday, July 25, 2012 5:19 PM<BR><B>To:</B> Rupert
Brooks<BR><B>Cc:</B> Insight Developers<BR><B>Subject:</B> Re:
[Insight-developers] itk performance numbers<BR></FONT><BR></DIV>
<DIV></DIV>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><BR></DIV>
<DIV><BR>
<DIV>
<DIV>On Jul 25, 2012, at 4:31 PM, Rupert Brooks wrote:</DIV><BR
class=Apple-interchange-newline>
<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">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
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>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 class=im>
<DIV><BR></DIV>
<DIV>Rupert</DIV>
<DIV><BR></DIV>
<DIV><snipped></DIV></DIV></DIV></BLOCKQUOTE></DIV></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></BODY></HTML>