Hello,

   I have modified your Chicken benchmark code to use the BLAS
library. With that modification, and using SRFI-4 numeric vectors, the
benchmark results are:

   0.024 seconds elapsed
       0 seconds in (major) GC
      22 mutations
       0 minor GCs
      10 major GCs

The modified code is attached.

   -Ivan


On Sun, Oct 11, 2009 at 12:14 AM, Jeronimo Pellegrini <[email protected]> wrote:
> Hello!
>
> I've been looking for some Scheme implementation that is suitable
> for number crunching and also supports SRFIs like 42 (eager
> comprehension), 45 (laziness), 25 (multidimensional arrays),
> and some others.
>
> So, I have tested Chicken, Bigloo and Gambit. There seems to be a
> necessary trade-off between number of SRFIs and number-chunching speed,
> unfortunately.
>
> The time used to do some floating-point number crunching (this
> example repeatedly multiply matrices) is:
>
> bigloo  0.52s
> gambit  2.70s
> chicken 8.70s
>
> This is for compiled Scheme, with all possible optimizations turned
> on.
>
> The problem is that if it takes 1h for C code, I should then expect
> at least the same for bigloo, and at least 17 times more for Chicken
> (that's too much, unfortunately).
>
> So, going through the mailing list archives I learned about crunch,
> which seems to be awesome, but was being discontinued as of February:
> http://lists.gnu.org/archive/html/chicken-users/2009-02/msg00082.html
>
> (This would be my #1 option!)
>
> And I also found messages mentioning Pre-Scheme:
> http://lists.gnu.org/archive/html/chicken-users/2009-02/msg00109.html
>
> But it's not listed as an Egg in the eggs index here:
> http://chicken.wiki.br/chicken-projects/egg-index-4.html
>
> So, my question is -- was crunch really discontinued? What about the
> Pre-Scheme extension?
>
> Thank you a lot!
> J.
>
>
>
> _______________________________________________
> Chicken-users mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>
(require-extension srfi-4 blas )

(define matrix-size f64vector-length)


(define read-matrix
  (lambda (port)
    (let ((m (read port))
	  (n (read port)))
        (let ((size (* m n))
	      (mat (make-f64vector (* m n))))
          (do ((i 0 (+ 1 i)))
              ((= i size) mat)
	    (f64vector-set! mat i (read port)))))))

;; match-error is called to complain when mul receives a pair of
;; incompatible arguments.
(define match-error
  (lambda (what1 what2)
    (error 'mul
           "~s and ~s are incompatible operands"
           what1
           what2)))

(define (zeros m n)
  (let ((size (* m n)))
    (make-f64vector size 0.0)))

(define bench-multiply
  (lambda (a b times)
    (let ((c #f))
      (do ((i 0 (+ i 1)))
          ((> i times))
          (set! c (blas:dgemm blas:RowMajor blas:NoTrans blas:NoTrans 100 100 4 1.0 a b 0.0 (zeros 100 100))))
      c)))

(define main
  (lambda (times)
    (let ((port-a (open-input-file "x.mat"))
          (port-b (open-input-file "y.mat")))
      (let ((a (read-matrix port-a))
            (b (read-matrix port-b))
            (c #f))
        (display (format "------------"))
        (newline)
        (time (set! c (bench-multiply a b times)))
        (display (format "------------"))
        (newline)
        (if (< (matrix-size c) 100)
            (display c))
        (newline)
        0))))

(newline)
(main (read))

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to