From: John R Harrison <johnh@ichips.intel.com>
To: caml-list@inria.fr
Cc: John Harrison <johnh@ichips.intel.com>
Subject: Re: OCaml and C math routines
Date: Fri, 13 Oct 2000 15:17:40 -0700 [thread overview]
Message-ID: <200010132217.PAA04645@dhpc0010.pdx.intel.com> (raw)
David McClain writes:
| OCaml'ers... I would be very interested to hear your response to this!
I guess I should comment, since I work closely with the people designing
math functions for various Intel architectures, and have even written a
few myself.
| Members of the SML basis committee and the Ocaml group probably can
| tell us the pros and cons of calling the native math library vs. having
| it written in ML itself.
There are (at least) three things to consider in writing a good math
library function:
* accuracy
* speed
* proper handling of exceptional cases
Getting good speed and accuracy together (or sometimes just one of them at
at a time) is often non-trivial. And even given a good basic design for the
core function, it's a serious amount of work to make all the peculiar
corner cases work sensibly, e.g. detecting overflow and underflow
correctly, behaving sensibly when unusual exceptions like "inexact" are
enabled, or even providing accurate answers when the rounding mode is not
the default of round-to-nearest or when trigonometric functions are applied
to huge arguments.
Besides, there's room for disagreement over what *should* be done in many
of the obscure cases. There's no IEEE standard for the transcendentals,
though C99 is establishing some sort of norm. In the absence of absolute
standards, there are hard trade-offs to be made between various desirable
characteristics.
So, on the one hand, it's ambitious bordering on hubristic for SML experts
who are not floating point specialists to reimplement all this stuff
themselves. On the other hand, it's certainly true that most available math
libraries have shortcomings in some area or another, so if the SML people
are able and determined enough, it would be possible in principle for them
to do better. For an idea of some of the techniques we've used at Intel in
recent math library work, you might look at the following:
"The Computation of Transcendental Functions on the IA-64 Architecture"
http://developer.intel.com/technology/itj/q41999/articles/art_5.htm
"New Algorithms for Improved Transcendental Functions on IA-64"
http://euler.ecs.umass.edu/paper/final/paper-118.ps
The original question seemed particularly focused on speed. In my
experience the really critical math functions tend to be coded in
assembler, simply because C compilers don't usually provide adequate
control or provide intrinsics to access special hardware features. For
less popular functions (like the cube root and Bessel functions), it's
common to use some portable C routines such as those in FDLIBM:
http://www.netlib.org/fdlibm
There's certainly a case for having a similar library in ML, but the case
for using it as the default for important functions is more questionable.
Cheers,
John.
next reply other threads:[~2000-10-14 12:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-13 22:17 John R Harrison [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-10-16 12:55 Dave Berry
2000-10-13 17:01 David McClain
2000-10-14 12:19 ` Xavier Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200010132217.PAA04645@dhpc0010.pdx.intel.com \
--to=johnh@ichips.intel.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox