A little Py Vs C++

Jens Mueller jens.k.mueller at gmx.de
Fri Nov 2 03:57:48 PDT 2012


Peter Alexander wrote:
> On Friday, 2 November 2012 at 10:24:34 UTC, Jens Mueller wrote:
> >Then I have a serious misunderstanding.
> >I thought D introduced array operations to allow the compiler to
> >generate efficient vector operations (in the long run), i.e.
> >generate
> >SIMD code. Why is this not working out?
> 
> It works fine for large vectors. For small vectors, it is
> horrendously slow.
> 
> The syntax a[] += b[] essentially calls a function which is designed
> to work for large vectors. It has to determine alignment, load
> everything from memory, do the operations, then store it back.
> 
> The SIMD extensions allow you to define variables that are
> guaranteed to be aligned and will probably be in the right registers
> to start with. Using them, the vectors ops don't need to determine
> alignment, and often don't need to do lots of loads/stores.
> 
> Both have their purposes.

I see. But can't the alignment problem be solved by using align. Then
have the compiler emits a call that checks for alignment if none was
specified else use a faster version.

Jens


More information about the Digitalmars-d mailing list