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 XAA23590; Sun, 20 Oct 2002 23:58:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA23806 for ; Sun, 20 Oct 2002 23:58:15 +0200 (MET DST) Received: from pop9.ucdavis.edu (pop9.ucdavis.edu [169.237.105.19]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9KLwE509984 for ; Sun, 20 Oct 2002 23:58:14 +0200 (MET DST) Received: from beech (mail@[128.120.141.217]) by pop9.ucdavis.edu (8.11.6/8.11.0/IT4.6.2) with ESMTP id g9KLwCt03071 for ; Sun, 20 Oct 2002 14:58:12 -0700 (PDT) Received: from ijtrotts by beech with local (Exim 3.35 #1 (Debian)) id 183O5v-0002Ki-00 for ; Sun, 20 Oct 2002 14:58:47 -0700 Date: Sun, 20 Oct 2002 14:58:47 -0700 To: OCaml Mailing List Subject: Re: [Caml-list] matrix-matrix multiply - O'Caml is 6 times slower than C Message-ID: <20021020215847.GA8750@beech> References: <20021020114251.A7642@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i From: Issac Trotts Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I don't see how to do strength-reduction without introducing references, > which appears to reduce performance more than is gained. You might try converting your references to mutable fields. Here's an example of the performance gain: % cat ref.ml let x = ref 1.0 in let n = int_of_string Sys.argv.(1) in for i = 1 to n do x := !x +. 1.0 done % cat ref2.ml type t = { mutable f:float };; let x = { f = 1.0 } in let n = int_of_string Sys.argv.(1) in for i = 1 to n do x.f <- x.f +. 1.0 done % ocamlopt -o ref{,.ml} % ocamlopt -o ref2{,.ml} % time ./ref 100000000 ./ref 100000000 2.51s user 0.00s system 99% cpu 2.515 total % time ./ref2 100000000 ./ref2 100000000 1.54s user 0.01s system 100% cpu 1.542 total The standard references take 1.6 times as much cpu time in this case. Issac ------------------- 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