anchor.diff:  (defun update (new-pos old-pos vel delta-time damping num-bodies p)
     (integrate-nbody-system new-pos old-pos vel delta-time damping num-bodies p))
   
  -#|
  -(defun run-benchmark (new-pos old-pos vel delta-time damping num-bodies p iterations)
  -  (update new-pos old-pos vel delta-time damping num-bodies p)
  -  ;; create-timer
  -  ;; start-timer
  -  (loop repeat iterations
  -     do (update new-pos old-pos vel delta-time damping new-pos p))
  -  ;; stop-timer
  -  ;; get elapsed time
  -  ;; delete-timer
  -  ;; compute-perf-stats
  -  ;; show-log
  -  )
  -|#
  -
   (defclass nbody-window (glut:window)
     ((new-pos :initform nil)
      (old-pos :initform nil)
  
positive.code: (let ((fps-count 0)
        (fps-limit 5)
        (template "CUDA N-Body (~A bodies): ~,1F fps | ~,1F BIPS | ~,1F GFLOP/s | single precision~%"))
    (defun display-frame-rate (num-bodies start-event stop-event)
      (incf fps-count)
      (when (>= fps-count fps-limit)
        (cffi:with-foreign-object (pmilliseconds :float)
          (cu-event-record (cffi:mem-ref stop-event 'cu-event)
                           (cffi:null-pointer))
          (cu-event-synchronize (cffi:mem-ref stop-event 'cu-event))
          (cu-event-elapsed-time pmilliseconds
                                 (cffi:mem-ref start-event 'cu-event)
                                 (cffi:mem-ref stop-event 'cu-event))
          (let* ((milliseconds (/ (cffi:mem-ref pmilliseconds :float)
                                  fps-count))
                 (ifps (/ 1.0 (/ milliseconds 1000.0))))
            (multiple-value-bind (interactions-per-second gflops)
                (compute-perf-stats num-bodies milliseconds 1)
              (glut:set-window-title (format nil template 
                                             num-bodies ifps
                                             interactions-per-second gflops)))
            (setf fps-count 0)
            (setf fps-limit (if (> ifps 1.0) ifps 1.0)))
          (cu-event-record (cffi:mem-ref start-event 'cu-event)
                           (cffi:null-pointer))))))
  
  (defmethod glut:reshape ((w nbody-window) width height)
    (gl:matrix-mode :projection)
    (gl:load-identity)
    (glu:perspective 60.0 (/ width height) 0.1 1000.0)
    
    (gl:matrix-mode :modelview)
    (gl:viewport 0 0 width height))
  
  (defmethod glut:idle ((w nbody-window))
    (update (slot-value w 'new-pos)
            (slot-value w 'old-pos)
            (slot-value w 'vel)
            (slot-value w 'delta-time)
            (slot-value w 'damping)
            (slot-value w 'num-bodies)
            (slot-value w 'p))
    (rotatef (slot-value w 'new-pos) (slot-value w 'old-pos))
    (glut:post-redisplay))
  
  (defun main ()
    (let ((dev-id 0)
  
negative.code:       (let ((p (mem-aref old-pos i)))
          (gl:vertex (float4-x p) (float4-y p) (float4-z p)))))
    (gl:end)
    ;; swap buffers
    (glut:swap-buffers)
    ;; display frame rate
    (display-frame-rate (slot-value w 'num-bodies)))
  
  (defvar *flops-per-interaction* 20)
  
  