This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: accuracy of intrinsic SUM function
On Aug 25 2012, Steve Kargl wrote:
This is on a single AMD system, but the fastest and most accurate
method is simply to use Intel native 80-bit arithmetic for a
sequential accumulation. That makes fancy methods futile except
on non-Intel systems. However, it might well be worth doing if
it doesn't already (I haven't checked).
Of course, your 80-bit arithmetic loses at least 49-bits of precision
when you sum the contents of an array declared as 'real(16) x(10000)'.
:-)
True, but C++ isn't that functional :-) However, sum for quadruple
precision would be vastly better done by a library routine, even if
basic addition weren't! Inter alia, Kahan addition does not need
the two accumulators to be in the same precision, and you can often
get a lot of benefit by not doing so.
Indeed, on some systems, you can use the triple form with double to
give extended quadruple faster than doing the arithmetic in plain
quadruple.
Regards,
Nick Maclaren.