Floating-point performance
Nicolas Neuss <[email protected]> Mon, 09 May 2005 23:07:15 +0200
| Newsgroups | gmane.lisp.allegro |
|---|---|
| Organization | IWR |
| Message-ID | <[email protected]> |
Hello, Allegro experts,
I am just testing if Allegro CL would be a suitable host for my PDE
simulation tool Femlisp. One necessity would be that floating point
arithmetic is fast. I assume that Allegro is able to satisfy this need,
because I remember an earlier article of Richard Fateman reporting fast fp
arithmetic with Allegro. However, at the moment I observe a factor 5 of
speed between Allegro and CMUCL. Which declaration do I miss? I have
played around a bit with (declare (:explain :calls :types)) but
unfortunately with little insight.
Thank you for any information,
Nicolas.
---------------------------------------------------------------------------
The test code and the timing results:
---------------------------------------------------------------------------
(let ((ddot
(compile nil
(lambda (x y n)
(declare (type fixnum n)
(type (simple-array double-float (*)) x y))
(declare (optimize (safety 0) (space 0) (debug 0) (speed
3)))
(loop for i of-type fixnum from 0 below n
summing (* (aref x i) (aref y i)) of-type
double-float))))
(daxpy
(compile nil
(lambda (x y n)
(declare (type fixnum n)
(type (simple-array double-float (*)) x y))
(declare (optimize (safety 0) (space 0) (debug 0) (speed
3)))
(dotimes (i n)
(incf (aref y i) (* 3.0d0 (aref x i))))))))
(let* ((size 10000) (repetitions (/ 100000000 size))
(a (make-array size :element-type 'double-float :initial-element
0.0d0))
(b (make-array size :element-type 'double-float :initial-element
0.0d0)))
(flet ((test (f)
(time (loop repeat repetitions do (funcall f a b size)))))
(test ddot)
(test daxpy))))
;;;; CMUCL results
; Evaluation took:
; 1.07 seconds of real time
; 0.99 seconds of user run time
; 0.0 seconds of system run time
; 640,581,017 CPU cycles
; 0 page faults and
; 1,120,104 bytes consed.
; Evaluation took:
; 1.4 seconds of real time
; 1.34 seconds of user run time
; 0.0 seconds of system run time
; 840,576,216 CPU cycles
; 0 page faults and
; 960,104 bytes consed.
;
;;;; Allegro results
; cpu time (non-gc) 5,620 msec user, 0 msec system
; cpu time (gc) 40 msec user, 0 msec system
; cpu time (total) 5,660 msec user, 0 msec system
; real time 5,831 msec
; space allocation:
; 160,123 cons cells, 240,256 other bytes, 7,832 static bytes
; cpu time (non-gc) 8,220 msec user, 0 msec system
; cpu time (gc) 10 msec user, 0 msec system
; cpu time (total) 8,230 msec user, 0 msec system
; real time 8,454 msec
; space allocation:
; 160,123 cons cells, 232 other bytes, 0 static bytes