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
Optimizing Array.blit
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-04-04 (22:19)
From: David Baelde <david.baelde@g...>
Subject: Optimizing Array.blit
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 couldn't be as efficient as a memcpy (and saw

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) ;
  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.