caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Ilmari Heikkinen" <ilmari.heikkinen@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] OCaml image blending performance
Date: Thu, 7 Feb 2008 16:10:22 +0200	[thread overview]
Message-ID: <854c25eb0802070610t1e050875y10de0092f9eb7c4e@mail.gmail.com> (raw)
In-Reply-To: <854c25eb0802070607t4b2ed641xa3bc19e8384ce23@mail.gmail.com>

On Feb 7, 2008 1:34 AM, Jon Harrop <jon@ffconsultancy.com> wrote:
> On Wednesday 06 February 2008 20:29:05 Ilmari Heikkinen wrote:
> > The C and Caml versions don't produce the same results, but should
> > have the same amount of computation (don't take my word for it though,
> > I don't know why the results differ.)
>
> You should post working code if you want people to optimize it. I suspect
> you've incorrectly assumed that OCaml has full-width ints in this case
> because it does work here on my 64-bit machine.

Actually, it does work here as well, I probably tested earlier with extra
blend modes enabled in C. Sorry about the confusion, should've done a
more thorough test before posting.


> OCaml is not competitive here for two main reasons:
>
> . Full-size integer arithmetic is not very fast in OCaml.
> . Abstractions often cost performance in OCaml.
>
> In this case, most of the speed loss can be regained by simply aggressively
> inlining everything, which is exactly what you (ab)used C macros for in the C
> code.

The C macros were more about making the code shorter by emulating HOFs,
blend2.ml does inline everything. Coming within 2x of C with no major hackery
on this sort of code is impressive though.

--
Ilmari Heikkinen


  parent reply	other threads:[~2008-02-07 14:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06 20:29 Ilmari Heikkinen
2008-02-06 22:12 ` [Caml-list] " Pal-Kristian Engstad
2008-02-06 23:30   ` Jon Harrop
2008-02-06 23:34 ` Jon Harrop
2008-02-07 11:01   ` Richard Jones
2008-02-07 11:13     ` Dominique Martinet
2008-02-07 12:29     ` Mauricio Fernandez
2008-02-07 15:04     ` Jon Harrop
     [not found] ` <854c25eb0802070607t4b2ed641xa3bc19e8384ce23@mail.gmail.com>
2008-02-07 14:10   ` Ilmari Heikkinen [this message]
2008-02-07 14:08     ` Jon Harrop

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=854c25eb0802070610t1e050875y10de0092f9eb7c4e@mail.gmail.com \
    --to=ilmari.heikkinen@gmail.com \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).