Subject: real and complex floating point on C stack
From: Camm Maguire
Date: 15 Jun 2007 19:57:16 -0400
Greetings! Just FYI regarding some recent gcl work:
=============================================================================
/tmp/mb.l
=============================================================================
(defconstant +reps+ 10000000)
(let ((f (compile nil (lambda (x) (declare (long-float x)) (dotimes (i +reps+) (let ((z x)) (setq z (cos z)) z))))))
(time (funcall f 1.0d0)))
(let ((f (compile nil (lambda (x) (declare (long-float x)) (dotimes (i +reps+) (let ((z x)) (setq z (sqrt (exp z)) z (exp (- (* z z)))) z))))))
(time (funcall f 1.0d0)))
(let ((f (compile nil (lambda (x) (declare (long-float x)) (dotimes (i +reps+) (let ((z x)) (setq z (exp (atan z))) z))))))
(time (funcall f 1.0d0)))
(let ((f (compile nil (lambda (x) (declare ((complex long-float) x)) (dotimes (i +reps+) (let ((z x)) (setq z (exp (atan z))) z))))))
(time (funcall f #c(1.0d0 1.0d0))))
=============================================================================
>(load "/tmp/mb.l")
;; Loading /tmp/mb.l
;; Compiling /tmp/gazonk_14798_0.lsp.
;; End of Pass 1.
;; End of Pass 2.
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, (Debug quality ignored)
;; Finished compiling /tmp/gazonk_14798_0.o.
;; Loading /tmp/gazonk_14798_0.o
;; start address -T 0xaa75e0 ;; Finished loading /tmp/gazonk_14798_0.o
real time : 0.910 secs
run-gbc time : 0.920 secs
child run time : 0.000 secs
gbc time : 0.000 secs
;; Compiling /tmp/gazonk_14798_0.lsp.
;; End of Pass 1.
;; End of Pass 2.
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, (Debug quality ignored)
;; Finished compiling /tmp/gazonk_14798_0.o.
;; Loading /tmp/gazonk_14798_0.o
;; start address -T 0xa6f2e0 ;; Finished loading /tmp/gazonk_14798_0.o
real time : 5.050 secs
run-gbc time : 5.050 secs
child run time : 0.000 secs
gbc time : 0.000 secs
;; Compiling /tmp/gazonk_14798_0.lsp.
;; End of Pass 1.
;; End of Pass 2.
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, (Debug quality ignored)
;; Finished compiling /tmp/gazonk_14798_0.o.
;; Loading /tmp/gazonk_14798_0.o
;; start address -T 0xaac250 ;; Finished loading /tmp/gazonk_14798_0.o
real time : 3.010 secs
run-gbc time : 3.010 secs
child run time : 0.000 secs
gbc time : 0.000 secs
;; Compiling /tmp/gazonk_14798_0.lsp.
;; End of Pass 1.
;; End of Pass 2.
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, (Debug quality ignored)
;; Finished compiling /tmp/gazonk_14798_0.o.
;; Loading /tmp/gazonk_14798_0.o
;; start address -T 0xa6c6e8 ;; Finished loading /tmp/gazonk_14798_0.o
real time : 5.780 secs
run-gbc time : 5.770 secs
child run time : 0.000 secs
gbc time : 0.000 secs
;; Finished loading /tmp/mb.l
T
>
=============================================================================
GCL is able to infer the types from the above and conclude that a
direct call to the C routine in libm can proceed without boxing.
These are just some examples -- many other such functions have now
been implemented in gcl_mnum.lsp.
Take care,
--
Camm Maguire camm at enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah