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 NAA17461; Mon, 25 Nov 2002 13:12:55 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 NAA18232 for ; Mon, 25 Nov 2002 13:12:54 +0100 (MET) Received: from jerry.kfunigraz.ac.at (GIGAJERRY.kfunigraz.ac.at [143.50.55.161]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gAPCCp110928; Mon, 25 Nov 2002 13:12:51 +0100 (MET) Received: from tom.kfunigraz.ac.at (mc_tom [10.10.1.160]) by jerry.kfunigraz.ac.at (8.11.2/8.11.2) with ESMTP id gAPCCom14445; Mon, 25 Nov 2002 13:12:50 +0100 (MET) Received: from kfunigraz.ac.at (IGAM08AV.kfunigraz.ac.at [143.50.39.35]) by tom.kfunigraz.ac.at (8.11.2/8.11.2) with ESMTP id gAPCCoJ03918; Mon, 25 Nov 2002 13:12:50 +0100 (MET) Message-ID: <3DE21F99.5040504@kfunigraz.ac.at> Date: Mon, 25 Nov 2002 14:03:21 +0100 From: Siegfried Gonzi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: Pierre Weis CC: caml-list@inria.fr Subject: Re: [Caml-list] Some clarifications to the language shootout page References: <200211251023.LAA14987@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Pierre Weis wrote: >Hi, > >I try to answer your post in a fair manner: I think the Caml and >Scheme code are not equivalent (hence the figures you observed). I >give the Caml code that is (in my mind) equivalent to the Scheme >code. I would be glad if you could run it on your machine to complete >your comparison (and may be modify your conclusions). > Pierre Weis translated the Bigloo version to: ==== ========================= Ocaml version obtained from the original Scheme fast version: (C) P. Weis usage: ocamlopt -unsafe -inline 9 mm_scm.ml time ./a.out ========================= let make_matrix rows cols = let mx = Array.make rows [||] in let count = ref 1.0 in for i = 0 to rows - 1 do let row = Array.make cols 0.0 in for j = 0 to cols - 1 do row.(j) <- !count; count := !count +. 1.0 done; mx.(i) <- row done; mx;; (* Don't know why there is this dead code into the Scheme version *) let num_cols mx = let row = mx.(0) in Array.length row;; (* Don't know why there is this dead code into the Scheme version *) let num_rows mx = Array.length mx;; let mmult rows cols m1 m2 = let m3 = Array.make rows [||] in for i = 0 to rows - 1 do let m1i = m1.(i) in let row = Array.make cols 0.0 in for j = 0 to cols - 1 do let v = ref 0.0 in for k = 0 to cols - 1 do v := !v +. m1i.(k) *. m2.(k).(j); done; row.(j) <- !v; done; m3.(i) <- row; done; m3;; let do_main size = let mm = ref [||] in let m1 = make_matrix size size in let m2 = make_matrix size size in mm := mmult size size m1 m2; let r0 = !mm.(0) and r2 = !mm.(2) and r3 = !mm.(3) and r4 = !mm.(4) in Printf.printf "%f %f %f %f\n" r0.(0) r2.(3) r3.(2) r4.(4);; do_main 512;; ==== This new situation ends up in: I did things on my stationary machine: Pentium II 450MHz, 256MB RAM, SuSE Linux 8.0 bigloo -Obench bench.scm : 23s/23s/0.1s g++ -O6 bench.scm: 7s/7s/0.03s ocamlopt -unsafe -inline 9 bench1.ml: 18s/18s/0.01 ;; Weis's version: ocamlopt unsafe -inline 9 bench2.ml : 14s/14s/0.01 Maybe the Scheme version could a little bit tweaked too. I am not sure. One short note: The Scheme version is portable from one Scheme implementation to the next and one could write a small macro which decides whether to use normal Scheme operators or Bigloo's native ones. S. Gonzi ------------------- 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