From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 30 19:08:06 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4009616A41F for ; Fri, 30 Dec 2005 19:08:06 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0F2243D46 for ; Fri, 30 Dec 2005 19:08:05 +0000 (GMT) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.13.4/8.13.4) with ESMTP id jBUJ7orN011180; Fri, 30 Dec 2005 11:07:50 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.13.4/8.13.1/Submit) id jBUJ7en4011166; Fri, 30 Dec 2005 11:07:40 -0800 (PST) (envelope-from sgk) Date: Fri, 30 Dec 2005 11:07:40 -0800 From: Steve Kargl To: Peter Jeremy Message-ID: <20051230190740.GA10957@troutmask.apl.washington.edu> References: <20051229224626.GA4823@troutmask.apl.washington.edu> <20051230182611.GD36631@cirb503493.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051230182611.GD36631@cirb503493.alcatel.com.au> User-Agent: Mutt/1.4.2.1i Cc: freebsd-hackers@freebsd.org Subject: Re: Implementations of sqrtl and logl X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2005 19:08:06 -0000 On Sat, Dec 31, 2005 at 05:26:12AM +1100, Peter Jeremy wrote: > On Thu, 2005-Dec-29 14:46:26 -0800, Steve Kargl wrote: > >I have implementations for sqrtl and logl, which can be added > >to libm. In limited testing on AMD64 , I find > > > >troutmask:kargl[208] ./test_sqrt > > float double long double > >MRE: 8.953800e-08 1.664855e-16 1.084202e-19 > >DDP: 7.05 15.78 18.96 > >BDP: 23.41 52.42 63.00 > ... > >MRE = maximum relative error between a value from my routine and > > a value computed using GMP/MPFR with 64-bits of precision. > > Given that long double has 64 bits of precision, is testing it against > a 64-bit test library adequate? And what is the accuracy of your test > library? > MPFR uses GMP for its internals. I set MPFR to use 64-bit precision and round-to-nearest. It is claimed that mpfr will give correctly rounded FP values in the requested precision and rounding mode. I can set MPFR to any precision and one of four rounding modes; however, the runtime of the tests will go up. I've changed my test program to use 128 bit precision. Here are the results troutmask:kargl[211] ./test_sqrt 100000000 float double long double MRE: 8.953800e-08 1.664855e-16 1.084202e-19 DDP: 7.05 15.78 18.96 BDP: 23.41 52.42 63.00 MRE: 1.084202e-19 DDP: 18.96 BDP: 63.00 To gather the stats, I need to either convert my long double result into a mpfr_t value or convert the MPFR sqrt value into a long double. I've chosen the latter. Thus, the 128-bit MPFR value is correctly rounded to a 64-bit long double. I don't understand your second question. Are you referring to MPFR?. epsilon is 2**(1 - p) where p is the precision. -- Steve