[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Allegro CL Floating Point
We need to do fast floating point in Lisp. We have benchmarked
a C program and a Lisp program. Both programs call an exponential
function and a trig function 250,000 times.
The C program runs in under 10 seconds. The Lisp program takes
at least 50 seconds. We can't understand why there should be
such a discrepancy. Can anyone replicate this and explain the
discrepancy? We are using the following version of Allegro
3.1.beta.22 [Sun4] (6/8/89)
Anthony Maida
maida@cs.psu.edu
;;;================================================================
;;; C program
#include <math.h>
#define cnt 500
main()
{
int i,j;
double b;
for (i=0; i<cnt; i++)
for (j=0; j<cnt; j++) {
b = exp(-.3);
b = cos(-.51);
}
}
;;;================================================================
;;; Lisp program
(defun speed (cnt)
(declare (optimize (speed 3) (safety 0)))
(declare (fixnum cnt))
(let ((b 0.0))
(declare (single-float b))
(declare (:explain :calls :types))
(dotimes (i cnt)
(declare (fixnum i))
(dotimes (j cnt)
(declare (fixnum j))
(setf b (exp -.3))
(setf b (cos .51))))))
(speed 500)