Auto-Vectorization and array/vector operations
via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 18 17:47:16 PDT 2015
On Wednesday, 15 July 2015 at 22:42:05 UTC, Steven wrote:
> Does this mean that while compilers are expected to take
> advantage of them, they currently do not, even when they have
> proper alignment? I haven't tried LDC yet, so maybe LDC does
> perform auto-vectorization and I should attempt to use LDC if I
> plan on using vector ops a lot?
If you want to use vector operations, YOU have to write the code
for it. Addition and multiplication seem like easy things to have
vectorized automatically, but it's complicated to do (I don't
know of any compiler that does a convincing and reliable job of
auto-vectorization) and likely it won't give you many of the
other useful vector operations.
Someone from a game engine company (Unreal?) held a nice talk
about how SIMD pervades their code base, including memory layout,
in order to get decent performance on the less trivial
operations, like dot product. I don't have a link though. =/
The main reason to write the SIMD code yourself is that you know
that it's going to work the way you want. There won't ever be a
case where you add one more variable to some structure and the
compiler decides it can no longer auto-vectorize a loop.
More information about the Digitalmars-d
mailing list