Optimizing for SIMD: best practices?(i.e. what features are allowed?)
z
z at z.com
Sun Mar 7 18:00:57 UTC 2021
On Friday, 26 February 2021 at 03:57:12 UTC, tsbockman wrote:
>>> static foreach(size_t i; 0 .. 3/+typeof(a).length+/){
>>> distance += a[i].abs;//abs required by the caller
>
> (a * a) above is always positive for real numbers. You don't
> need the call to abs unless you're trying to guarantee that
> even nan values will have a clear sign bit.
>
I do not know why but the caller's performance nosedives whenever
there is no .abs at this particular line.(there's a 3x
difference, no joke.)
Same for assignment instead of addition, but with a 2x difference
instead.
More information about the Digitalmars-d-learn
mailing list