On 02/11/12 11:57, Jens Mueller wrote:
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.

No. For SIMD, you cannot afford to have even a single machine instruction inserted, or the benefit is entirely lost.


Reply via email to