A little Py Vs C++

Peter Alexander peter.alexander.au at gmail.com
Fri Nov 2 03:41:31 PDT 2012


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.


More information about the Digitalmars-d mailing list