Re: memory usage issue for double-float operations

Andreas Franke via Sbcl-help <[email protected]>
Newsgroups gmane.lisp.steel-bank.general
Message-ID <trinity-29f3525a-8035-4fea-b8f2-c5a9a2a6b7e1-1727477171835@3c-app-gmx-bs30>
Maybe you could use the two 32-bits parts
of a double-float and use multiple-value-calls?
See attachment.

HTH,
Andreas

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help
double-float-function.lisp (text/x-common-lisp, 973 B)
(in-package :cl-user)

(declaim (optimize #+nil (compilation-speed 0)
		   (debug 0)
		   (speed 3)
		   #+nil (space 0)
		   (safety 0)))

#+nil
(declaim (type (simple-array double-float (1)) *ar*))

(defvar *ar* (make-array '(1)
			 :element-type 'double-float
			 :initial-element 0.0d0))

#+nil
(declaim (ftype (function (double-float)
			  (values (signed-byte 32) ;; hi
				  (unsigned-byte 32))) ;; lo
		f1))

(defun f1 (v)
  (declare (type double-float v))
  (let ((f (+ v v)))
    ;;(declare (dynamic-extent f))
    (values (sb-kernel:double-float-high-bits f)
	    (sb-kernel:double-float-low-bits f))))

#+nil
(declaim (ftype (function (double-float) *) f2))

(defun f2 (v)
  (declare (type double-float v))
  (loop for i from 1 to 1000
	do
	   (setf (aref (the (simple-array double-float (1)) *ar*)
		       0)
	     (multiple-value-call #'sb-kernel:make-double-float
	       (let ((f (+ v i)))
		 (declare (dynamic-extent f))
		 (f1 f))))))

(time (f2 1.0d0))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.