From: Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at>
To: Pierre Weis <pierre.weis@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Some clarifications to the language shootout page
Date: Mon, 25 Nov 2002 14:03:21 +0100 [thread overview]
Message-ID: <3DE21F99.5040504@kfunigraz.ac.at> (raw)
In-Reply-To: <200211251023.LAA14987@pauillac.inria.fr>
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
next prev parent reply other threads:[~2002-11-25 12:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-25 9:01 Siegfried Gonzi
2002-11-25 10:23 ` Pierre Weis
2002-11-25 13:03 ` Siegfried Gonzi [this message]
2002-11-25 11:09 ` Siegfried Gonzi
2002-11-26 9:43 ` Siegfried Gonzi
2002-11-26 13:22 ` Pierre Weis
2002-11-27 20:50 isaac gouy
2002-11-29 8:32 ` Siegfried Gonzi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DE21F99.5040504@kfunigraz.ac.at \
--to=siegfried.gonzi@kfunigraz.ac.at \
--cc=caml-list@inria.fr \
--cc=pierre.weis@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).