From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA22876; Fri, 9 Aug 2002 10:47:27 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA23008 for ; Fri, 9 Aug 2002 10:47:26 +0200 (MET DST) Received: from uranium.btinternet.com (uranium.btinternet.com [194.73.73.89]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g798lPr08941 for ; Fri, 9 Aug 2002 10:47:25 +0200 (MET DST) Received: from host217-39-111-247.in-addr.btopenworld.com ([217.39.111.247] helo=beertje.william.bogus) by uranium.btinternet.com with esmtp (Exim 3.22 #8) id 17d5QZ-0001Kn-00; Fri, 09 Aug 2002 09:47:23 +0100 Received: (from williamc@localhost) by beertje.william.bogus (8.11.6/8.11.6/SuSE Linux 0.5) id g798oNR01542; Fri, 9 Aug 2002 09:50:23 +0100 X-Authentication-Warning: beertje.william.bogus: williamc set sender to williamc@paneris.org using -f From: William Chesters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15699.33358.975751.318231@beertje.william.bogus> Date: Fri, 9 Aug 2002 09:50:22 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Is anyone using caml for music or sound synthesis? In-Reply-To: <20020809082757.GB4942@fichte.ai.univie.ac.at> References: <20020808150134.B7570@cilantro.cs.wisc.edu> <200208082235.SAA14930@dewberry.cc.columbia.edu> <20020809011830.A702@execpc.com> <001e01c23f78$5c765700$0700a8c0@warp> <20020809082757.GB4942@fichte.ai.univie.ac.at> X-Mailer: VM 6.95 under 21.4 (patch 4) "Artificial Intelligence" XEmacs Lucid Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Markus Mottl writes: > On Fri, 09 Aug 2002, Nicolas Cannasse wrote: > > Yes but such algorithms are making a large use of float calculations, and > > ocaml float are boxed into a block, so such calcs could trigger multiples > > allocations. > > It's true that this can deteriorate performance in the general case, > but note that the compiler performs a fair amount of unboxing (e.g. > float arrays when the compiler can see the float type). This usually makes > numeric code run surprisingly fast in OCaml. If you know the details, you > can most often write your code in such a way that it performs efficiently. > Then it really isn't much worse than C. That's been my experience too. The main "gotcha" is that when you write imperative loops you should avoid using "float ref", because the polymorphism of the 'a ref type prevents float unboxing. Hence don't do let tot = ref 0. in for i = 0 to Array.length a do tot := !tot +. a.(i) done but rather type floatref = { mutable v: float } let tot = { v = 0. } in for i = 0 to Array.length a do tot.v <- tot.v +. a.(i) done The other thing to remember is that ocaml doesn't do inlining across compilation boundaries. If you bear those things in mind, though, it is fine. You could probably find cases where ocaml did better than gcc because of the latter's occasional brainstorms when it comes to register allocation. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners