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 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 7836BBC69 for ; Sat, 5 Jan 2008 19:09:49 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq4HABJWf0dDWxLC/2dsb2JhbACBV6gm X-IronPort-AV: E=Sophos;i="4.24,248,1196636400"; d="scan'208";a="7467394" Received: from ip67-91-18-194.z18-91-67.customer.algx.net (HELO server1.bertec.net) ([67.91.18.194]) by mail3-smtp-sop.national.inria.fr with ESMTP; 05 Jan 2008 19:09:48 +0100 Received: from kuba.bertec.net (kuba.bertec.net [192.168.2.16]) by server1.bertec.net (Postfix) with ESMTP id 17ADC105830 for ; Sat, 5 Jan 2008 13:09:47 -0500 (EST) From: Kuba Ober To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Performance questions, -inline, ... Date: Sat, 5 Jan 2008 13:09:45 -0500 User-Agent: KMail/1.9.6 (enterprise 0.20071123.740460) References: <200801031128.30183.ober.14@osu.edu> <1199380305.6057.13.camel@thelema-laptop> In-Reply-To: <1199380305.6057.13.camel@thelema-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801051309.45692.ober.14@osu.edu> X-Spam: no; 0.00; -inline:01 vectors:01 sqrt:01 arrays:01 compiler:01 cheers:01 executes:01 caml-list:01 loops:02 len:02 floats:02 element:03 parameters:03 let:03 let:03 > how about: > > (* generic vector operation *) > let op2 op a b nloop = > let len = Array.length a in > for j = 0 to nloop do > for i = 0 to len-1 do > b.(i) <- op a.(i) b.(i) > done; > done > > let add4 = op2 (+.) This doesn't change a thing, as I've said the code is part of a larger benchmark, that's why there are some unused parameters etc. They have no effect on performance. > Why does your code have the j loops? Simply to execute the operation Array.length ^ 2 times :) > You add a constant (or vector > element) a number of times equal to the length of your vector? No, equal to the square of it. I didn't want to have too big vectors. The stuff executes floor(sqrt(50e6)) times. > Arrays of floats have some optimizations built in to the compiler (no > boxing, even though they're not 31-bit values), so you should get as > good performance as you'll get. Are you saying that it may be faster to use a one-element array than a ref? That'd be curious at best, and a WTF otherwise ;) Cheers, Kuba