|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP LINKS YOU MUST CLICK ON Standards
Sun engineer's response to 'How Sun can pull out of its slump'
Consistency is key
By: Gregory V. Tarsy
Digg This!
Page 2 of 2
« previous page
There are two sources of error in the algorithm as provided in Murphy's article. The first is due to the sqrt operation, and the second is due to the addition in summing the square roots. Sqrt rounding error: the largest rounding errors for the sqrt operations should occur for the largest numbers. A one ULP error for sqrt(1,000,000,000) is on the order of 2*10^(-12). This rounding error is very small compared to the one that is possible due to the addition that follows the sqrt operations. The sum just before sqrt(1000000000) is 21081851051977.5977. A 1 ULP error in the sum value results in an error of about .0029. Huge compared to the rounding error of the sqrt operation. The SPARC-quad run shows that a lot more precision will yield the correct result. The cost as Murphy points out, is significantly more compute time. The question is, can something be done to minimize the inaccuracy without pushing storage to quad? Yes.
III) Algorithm Correcting for ErrorsThe following algorithm uses the notion of compensated summation, which deals with the rounding error that is associated with each add in the summation. ------- sqrX.c -------
#include
This program was compiled/linked with the same command, but returned results matching Correct while only taking about 20% more compute time. In the NOTES section at the end of this paper, we offer a bit more detail about compensated summation. IV) Why are some results better than SPARC?There is a clustering of systems in terms of errors, identified as RISC machines that adhere to IEEE-754 64-bit format for double precision work.The best results were from systems based on Intel's Pentium model. Pentium systems have extended precision registers, 80 bits versus SPARC's 64-bits in double. In addition, Pentium systems allow intermediate results to be kept in extended format. An explicit call is required to force the Pentium processor to keep intermediate results in 64-bit format. As the preceding section shows, the critical issue of concern here should be the precision used in the problem. As Murphy points out, the correct value was calculated using 200 digits of precision. While the results from the Pentium class machines were better, the question arguably remains: Are any of these answers bad? We contend that the answer to this question is no. Given the magnitude of the number, and the size of the error, the results are all perfectly reasonable. Finally, what should be learned from this example, is that a precision level may work for one algorithm and data set, but fail if the data changes, or if the algorithm is modified. Another interpretation of this is that the compilers of C don't have strong guarantees about what "double" means. In some versions of gcc with some compiler options, "double" can mean "80-bits" instead of 64-bits. Some of the gcc compilers might be new enough to have some C99 support so it is conceivable that double_t is being used instead of double. If one wants more accurate results without compensated summation, one should declare f as "long double" or "double_t". If one wants predictable results one can use Java, even on x86. V) IEEE-754 and Sun's ResultsIEEE 754 aids understanding where errors arise in computations by enabling us to work out what error is committed in each operation just by knowing the operands and the destination format; we need not know such system-dependent details as whether the hardware uses a guard bit or whether it chops or rounds. But IEEE 754 also obscures understanding why a particular system computes the result that it does because it allows implementations to arbitrarily choose which operations are rounded to the format the programmer specifies and which are rounded to a wider format.The one pertinent observation in Murphy's analysis of his example is that the results on SPARC systems dating back to 1989 are all the same, whereas the results on x86 systems vary in ways that are not at all obvious. NOTESA) Compensated Summation ------- sqrX.c -------
#include In the original algorithm: for(i=0;i<=1000000000;i++)
{
f+=sqrt( (double) i);
}whenever the addition is done, there are two possibilities:
With each addition, the rounding error is ignored. After a billion additions, the results are noticeable in this problem. The compensating algorithm is doing the following:
Page 2 of 2 « previous page LATEST LINUX STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||