<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I haven’t followed the discussion in detail, but a long time ago I remember having simliar issues in the kernels when using a list[] of rvec[] (in plain-old-c, no c++) instead of extracting the pointer and handling the multiply-by-3 manually. Could it be something similar here, e.g. that the compiler things it does not know enough about RVec rather than something going from with the outer list?</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Erik</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 23 Mar 2016, at 10:44, Berk Hess <<a href="mailto:hess@kth.se" class="">hess@kth.se</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" class="">
<div text="#000000" bgcolor="#FFFFFF" class="">
<div class="moz-cite-prefix">On 2016-03-23 10:42, Mark Abraham
wrote:<br class="">
</div>
<blockquote cite="mid:CAMNuMAT8Wgv4ZroixK-JqNxvyYhpZzWNr7R8AK4rgetgFeEjrQ@mail.gmail.com" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252" class="">
<div dir="ltr" class="">Hi,<br class="">
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Wed, Mar 23, 2016 at 9:44 AM Berk Hess <<a moz-do-not-send="true" href="mailto:hess@kth.se" class=""></a><a class="moz-txt-link-abbreviated" href="mailto:hess@kth.se">hess@kth.se</a>>
wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="">
<br class="">
Luckily Szilard does thorough testing and noticed a
performance<br class="">
degradation in change set 25 of <a moz-do-not-send="true" href="https://gerrit.gromacs.org/#/c/5232/" rel="noreferrer" target="_blank" class="">https://gerrit.gromacs.org/#/c/5232/</a>
The<br class="">
only signifcant change with respect to previous sets is
replacing C<br class="">
pointers by std::vector. I traced the performance difference
back to a<br class="">
single loop, which must have become several factors slower
to explain<br class="">
the time difference. I get the performance back when
replacing the<br class="">
vector by a pointer extracted with .data(), see below. I
looked at the<br class="">
assembly code from gcc 5.3.1 and the vector case generated
200 extra<br class="">
instructions, which makes it difficult to see what the
actual difference<br class="">
is. The pointer case uses a lot of vmovss and vaddss, which
the vector<br class="">
one does much less, but this is only serial SIMD
instruction. I thought<br class="">
that [] in vector might does bounds checking,</blockquote>
<div class=""><br class="">
</div>
<div class="">Definitely not in release builds.</div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"> but it
seems it does not.<br class="">
Can anyone explain why the vector case can be so slow?</blockquote>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
If this is a general issue (with RVec or more?), we need to
always extra<br class="">
a pointer with .data() for use in all inner-loops. This is
pretty<br class="">
annoying and difficult to enforce.<br class="">
<br class="">
Cheers,<br class="">
<br class="">
Berk<br class="">
<br class="">
const std::vector<RVec>
f_foreign =<br class="">
idt_foreign->force<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class="">This does a copy of the vector, and doesn't seem to be in
any version of this patch in gerrit. Is this what you meant
to write?</div>
</div>
</div>
</blockquote>
I tried this. But my original "vectorized" patch set took a pointer
from idt_foreign and did not copy the vector, that gives the same,
slow, performance.<br class="">
<br class="">
Berk<br class="">
<blockquote cite="mid:CAMNuMAT8Wgv4ZroixK-JqNxvyYhpZzWNr7R8AK4rgetgFeEjrQ@mail.gmail.com" type="cite" class="">
<div dir="ltr" class="">
<div class="gmail_quote">
<div class=""><br class="">
</div>
<div class="">Mark</div>
<div class=""><br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
or<br class="">
const RVec *f_foreign
=<br class="">
idt_foreign->force.data();<br class="">
<br class="">
int natom =
atomList->atom.size();<br class="">
for (int i = 0; i < natom; i++)<br class="">
{<br class="">
int ind = atomList->atom[i];<br class="">
rvec_inc(f[ind],
f_foreign[ind]);<br class="">
}<br class="">
--<br class="">
Gromacs Developers mailing list<br class="">
<br class="">
* Please search the archive at <a moz-do-not-send="true" href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" rel="noreferrer" target="_blank" class="">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a>
before posting!<br class="">
<br class="">
* Can't post? Read <a moz-do-not-send="true" href="http://www.gromacs.org/Support/Mailing_Lists" rel="noreferrer" target="_blank" class="">http://www.gromacs.org/Support/Mailing_Lists</a><br class="">
<br class="">
* For (un)subscribe requests visit<br class="">
<a moz-do-not-send="true" href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank" class="">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a>
or send a mail to <a moz-do-not-send="true" href="mailto:gmx-developers-request@gromacs.org" target="_blank" class="">gmx-developers-request@gromacs.org</a>.<br class="">
</blockquote>
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
</blockquote>
<br class="">
</div>
-- <br class="">Gromacs Developers mailing list<br class=""><br class="">* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" class="">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a> before posting!<br class=""><br class="">* Can't post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists" class="">http://www.gromacs.org/Support/Mailing_Lists</a><br class=""><br class="">* For (un)subscribe requests visit<br class=""><a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" class="">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" class="">gmx-developers-request@gromacs.org</a>.</div></blockquote></div><br class=""></div></body></html>