Paste number 11910: fractals on openmcl

Index of paste annotations: 1 | 2 | 3 | 4

Paste number 11910: fractals on openmcl
Pasted by: jdz
When:9 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+96U
Channel:#lisp
Paste contents:
Raw Source | XML | Display As
Welcome to OpenMCL Version (Beta: Darwin) 0.14.3!
? (load (compile-file "apress-fractal"))
Performing compile-time optimization.. please wait.
Done.
#P"/Users/jdz/Downloads/apress-fractal/src/apress-fractal.dfsl"
? (time (generate-fractals-from-input-file "../sampleinput.txt"))
> Error in process listener(1): The value #<ARRAY 600x800 type (UNSIGNED-BYTE 8), displaced> can not be used to set the value of the slot DATA in #<MSET-MAP [-1.0 1.0 1.0 -1.0] 800x600 #x63C9936>, because it is not of type (SIMPLE-ARRAY (INTEGER 0 128) (* *)). 
> While executing: CCL::%MAYBE-STD-SETF-SLOT-VALUE-USING-CLASS
> Type :POP to abort.
Type :? for other options.
1 > 

Annotations for this paste:

Annotation number 1: Same error on bleeding edge (from a day or so ago)
Pasted by: dsteuber
When:9 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+96U/1
Paste contents:
Raw Source | Display As
$ openmcl
Welcome to OpenMCL Version 1.0-test-050914 (DarwinPPC32)!
? (load (compile-file "apress-fractal.lisp"))
Performing compile-time optimization.. please wait.
Done.
#P"/Users/david/usr/src/apress-fractal/src/apress-fractal.dfsl"
? (time (generate-fractals-from-input-file "../sampleinput.txt"))
> Error in process listener(1): The value #<ARRAY 600x800 type (UNSIGNED-BYTE 8), displaced> can not be used to set the value of the slot DATA in #<MSET-MAP [-1.0 1.0 1.0 -1.0] 800x600 #x8405A0E>, because it is not of type (SIMPLE-ARRAY (MOD 129) (* *)). 
> While executing: CCL::%MAYBE-STD-SETF-SLOT-VALUE-USING-CLASS
> Type :POP to abort.
Type :? for other options.
1 > :pop


I don't know when I broke this for OpenMCL.  I will send a note to openmcl-devel.

Annotation number 2: How do I correct this code (displaced array type is wrong)
Pasted by: dsteuber
When:9 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+96U/2
Paste contents:
Raw Source | Display As
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defconstant +max-iterations+ 128))

(defclass mset-map ()
  ((left           :type single-float       :initarg :left           :reader mset-map-left)
   (right          :type single-float       :initarg :right          :reader mset-map-right)
   (top            :type single-float       :initarg :top            :reader mset-map-top)
   (bottom         :type single-float       :initarg :bottom         :reader mset-map-bottom)
   (width          :type (integer 1 4096)   :initarg :width          :reader mset-map-width)
   (height         :type (integer 1 4096)   :initarg :height         :reader mset-map-height)
   (x-axis         :type simple-vector)
   (y-axis         :type simple-vector)
   (data           :type (simple-array (integer 0 #.+max-iterations+) (* *)))
   (data-alias     :type (simple-array (integer 0 #.+max-iterations+) *))))

(defmethod shared-initialize :after ((o mset-map) slot-names &rest init-args)
  (declare (ignore slot-names init-args))
  (flet ((make-axis-array (len min max)
           (let ((my-array (make-array len)))
             (loop for i below len
                with pixelsize = (/ (- max min) len)
                with start = min
                do (setf (svref my-array i) (+ start (* i pixelsize))))
             my-array)))
    (with-slots (left right top bottom x-axis y-axis data data-alias height width) o
      (setf x-axis (make-axis-array width left right)
            y-axis (nreverse (make-axis-array height bottom top))
            data-alias (make-array (* height width)
                                   :element-type '(integer 0 #.+max-iterations+)
                                   :initial-element 0)
            data (make-array (list height width)
                               :element-type '(integer 0 #.+max-iterations+)
                               :displaced-to data-alias))))) 

Annotation number 3: Corrected DEFCLASS form for posterity
Pasted by: dsteuber
When:9 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+96U/3
Paste contents:
Raw Source | Display As
(defclass mset-map ()
  ((left           :type single-float       :initarg :left           :reader mset-map-left)
   (right          :type single-float       :initarg :right          :reader mset-map-right)
   (top            :type single-float       :initarg :top            :reader mset-map-top)
   (bottom         :type single-float       :initarg :bottom         :reader mset-map-bottom)
   (width          :type (integer 1 4096)   :initarg :width          :reader mset-map-width)
   (height         :type (integer 1 4096)   :initarg :height         :reader mset-map-height)
   (x-axis         :type simple-vector)
   (y-axis         :type simple-vector)
   (data           :type (array (integer 0 #.+max-iterations+) (* *)))
   (data-alias     :type (simple-array (integer 0 #.+max-iterations+) *))))

Annotation number 4: results for fractals with corrected code
Pasted by: jdz
When:9 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+96U/4
Paste contents:
Raw Source | Display As
(GENERATE-FRACTALS-FROM-INPUT-FILE "../sampleinput.txt") took 15,480 milliseconds (15.480 seconds) to run.                                                                     
Of that, 7,831 milliseconds (7.831 seconds) were spent in user mode                                                                                                            
         5,228 milliseconds (5.228 seconds) were spent in system mode                                                                                                          
         2,421 milliseconds (2.421 seconds) were spent executing other OS processes.                                                                                           
2,839 milliseconds (2.839 seconds) was spent in GC.                                                                                                                            
 732,313,024 bytes of memory allocated.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.