From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 006F8BC8E for ; Tue, 15 Feb 2005 21:50:21 +0100 (CET) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1FKoKQr003341 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 Feb 2005 21:50:20 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1D19eG-000Ehe-9T for caml-list@yquem.inria.fr; Tue, 15 Feb 2005 20:50:20 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Memory allocation nano-benchmark. Date: Tue, 15 Feb 2005 20:51:54 +0000 User-Agent: KMail/1.7.1 References: <420B7A7E.90504@or.uni-bonn.de> <1108169091.3474.16.camel@pelican.wigram> <000c01c51369$278441c0$0100a8c0@mshome.net> In-Reply-To: <000c01c51369$278441c0$0100a8c0@mshome.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200502152051.55292.jon@jdh30.plus.com> X-Miltered: at concorde with ID 4212608C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gava:01 wrote:01 -unsafe:01 ocamlopt:01 arrays:01 -unsafe:01 ocaml:01 arrays:01 bigarray:01 bigarray:01 computations:01 computations:01 ocaml:01 matrices:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Tuesday 15 February 2005 14:17, Fr=E9d=E9ric Gava wrote: > stupid question, do you use the "-unsafe" option of ocamlopt. It is better > for arrays... Having seen a physics student write a C++ program which invalidly read from= =20 a[n], resulting in him drawing scientific conclusions from physically-=20 realistic but non-deterministically- and unquantifiably-erroneous results, = I=20 strongly advise people to take the extra ~10% performance hit and use array= =20 bounds checking all the time. Indeed, I'm in the "remove -unsafe" camp. Even if OCaml only hoisted bounds= =20 checks in the simplest of cases, I think there would be a strong case for=20 removing this option. > > The code using ordinary arrays runs in 2.8 seconds, > > using bigarray 0.7 seconds. 4 x 0.7 =3D 2.8. > > > > bigarray is 4 times faster to write than three level > > ordinary array. The current array implementation is not great for large array-based=20 computations but I'm not sure that this is such a failing because I don't=20 think people should be coding large array-based computations in OCaml. Eith= er=20 use a dedicated numerical library for handling large matrices/tensors or us= e=20 a more appropriate data structure (typically a tree) to solve "the bigger"= =20 problem. The asymptotic complexity of such array based computations is rare= ly=20 good and, consequently, real-time performance is often unnecessarily poor. =2D-=20 Dr Jon D Harrop, Flying Frog Consultancy Ltd.