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=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3CB39BC69 for ; Tue, 10 Apr 2007 03:26:47 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3A1QjjD008285 for ; Tue, 10 Apr 2007 03:26:46 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.7) with ESMTP id l3A1QZqm018986; Tue, 10 Apr 2007 10:26:36 +0900 (JST) Date: Tue, 10 Apr 2007 10:26:30 +0900 (JST) Message-Id: <20070410.102630.63130168.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 From: Jacques Garrigue In-Reply-To: <53c655920704091713g6a7b11f4xc975e8118cd35fa1@mail.gmail.com> References: <53c655920704041519t77930d38y52003888139b9d2c@mail.gmail.com> <53c655920704091713g6a7b11f4xc975e8118cd35fa1@mail.gmail.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 461AE7D5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; blit:01 blit:01 camlprim:01 val:01 val:01 timings:01 blits:01 arrays:01 polymorphism:01 arrays:01 0.17:98 0.19:98 caml-list:01 int:01 int:01 From: "David Baelde" > 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 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