> 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)) -----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|----- ====