caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mauricio Fernandez <mfp@acm.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] OCaml image blending performance
Date: Thu, 7 Feb 2008 13:29:50 +0100	[thread overview]
Message-ID: <20080207122950.GA11491@tux-chan> (raw)
In-Reply-To: <20080207110154.GA24561@annexia.org>

On Thu, Feb 07, 2008 at 11:01:54AM +0000, Richard Jones wrote:
> On Wed, Feb 06, 2008 at 11:34:02PM +0000, Jon Harrop wrote:
> > 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.
> 
> I don't understand this.  In 'blend2.ml' (which I was responsible for)
> C macros are used to inline all the OCaml functions the same as in the
> C version.  Yet it's still 70% slower than the C version.
> 
> My suspicion was that it was to do with his use of a string as a byte
> array.

I get a 30% speedup by unrolling the BLEND loop and performing some additional
CSE (just getting rid of that extra (j_+3), actually). 

I think the major culprit is 31-bit integer arithmetic: there are lots of 
"orl $1, ...", "sarl $1, ...", decl and incl in the generated code.

If Bigarray.Array1 had unsafe_get and unsafe_set, operating on int32 values
could be faster (ocamlopt is often smart enough to do without boxed int32s).
Currently, bigarray bound checking is performed even with -unsafe, however.

-- 
Mauricio Fernandez  -   http://eigenclass.org


  parent reply	other threads:[~2008-02-07 12:30 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 [this message]
2008-02-07 15:04     ` Jon Harrop
     [not found] ` <854c25eb0802070607t4b2ed641xa3bc19e8384ce23@mail.gmail.com>
2008-02-07 14:10   ` Ilmari Heikkinen
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=20080207122950.GA11491@tux-chan \
    --to=mfp@acm.org \
    --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;
as well as URLs for NNTP newsgroup(s).