From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id EBC5BBC0A for ; Thu, 5 Apr 2007 00:19:56 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l34MJunE012695 for ; Thu, 5 Apr 2007 00:19:56 +0200 Received: by ug-out-1314.google.com with SMTP id k3so853680ugf for ; Wed, 04 Apr 2007 15:19:52 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=HanI4dz27T6rfgjEkOjf6KuuOwykUWRQmX19B8xb8xdeou+JgdXHKy5PL2tezaG4nHIaIRSz2Kvj1wpmpMxOOtAXlEZjyg0YhW5082NvDZt0jW27oCGftsXpVwTJx4xcs/54oQs7L1turPjYXh6qclWkxh8MQ4e/ewreMM9pGwY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=puJgOQSicz2P85R2GTCbpk4NZvDeAs/2W3Dxo+4M+Y2uS826C6CLQ76y4fadDWFP991jW5VXmha/dlURWgwT+j6aSF9sIU6yV8eYrN4jvndAQzbKQ+2uCApdt3S2WBmKun6IJszecwRaenryjGn1zvnUERITUuuuGLzGrtL60Ik= Received: by 10.114.39.16 with SMTP id m16mr426053wam.1175725191789; Wed, 04 Apr 2007 15:19:51 -0700 (PDT) Received: by 10.114.211.2 with HTTP; Wed, 4 Apr 2007 15:19:51 -0700 (PDT) Message-ID: <53c655920704041519t77930d38y52003888139b9d2c@mail.gmail.com> Date: Thu, 5 Apr 2007 00:19:51 +0200 From: "David Baelde" Reply-To: david.baelde@ens-lyon.org To: "OCaml Mailing List" Subject: Optimizing Array.blit MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 4614248C.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 4614248C.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; blit:01 ocamlopt:01 blits:01 blits:01 computations:01 memcpy:01 blit:01 arrays:01 internals:01 ocaml:01 camlprim:01 val:01 val:01 memcpy:01 sizeof:01 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