Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Sep 2023 11:59:25 -0700
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        Alexander Leidinger <Alexander@leidinger.net>
Cc:        Paul Zimmermann <Paul.Zimmermann@inria.fr>, freebsd-hackers@freebsd.org
Subject:   Re: Accuracy of Mathematical Functions
Message-ID:  <ZRR7jaP2l_HuhM9P@troutmask.apl.washington.edu>
In-Reply-To: <8849166a6a2deb6ebc1f307d6e8a66a9@Leidinger.net>
References:  <p9u0h6ni1hwy.fsf@coriandre.loria.fr> <1395eeabc6d404997f6a09a7b39d3da5@Leidinger.net> <ZRMeBEZxce0xcA4U@troutmask.apl.washington.edu> <8849166a6a2deb6ebc1f307d6e8a66a9@Leidinger.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Sep 27, 2023 at 10:32:18AM +0200, Alexander Leidinger wrote:
> Am 2023-09-26 20:08, schrieb Steve Kargl:
> > On Tue, Sep 26, 2023 at 03:26:16PM +0200, Alexander Leidinger wrote:
> > > Am 2023-09-25 15:50, schrieb Paul Zimmermann:
> > > 
> > > > We have updated our comparison:
> > > >
> > > > https://members.loria.fr/PZimmermann/papers/accuracy.pdf
> > > >
> > > > This new update includes for the first time the FreeBSD math library,
> > > > whose accuracy is quite good, except:
> > > 
> > > I wonder how those functions/libs you tested compare in terms of
> > > speed...
> > > It would allow to provide a hint to the question
> > >   "Which lib is the fastest and fulfills the needs in terms of
> > > accuracy for
> > > the intended use-case?"
> > > 
> > > I agree that the best way to do this requires to run all libs on the
> > > same
> > > hardware and OS, which is not feasible in your approach. What may be
> > > feasible is to compare the relative performance of those subsets,
> > > which you
> > > run on the same hardware.
> > > 
> > 
> > Speed vs accuracy is always a trade-off.  Consider
> 
> Yes.
> 
> [examples]
> > The latter is more accurate, but its underlying algorithm
> > uses summation-and-carry of the ascending series.  This
> > algorithm is sensitive to compiler options, so I haven't
> > pushed it FreeBSD (, yet).
> 
> A thought just crossed my mind... should we consider to provide two ABI
> compatible math libs, one fast (and "acceptable accurate"... whatever this
> means), and one accurate (and this one being the default to link against)?
> Users then could use libmap.conf(5) to use the one according to their needs.

This is certainly possible, but implementing it across all supported
architecture might be problematic.  For float and double, FreeBSD
may be able to leverage CoreMath that Paul and his colleagues at
Inria are developing (https://core-math.gitlabpages.inria.fr/).  I
have not tried to build and test it on FreeBSD, yet.

Unfortunately, compiler options like -ffast-math and -Ofast tend
to lead users down a potentially hazardous path.  Everyone wants
their codes to run "fast".  They just don't know that "fast" might
also mean wrong.  


-- 
Steve



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZRR7jaP2l_HuhM9P>