From: Issac Trotts <ijtrotts@ucdavis.edu>
To: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] matrix-matrix multiply - O'Caml is 6 times slower than C
Date: Sun, 20 Oct 2002 14:58:47 -0700 [thread overview]
Message-ID: <20021020215847.GA8750@beech> (raw)
In-Reply-To: <r99of9pgf2t.fsf@quimby-xp.cs.cornell.edu>
> 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
next prev parent reply other threads:[~2002-10-20 21:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-18 20:09 Paul Stodghill
2002-10-20 9:42 ` Xavier Leroy
2002-10-20 18:06 ` Paul Stodghill
2002-10-20 21:58 ` Issac Trotts [this message]
2002-10-23 10:16 ` [Caml-list] Re: float boxing (was: matrix-matrix multiply) Christophe TROESTLER
2002-10-23 12:08 ` malc
2002-10-24 0:00 ` malc
2002-10-21 12:53 ` [Caml-list] matrix-matrix multiply - O'Caml is 6 times slower than C Xavier Leroy
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=20021020215847.GA8750@beech \
--to=ijtrotts@ucdavis.edu \
--cc=caml-list@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