how to pass/return Vc::Vector arguments to a function?
Matthias Kretz
[please enable javascript to see the address]
Thu Nov 10 00:03:27 CET 2016
On Mittwoch, 9. November 2016 13:06:30 CET you wrote:
> > BTW, is there significant data parallel work on the outer loop, too? In
> > this case you might consider vectorising the outer loop.
>
> there is, and in fact more than in the inner loop, thanks for pointing that
> out. the problem is that then i may be updating the same atom several
> times simultaneously, and i will need atomic operations…, i might give it a
> try though.
Have you considered double-buffering. E.g.
state1 = initial_state();
while (...) {
state2 = timestep(state1);
state1 = timestep(state2);
}
That way you have one read-only and one write-only set of atoms. You'd get
different results, but not necessarily less correct ones, no?
Alternatively, you can switch vectorization direction. I.e. vectorize the
outer loop and keep the inner loop vectorization as is. When calling the inner
loop, loop over the scalars in the Vc::Vectors of the outer loop. (Possibly,
using a mask, like this:
for (int i : where(x > 0)) {
// i will be all the indexes where x[i] > 0
inner(x[i]);
}
)
Cheers,
Matthias
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://kretzfamily.de
GSI Helmholtzzentrum für Schwerionenforschung https://gsi.de
SIMD easy and portable https://github.com/VcDevel/Vc
──────────────────────────────────────────────────────────────────────────
More information about the Vc
mailing list