On Mon, 7 Nov 2005, Rustam Muginov wrote:
> After a cycle, i am adding partial sums in the following way:
> vSum = vec_add( vec_add( vSum0, vSum1 ), vec_add( vSum2, vSum3 ) );
>
Yes, that's what I had in mind.
> But now modified function gives different results, comparing with
> original one.
That is to be expected. Floating point computation, unlike mathematically
precise arithmetic, is sensitive to the order in which values are summed
up. However, the precision can only improve when you introduce more
partial sum variables. That's because the magnitude of each individual
accumulator is smaller, hence there is more overlap of mantissa bits
between accumulator and each summand. (Assuming you add only positive
values.)
> Sometimes the relative error is rather high, like 11% or so.
That does sound like way too much.
> I think i did something wrong with shifting to partial sums, but i can
> not guess what.
>
When that happens to me, it is usually a stupid mistake like forgetting to
rename a variable in the tail loop, when its meaning has slightly changed
in the main loop. Or something like that. Take a walk, and look at the
code again in an hour with a fresh mind. :-)
Holger
_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden
This email sent to email@hidden