Good dotProduct

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jun 29 12:19:54 PDT 2010


bearophile wrote:
> There is one more thing that I have forgotten. If you have code like:
> 
> void main() {
>     double[8] a = 0.5;
>     double[8] b = 2.0;    
>     double r = dot5(a, b);
> }
> 
> then you can't be sure that 'a' and 'b' are aligned to 16 bytes (I hope they are aligned to 8).
> 
> Time ago I have suggested the simple syntax:
> align(16) double[8] b = 2.0;    
> 
> but things are not so easy:
> http://d.puremagic.com/issues/show_bug.cgi?id=2278
> 
> Bye,
> bearophile

No need to worry about that. Unaligned arrays can be handled simply by 
taking care of the stray elements by hand. The bulk of the loop will run 
at full speed.

Andrei


More information about the Digitalmars-d mailing list