Opened 3 years ago

Closed 3 years ago

#1396 closed defect (fixed)

Read-time complex simple-arrays not getting stored right (??)

Reported by: tarballs_are_good Owned by: rme
Priority: normal Milestone:
Component: Compiler Version: trunk
Keywords: Cc:

Description

It looks to be that arrays of complex double-floats evaluated at readtime aren't being stashed away in the fasl correctly.

Test case:

(defvar *test* nil)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defun v (&rest args)
    (let ((a (make-array (length args) :element-type '(complex double-float)
                                       :initial-element #C(0.0d0 0.0d0))))
      (loop :for i :from 0
            :for x :in args
            :do (setf (aref a i) (coerce x '(complex double-float)))
            :finally (return a)))))

(defmacro define-foo (name m)
  `(setf (getf *test* ',name) ,m))

(define-foo a (v 1 2 3))

(define-foo b '#.(v 1 2 3))

Output:

CL-USER> (load (compile-file "test.lisp"))
#P"test.dx64fsl"
CL-USER> *test*
(B #(#C(0.0D0 0.0D0) #C(0.0D0 0.0D0) #C(0.0D0 0.0D0))
 A #(#C(1.0D0 0.0D0) #C(2.0D0 0.0D0) #C(3.0D0 0.0D0)))

Change History (4)

comment:1 Changed 3 years ago by wws

(In [16805]) Fix SUBTAG-BYTES for x8632, x8664, ppc32, & arm, so that fasl dump and load work correctly for complex single-float and double-float vectors.

I did NOT fix the PPC64 case. Somebody with that hardware will have to do that.

Addresses #1396.

comment:2 Changed 3 years ago by wws

Test case. Save in "complex-float-vector-test.lisp":

(eval-when (:compile-toplevel)
  (defun v2 (&rest args)
    (let ((a (make-array (length args) :element-type '(complex double-float)
                                       :initial-element #C(0.0d0 0.0d0))))
      (loop :for i :from 0
            :for x :in args
            :do (setf (aref a i) (coerce x '(complex double-float)))
            :finally (return a))))
  (defun v3 (&rest args)
    (let ((a (make-array (length args) :element-type '(complex single-float)
                         :initial-element #C(0.0s0 0.0s0))))
      (loop :for i :from 0
         :for x :in args
         :do (setf (aref a i) (coerce x '(complex single-float)))
         :finally (return a))))
  (defun v4 (&rest args)
    (let ((a (make-array (length args) :element-type 'double-float
                         :initial-element 0.0d0)))
      (loop :for i :from 0
         :for x :in args
         :do (setf (aref a i) (coerce x 'double-float))
         :finally (return a)))))

(defparameter *a*
  '#.(v2 #c(1.2 2.3) #c(3.4 4.5) #c(5.6 6.7)))

(defparameter *b*
  '#.(v3 #c(1.2 2.3) #c(3.4 4.5) #c(5.6 6.7)))

(defparameter *c*
  '#.(v4 1.2 2.3 3.4 4.5 5.6 6.7))

To test:

(compile-file "complex-float-vector-test.lisp")
(load *)
*a*
*b*
*c*

You'll see exactly the entered numbers for *b*, but approximates in *a* and *c*. As long as the numbers in *a* and *c* match, all is well.

comment:3 Changed 3 years ago by wws

  • Owner set to rme

Strictly speaking, this change requires bumping the fasl version, but since probably nobody but tarballs_are_good has a fasl file containing a wrongly-dumped complex float vector, I didn't require everybody else to recompile all their code.

Assigning to rme to either fix the PPC64 version of SUBTAG-BYTES or close the ticket.

comment:4 Changed 3 years ago by wws

  • Resolution set to fixed
  • Status changed from new to closed

Closing the ticket. rme says that he's stopped supporting PPC.

Note: See TracTickets for help on using tickets.