Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
OCaml image blending performance
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-07 (14:10)
From: Ilmari Heikkinen <ilmari.heikkinen@g...>
Subject: Re: [Caml-list] OCaml image blending performance
On Feb 7, 2008 1:34 AM, Jon Harrop <> 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, does inline everything. Coming within 2x of C with no major hackery
on this sort of code is impressive though.

Ilmari Heikkinen