From: Yaron Minsky <yminsky@gmail.com>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: "Will M. Farr" <farr@mit.edu>,
shootout-list@lists.alioth.debian.org, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Ocaml sums the harmonic series -- four ways, four benchmarks: floating point performance
Date: Sat, 15 Jan 2005 12:13:21 -0500 [thread overview]
Message-ID: <891bd3390501150913453772a4@mail.gmail.com> (raw)
In-Reply-To: <20050115115519.GA11037@yquem.inria.fr>
On Sat, 15 Jan 2005 12:55:19 +0100, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> The following slight modification of your code generates asm code that
> is closest to what a C compiler would produce:
>
> let sum_harmonic5 n =
> let sum = ref 1.0 in
> let ifloat = ref 2.0 in
> for i = 2 to n do
> sum := !sum +. 1.0/.(!ifloat);
> ifloat := !ifloat +. 1.0
> done;
> !sum +. 0.0;;
>
> The + 0.0 at the end is ugly but convinces ocamlopt that !sum is best
> kept unboxed during the loop.
That last comment is very interesting and surprising to me. I've
looked over the optimization suggestions for the compiler, and I don't
understand why that last +. convinces the compiler to unbox sum. Can
you explain why that is? Floating point performance is important to
me, and I'd like to get a better grasp on it.
(As a general matter, it would be nice to have some tools to
understand things like unboxing and inlining a little better. For
example, it would be great to have something akin to -dtypes that
outputs information with which one could check whether a certain
function call is inlined, or whether a certain float is unboxed.)
y
next prev parent reply other threads:[~2005-01-15 17:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-13 15:53 Will M. Farr
2005-01-13 17:29 ` [Caml-list] " John Prevost
2005-01-13 19:01 ` Will M. Farr
2005-01-13 20:24 ` John Prevost
2005-01-13 20:50 ` Erik de Castro Lopo
2005-01-13 21:32 ` Erik de Castro Lopo
2005-01-15 11:55 ` Xavier Leroy
2005-01-15 15:49 ` Michal Moskal
2005-01-15 17:01 ` [Caml-list] [FP performance] Ocaml sums the harmonic series Christophe TROESTLER
2005-01-15 17:13 ` Yaron Minsky [this message]
2005-01-23 2:27 ` [Caml-list] Ocaml sums the harmonic series -- four ways, four benchmarks: floating point performance Oliver Bandel
2005-01-23 6:07 ` Will M. Farr
2005-01-23 15:18 ` Oliver Bandel
2005-01-16 9:57 Philippe Lelédy
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=891bd3390501150913453772a4@mail.gmail.com \
--to=yminsky@gmail.com \
--cc=Xavier.Leroy@inria.fr \
--cc=caml-list@yquem.inria.fr \
--cc=farr@mit.edu \
--cc=shootout-list@lists.alioth.debian.org \
--cc=yminsky@cs.cornell.edu \
/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