<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Dumb question: wouldn't smart pointers (C++11 std::shared_ptr be an intermediate solution between std::vector and old-school manual allocation? (Not passing judgement on whether we should use std::vector<Rvec> but thinking about the options here).</div><div><br></div><div>Best,</div><div>--Peter</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Date: Wed, 23 Mar 2016 13:18:52 +0000<br>
From: Mark Abraham <<a href="mailto:mark.j.abraham@gmail.com">mark.j.abraham@gmail.com</a>><br>
To: <a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br>
Subject: Re: [gmx-developers] std::vector<Rvec> slowness<br>
Message-ID:<br>
<<a href="mailto:CAMNuMAT4GftoMf8t5uzB5o9E%2BCxFG2HEdi-JvbCDqukjXooY6w@mail.gmail.com">CAMNuMAT4GftoMf8t5uzB5o9E+CxFG2HEdi-JvbCDqukjXooY6w@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi,<br>
<br>
On Wed, Mar 23, 2016 at 1:56 PM Berk Hess <<a href="mailto:hess@kth.se">hess@kth.se</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> It's impractical and bad for performance to go from AoS to SoA.<br>
><br>
<br>
Sure, but that's what we do every MD step on typical CPUs. We do DD<br>
communication on XYZXYZXYZXYZ and then transpose them to XXXXYYYYZZZZ to<br>
use in short-ranged kernels. If we did DD communication on<br>
XXXXX....YYYYY..... ZZZZZZ.... then we still have gather-scatter overhead,<br>
but we don't have transposition in the mix.<br>
<br>
The question is now if we can fix this issue or if we should always try to<br>
> use .data() in inner-loops<br>
><br>
<br>
I think you're missing my point... we've always done a cast from rvec * to<br>
real * to pass to inner loops. :-) Using data() is a similar idea - hence<br>
my suggestion of as_real_array(theVectorOfRVecs).<br>
<br>
or if we should completely avoid std::vector<RVec> in performance sensitive<br>
> code and use good old C pointers with nasty manual allocation.<br>
><br>
<br>
Allocation is irrelevant to how one uses it. One must have a real * to be<br>
sure the compiler isn't confused. To get that from a vector, we use data().<br>
Whether the allocation of the memory is managed by std::vector or snew is<br>
immaterial.<br>
<br>
Mark<br></blockquote></div></div></div>