anchor.diff:                                     (aref fs (- jy 1) jx)))
                             (* c2 (aref fs jy jx)))))))
   
  -(defun initialize-device-memory (nx ny dx dy fd)
  -  (cffi:with-foreign-object (fh :float (* nx ny))
  -    (let ((alpha 30.0))
  -      (dotimes (jy ny)
  -        (dotimes (jx nx)
  -          (let ((j (index nx jx jy))
  -                (x (- (* dx (+ (float jx 1.0) 0.5)) 0.5))
  -                (y (- (* dy (+ (float jy 1.0) 0.5)) 0.5)))
  -            (setf (cffi:mem-aref fh :float j)
  -                  (exp (* (- alpha)
  -                          (+ (* x x) (* y y)))))))))
  -    (cu-memcpy-host-to-device (cffi:mem-ref fd 'cu-device-ptr) fh (* nx ny 4))))
  +(defun initialize-device-memory (nx ny dx dy f)
  +  (let ((alpha 30.0))
  +    (dotimes (jy ny)
  +      (dotimes (jx nx)
  +        (let ((j (index nx jx jy))
  +              (x (- (* dx (+ (float jx 1.0) 0.5)) 0.5))
  +              (y (- (* dy (+ (float jy 1.0) 0.5)) 0.5)))
  +          (setf (mem-aref f j)
  +                (exp (* (- alpha)
  +                        (+ (* x x) (* y y)))))))))
  +  (memcpy-host-to-device f))
   
   (defvar +block-dim-x+ 16)
   (defvar +block-dim-y+ 16)
  
positive.code:          (time 0)
           (flo 0))
      (with-cuda-context (dev-id)
        (with-cuda-memory-blocks ((f (* nx ny 4))
                                  (fn (* nx ny 4)))
          (initialize-device-memory nx ny dx dy f)
          (start-timer)
          (dotimes (i 20000)
            (when (= (mod i 100) 0)
              (print-time i time))
            (when (= (mod i nout) 0)
              (output-pnm dir i nout nx ny f))
            (incf flo (diffusion2d nx ny f fn kappa dt dx dy))
            (incf time dt)
            (swap f fn))
          (print-time 20000 time)
          (output-pnm dir 20000 nout nx ny f)
          (print-elapsed-time)
          (print-performance flo)
          (stop-timer))))
  
negative.code:   (let ((n (truncate (/ i nout))))
      (concatenate 'string dir (format nil "~4,'0D.pgm" n))))
  
  (defun output-pnm (dir i nout nx ny f)
    (memcpy-device-to-host f)
    (let ((image (make-instance 'imago:grayscale-image
                                :width nx :height ny)))
      (dotimes (i nx)
        (dotimes (j ny)
          (setf (imago:image-pixel image i j) (image-value f i j nx 1.0 0.0))))
      (imago:write-pnm image (file-name dir i nout) :ASCII))
    (values))
  
  
  