<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I hit send before I phrased my earlier e-mail in the form of a question:<DIV><BR class="khtml-block-placeholder"></DIV><DIV>"Can anyone help me identify why I'm encountering such a bottleneck"?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>:-)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-Brent</DIV><DIV><BR><DIV><DIV>On Jan 2, 2007, at 8:11 PM, Brent Fulgham wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">The main performance problem in my code appears to be the implementation of the floating point array stuff.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Attached is a test case outlining the problem.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If I run this under OpenMCL (the 12-31-2006 build):</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>? (time (dotimes (i 5000)</DIV><DIV>        (defparameter *A* (rlet ((BB (array :single-float 4)))</DIV><DIV>             (init-array BB :single-float 0.1 0.2 0.3 0.4)))))</DIV><DIV>(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.</DIV><DIV>Of that, 1,090 milliseconds (1.090 seconds) were spent in user mode</DIV><DIV>         1,719 milliseconds (1.719 seconds) were spent in system mode</DIV><DIV>         1,885 milliseconds (1.885 seconds) were spent executing other OS processes.</DIV><DIV>14 milliseconds (0.014 seconds) was spent in GC.</DIV><DIV> 10,613,672 bytes of memory allocated.</DIV><DIV>NIL</DIV><DIV>? </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>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:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">? (time (dotimes (i 5000)</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">     (defparameter *A* (rlet ((BB (array :single-float 4)))</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">       (ccl::init-array BB :single-float 0.1 0.2 0.3 0.4)))))</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">(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.</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">200,016 bytes of memory allocated.</SPAN></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>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.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>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:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Of that, 277 milliseconds (0.277 seconds) were spent in user mode</DIV><DIV>         413 milliseconds (0.413 seconds) were spent in system mode</DIV><DIV>         59 milliseconds (0.059 seconds) were spent executing other OS processes.</DIV><DIV>7 milliseconds (0.007 seconds) was spent in GC.</DIV><DIV> 2,133,672 bytes of memory allocated.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-Brent</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>==========================================================</DIV><DIV>Test Implementation</DIV><DIV>==========================================================</DIV><DIV>(eval-when (:compile-toplevel :load-toplevel :execute)</DIV><DIV>  (ccl:use-interface-dir :carbon) </DIV><DIV>  (open-shared-library "/System/Library/Frameworks/Carbon.framework/Carbon"))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(defun %sizeof (type)</DIV><DIV>   (ccl::%foreign-type-or-record-size type :bytes))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(defun record-field-length (Type)</DIV><DIV>   (%sizeof Type))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(defmacro %put-long (Name Value &optional (Index 0))</DIV><DIV>  `(eval-when (compile eval load)</DIV><DIV>     (setf (%get-long ,Name (* ,Index (%sizeof :long))) ,Value)))</DIV><DIV>;</DIV><DIV>;  "speedy" version</DIV><DIV>;</DIV><DIV>;(defmacro %put-long (Name Value &optional (Index 0))</DIV><DIV>;  `(eval-when (compile eval load)</DIV><DIV>;     (setf (%get-long ,Name (* ,Index 4)) ,Value)))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(defmacro %put-single-float (Name Value Index)</DIV><DIV>  `(eval-when (compile eval load)</DIV><DIV>     (setf (%get-single-float ,Name (* ,Index (%sizeof :single-float))) ,Value)))</DIV><DIV>;</DIV><DIV>;  "speedy" version</DIV><DIV>;</DIV><DIV>;(defmacro %put-single-float (Name Value Index)</DIV><DIV>;  `(eval-when (compile eval load)</DIV><DIV>;     (setf (%get-single-float ,Name (* ,Index 4)) ,Value)))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(defun INIT-ARRAY (&array Type &rest Values)</DIV><DIV>  (declare (dynamic-extent Values))</DIV><DIV>  (let ((Index 0)</DIV><DIV>        (Size (record-field-length Type)))</DIV><DIV>    (dolist (Value Values &Array)</DIV><DIV>      (ecase Type</DIV><DIV>        (:long (%put-long &Array Value Index))</DIV><DIV>        (:single-float (%put-single-float &Array Value Index)))</DIV><DIV>      (incf Index 1))))</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(defmacro WITH-RGBA-VECTOR (Vector (Red Green Blue Alpha) &body Forms)</DIV><DIV>  `(rlet ((,Vector (array :single-float 4)))</DIV><DIV>     (init-array ,Vector :single-float ,Red ,Green ,Blue ,Alpha)</DIV><DIV>     ,@Forms))</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>