From: "David Baelde" <david.baelde@gmail.com>
To: "OCaml Mailing List" <caml-list@inria.fr>
Subject: Optimizing Array.blit
Date: Thu, 5 Apr 2007 00:19:51 +0200 [thread overview]
Message-ID: <53c655920704041519t77930d38y52003888139b9d2c@mail.gmail.com> (raw)
Hi list,
I'm developing an app (compiled with ocamlopt) which does intensive
Array.blits. I quickly realized that these blits took an absurd amount
of time compared to other computations. Then I figured out that the
code in array.ml couldn't be as efficient as a memcpy (and saw
http://caml.inria.fr/mantis/view.php?id=2787).
I tried to write a blit function in C, specialized for float arrays.
I'm not very much into the internals of OCaml, but I came up with the
following working 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) ;
memcpy(&Double_field(_dst,dst_off),&Double_field(_src,src_off),sizeof(double)*len)
;
return Val_unit ;
}
I have no idea whether or not this is valid in general, portable, etc.
Also, should I try to get a good C function or are BigArrays the
ultimate efficient solution ? I'm reluctant to change all my code just
for blits..
Thanks for any advice on that problem.
--
David
next reply other threads:[~2007-04-04 22:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-04 22:19 David Baelde [this message]
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 ` [Caml-list] " Jacques Garrigue
2007-04-10 10:08 ` 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=53c655920704041519t77930d38y52003888139b9d2c@mail.gmail.com \
--to=david.baelde@gmail.com \
--cc=caml-list@inria.fr \
--cc=david.baelde@ens-lyon.org \
/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