From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 26139 invoked from network); 26 Jan 1999 23:20:10 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 26 Jan 1999 23:20:10 -0000 Received: from netcom6.netcom.com (netcom6.netcom.com [192.100.81.114]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id RAA05619 for ; Tue, 26 Jan 1999 17:51:42 -0500 Received: (from ram@localhost) by netcom6.netcom.com (8.8.5-r-beta/8.8.5/(NETCOM v1.02)) id OAA28689 for axp-list@redhat.com; Tue, 26 Jan 1999 14:51:42 -0800 (PST) Date: Tue, 26 Jan 1999 14:51:42 -0800 (PST) From: "Munagala V. S. Ramanath" Message-Id: <199901262251.OAA28689@netcom6.netcom.com> To: axp-list@redhat.com Subject: Re: An sqrt() experiment > 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