caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: david.baelde@ens-lyon.org, david.baelde@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: Optimizing Array.blit
Date: Tue, 10 Apr 2007 10:26:30 +0900 (JST)	[thread overview]
Message-ID: <20070410.102630.63130168.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <53c655920704091713g6a7b11f4xc975e8118cd35fa1@mail.gmail.com>

From: "David Baelde" <david.baelde@gmail.com>
> To answer the question by myself, I have ran a few tests. It turned
> out that specializing Array.blit provides a significant boost, but
> doing such an ugly hack was dangerous and unnecessary. I now use the
> following standard code:
> 
> CAMLprim value caml_float_array_blit(value _src, value _src_off,
>                                      value _dst, value _dst_off, value _len) {
>   int src_off = Int_val(_src_off) ;
>   int dst_off = Int_val(_dst_off) ;
>   int len = Int_val(_len) ;
>   int i ;
>   for (i=0 ; i<len ; i++)
>     Store_double_field(_dst,dst_off+i,Double_field(_src,src_off+i)) ;
>   return Val_unit ;
> }
> 
> I got the following timings in seconds for a program doing intensive
> blits on float arrays: 0.17 for the ugly hack, 0.19 for the clean C
> function, 1.04 for the standard Array.blit.

Did you try taking the version from the standard library, and
annotating it with (a1 : float array)?
No ugly hack here: everything is 100% safe.
Personally, I get a 4 fold improvement just doing that.
Sometimes polymorphism is costly (particularly with arrays.)

Jacques Garrigue


  reply	other threads:[~2007-04-10  1:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-04 22:19 David Baelde
2007-04-05 17:56 ` [Caml-list] " Tom
2007-04-05 21:54   ` Florian Weimer
2007-04-06  7:00     ` David Baelde
2007-04-10  0:13 ` David Baelde
2007-04-10  1:26   ` Jacques Garrigue [this message]
2007-04-10 10:08     ` [Caml-list] " David Baelde

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=20070410.102630.63130168.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=david.baelde@ens-lyon.org \
    --cc=david.baelde@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;
as well as URLs for NNTP newsgroup(s).