From: "Munagala V. S. Ramanath" <ram@netcom.com>
To: axp-list@redhat.com
Subject: Re: An sqrt() experiment
Date: Tue, 26 Jan 1999 14:51:42 -0800 (PST) [thread overview]
Message-ID: <199901262251.OAA28689@netcom6.netcom.com> (raw)
> This is a bit confusing. Already for some time, the "official" libm on
> AXP/Linux **IS** based on fdlibdm !!
>
> Especially, the very old sqrt, was that single-bit-a-time version from libfdm,
> later it was replaced by an assembler version of the method you cite. libffm
> slightly improves on that. It seems strange, that you get near those figures
> with your C version. It seems likely that your timing is governed by other
> factors, but not (really) sqrt.
My C routine is not the same as the code in fdlibm; it is derived
from comments in the fdlibm code that discussed Newtons method; it
uses floating point divides but since the Alpha was supposed to be
good at floating point arithmetic, I decided to give it a try. My
code also ignores all the special cases like 0, +-inf, +-NaN etc.
as noted in my comments in the code.
> >From your code, I get about 303 ns/sqrt. However, the raw libffm speed of sqrt
> is about 120 ns !!
My code includes calls to rand() in the timing loop but since I was
only interested in comparing two versions of sqrt() on the same
platform, I didn't worry about it. For absolute timing or for
cross-platform comparisons, the rand() call needs to be taken out
of the timing loop as other respondents have noted.
I took the rand() call out and now I get something like this:
y = 666667166.458800, time = 1.877930 secs. [sqrt] <-- libm
y = 666667166.458800, time = 0.292969 secs. [sqt]
y = 666667166.458800, time = 0.146484 secs. [sqrt] <-- libffm
y = 666667166.458800, time = 0.293945 secs. [sqt]
This yields a figure of 146 ns for the libffm sqrt() which is close
to your expectation and almost 13 times faster than the stock libm!
Ram
next reply other threads:[~1999-01-26 23:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-26 22:51 Munagala V. S. Ramanath [this message]
1999-01-27 18:30 ` An sqrt() experiment Jonathan L Dubois
1999-01-28 8:17 ` Joachim Wesner
-- strict thread matches above, loose matches on Subject: below --
1999-01-28 15:18 Munagala V. S. Ramanath
1999-01-26 22:14 Munagala V. S. Ramanath
1999-01-26 22:07 Munagala V. S. Ramanath
1999-01-26 19:39 Munagala V. S. Ramanath
1999-01-26 20:05 ` Andrei A. Dergatchev
1999-01-26 20:28 ` Andrei A. Dergatchev
1999-01-26 21:20 ` Joachim Wesner
1999-01-26 22:15 ` Wes Bauske
1999-01-29 6:28 ` Richard Henderson
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox