caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at>
To: caml-list@inria.fr
Cc: Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at>
Subject: Re: [Caml-list] Some clarifications to the language shootout page
Date: Tue, 26 Nov 2002 10:43:20 +0100	[thread overview]
Message-ID: <3DE34238.9050804@kfunigraz.ac.at> (raw)
In-Reply-To: <3DE1E6CD.2020906@kfunigraz.ac.at>

[-- Attachment #1: Type: text/plain, Size: 2442 bytes --]


> Hi:



The Bigloo boss Manuel  tweaked the MM a little bit (2 little changes 
but with significant consequences):

The Bigloo code can  be reduced to 17s/17/s0.1s

This  is still a little bit higher than the OCaml version but it is damn 
close to within the factor of 2 to C.

Compile it with:

bigloo -v2 -Obench bench.scm -copt "-O3 -fomit-frame-pointer"


Regards,
S. Gonzi


====
Just one more thing, I have changed the Scheme code a very little bit to

make it more similar to the Caml code. That is, I have changed the 
construction of the row vectors. The original initialization 

  (mx (make-vector rows 0.0))

was breaking the CFA because mx what not 
correctly typed vector of vector of double. I have replaced it with:

  (mx (make-vector rows (make-vector 0 0.0)))

Then, you should compile with:

  bigloo -v2 -Obench foo.scm  -copt "-O3 -fomit-frame-pointer"

On my machine with this two modifications I see an improvement of about 17%.
It is still insufficient to defeat Ocaml but we are getting a little closer  [:-)] 

-- 
Manuel

-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
(module bench-matrix
(option (set! *genericity* #f))
(main main))


(define (mkmatrix rows cols)
(let ((mx (make-vector rows (make-vector 0 0.0)))
(count 1.0))
(do ((i 0 (+fx i 1)))
((=fx i rows))
(let ((row (make-vector cols 0.0)))
(do ((j 0 (+fx j 1)))
((=fx j cols))
(vector-set! row j count)
(set! count (+fl count 1.0)))
(vector-set! mx i row)))
mx))

(define (num-cols mx)
(let ((row (vector-ref mx 0)))
(vector-length row)))

(define (num-rows mx)
(vector-length mx))

(define (mmult rows cols m1 m2)
(let ((m3 (make-vector rows (make-vector 0 0.0))))
(do ((i 0 (+fx 1 i)))
((=fx i rows))
(let ((m1i (vector-ref m1 i))
(row (make-vector cols 0.0)))
(do ((j 0 (+fx 1 j)))
((=fx j cols))
(let ((val 0.0))
(do ((k 0 (+fx 1 k)))
((=fx k cols))
(set! val
(+fl val (*fl (vector-ref m1i k)
(vector-ref (vector-ref m2 k) j)))))
(vector-set! row j val)))
(vector-set! m3 i row)))
m3))


(define (do-main size)
(let* ((m1 (mkmatrix size size))
(m2 (mkmatrix size size))
(mm (mmult size size m1 m2)))
(let ((r0 (vector-ref mm 0))
(r2 (vector-ref mm 2))
(r3 (vector-ref mm 3))
(r4 (vector-ref mm 4)))
(print (vector-ref r0 0) " " (vector-ref r2 3) " "
(vector-ref r3 2) " " (vector-ref r4 4)))))

(define (main x)
(do-main 512))
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
====






  parent reply	other threads:[~2002-11-26  9:43 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
2002-11-25 11:09 ` Siegfried Gonzi
2002-11-26  9:43 ` Siegfried Gonzi [this message]
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=3DE34238.9050804@kfunigraz.ac.at \
    --to=siegfried.gonzi@kfunigraz.ac.at \
    --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;
as well as URLs for NNTP newsgroup(s).