From: Alain Frisch <alain@frisch.fr>
To: Joel Reymont <joelr1@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] optimizing numerical code
Date: Wed, 18 May 2011 20:50:54 +0200 [thread overview]
Message-ID: <4DD4150E.6080400@frisch.fr> (raw)
In-Reply-To: <346B52D2-EE21-43D1-B41E-3AEB3BBF0013@gmail.com>
On 5/18/2011 8:35 PM, Joel Reymont wrote:
> Consider the following two functions that I'm trying to optimize.
>
> Why is there an allocation for every iteration of the loop in divergence1 but not in divergence2?
First, note that the compiler does indeed unbox the reference cell acc
as a local variable. It turns out that the float contained in the
reference is not itself unboxed. This is due to the heuristic used by
ocamlopt to unbox floats. Currently, a float variable is unboxed only if
all the places where its value is used are unboxing contexts. A way to
force unboxing in divergence1 is to replace (!acc) with (!acc +. 0) at
the end. Without this change, the compilers can find a use of !acc as a
boxed float (because this is what the function needs to return) and so
it decides not to unbox acc at all.
See also:
http://caml.inria.fr/mantis/view.php?id=5204
(The more_unboxing branch in the OCaml SVN implements a different
unboxing strategy.)
-- Alain
next prev parent reply other threads:[~2011-05-18 18:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 18:35 Joel Reymont
2011-05-18 18:50 ` Alain Frisch [this message]
2011-05-19 8:24 ` Alain Frisch
2011-05-19 8:37 ` Joel Reymont
2011-05-19 10:59 ` Alain Frisch
2011-05-19 12:40 ` Gerd Stolpmann
2011-06-09 9:02 ` Alain Frisch
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=4DD4150E.6080400@frisch.fr \
--to=alain@frisch.fr \
--cc=caml-list@inria.fr \
--cc=joelr1@gmail.com \
/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