[Openmcl-devel] Performance Question

Brent Fulgham bfulg at pacbell.net
Wed Jan 3 07:03:28 UTC 2007


I hit send before I phrased my earlier e-mail in the form of a question:

"Can anyone help me identify why I'm encountering such a bottleneck"?

:-)

Thanks,

-Brent

On Jan 2, 2007, at 8:11 PM, Brent Fulgham wrote:

> The main performance problem in my code appears to be the  
> implementation of the floating point array stuff.
>
> Attached is a test case outlining the problem.
>
> If I run this under OpenMCL (the 12-31-2006 build):
>
> ? (time (dotimes (i 5000)
>         (defparameter *A* (rlet ((BB (array :single-float 4)))
>              (init-array BB :single-float 0.1 0.2 0.3 0.4)))))
> (DOTIMES (I 5000) (DEFPARAMETER *A* (RLET ((BB (ARRAY :SINGLE-FLOAT  
> 4))) (INIT-ARRAY BB :SINGLE-FLOAT 0.1 0.2 0.3 0.4)))) took 4,694  
> milliseconds (4.694 seconds) to run.
> Of that, 1,090 milliseconds (1.090 seconds) were spent in user mode
>          1,719 milliseconds (1.719 seconds) were spent in system mode
>          1,885 milliseconds (1.885 seconds) were spent executing  
> other OS processes.
> 14 milliseconds (0.014 seconds) was spent in GC.
> 10,613,672 bytes of memory allocated.
> NIL
> ?
>
> If I run this code in the demo version of MCL 5.1, the performance  
> is about an 40 times better, and conses about a 50th as much memory:
>
> ? (time (dotimes (i 5000)
>      (defparameter *A* (rlet ((BB (array :single-float 4)))
>        (ccl::init-array BB :single-float 0.1 0.2 0.3 0.4)))))
> (DOTIMES (I 5000) (DEFPARAMETER *A* (RLET ((BB (ARRAY :SINGLE-FLOAT  
> 4))) (CCL::INIT-ARRAY BB :SINGLE-FLOAT 0.1 0.2 0.3 0.4)))) took 185  
> milliseconds (0.185 seconds) to run.
>  200,016 bytes of memory allocated.
>
> This pretty closely matches the 40-fold slow-down in frame rate I  
> see in simple tests of the OpenGL stuff under OpenMCL compared to MCL.
>
> If I hard-code the sizes in the %put-long/%put-single-float it  
> speeds things up considerably, though memory use is still very large:
>
> Of that, 277 milliseconds (0.277 seconds) were spent in user mode
>          413 milliseconds (0.413 seconds) were spent in system mode
>          59 milliseconds (0.059 seconds) were spent executing other  
> OS processes.
> 7 milliseconds (0.007 seconds) was spent in GC.
> 2,133,672 bytes of memory allocated.
>
>
> Thanks,
>
> -Brent
>
>
> ==========================================================
> Test Implementation
> ==========================================================
> (eval-when (:compile-toplevel :load-toplevel :execute)
>   (ccl:use-interface-dir :carbon)
>   (open-shared-library "/System/Library/Frameworks/Carbon.framework/ 
> Carbon"))
>
> (defun %sizeof (type)
>    (ccl::%foreign-type-or-record-size type :bytes))
>
> (defun record-field-length (Type)
>    (%sizeof Type))
>
> (defmacro %put-long (Name Value &optional (Index 0))
>   `(eval-when (compile eval load)
>      (setf (%get-long ,Name (* ,Index (%sizeof :long))) ,Value)))
> ;
> ;  "speedy" version
> ;
> ;(defmacro %put-long (Name Value &optional (Index 0))
> ;  `(eval-when (compile eval load)
> ;     (setf (%get-long ,Name (* ,Index 4)) ,Value)))
>
> (defmacro %put-single-float (Name Value Index)
>   `(eval-when (compile eval load)
>      (setf (%get-single-float ,Name (* ,Index (%sizeof :single- 
> float))) ,Value)))
> ;
> ;  "speedy" version
> ;
> ;(defmacro %put-single-float (Name Value Index)
> ;  `(eval-when (compile eval load)
> ;     (setf (%get-single-float ,Name (* ,Index 4)) ,Value)))
>
> (defun INIT-ARRAY (&array Type &rest Values)
>   (declare (dynamic-extent Values))
>   (let ((Index 0)
>         (Size (record-field-length Type)))
>     (dolist (Value Values &Array)
>       (ecase Type
>         (:long (%put-long &Array Value Index))
>         (:single-float (%put-single-float &Array Value Index)))
>       (incf Index 1))))
>
> (defmacro WITH-RGBA-VECTOR (Vector (Red Green Blue Alpha) &body Forms)
>   `(rlet ((,Vector (array :single-float 4)))
>      (init-array ,Vector :single-float ,Red ,Green ,Blue ,Alpha)
>      , at Forms))
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20070102/85360dd8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 188 bytes
Desc: This is a digitally signed message part
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20070102/85360dd8/attachment.pgp>


More information about the Openmcl-devel mailing list