<br><br><div class="gmail_quote">On Sat, Feb 5, 2011 at 10:14 AM, Liam Healy <span dir="ltr"><<a href="mailto:lhealy@common-lisp.net">lhealy@common-lisp.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I've seen those notes too, and I'm not sure what they mean.  It<br>
doesn't make sense to me that a double float should have to be within<br>
2^63 unless perhaps it is trying to convert to a fixnum somewhere,<br>
which also seems odd.  You might try asking on #lisp or the SBCL<br>
mailing list.  </blockquote><div><br>OK, will do. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Actually, I'm not sure what optimization to expect<br>

here, because I'm not sure how it might be compiling this<br>
inefficiently.  What evidence do you have of inefficiency?<br></blockquote><div><br>I don't have any evidence off inefficiencies.  (now that you mention it,
 I should<br>
try a similar calculation in fortran and c -- will report on that).<br>
<br>
The experiment was motivated by the fact that map-grid provides both the 
argument types and the<br>
required result type.  I wanted to see if providing declarations to the element-function would<br>improve performance.<br><br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
Liam<br>
<div><div></div><div class="h5"><br>
<br>
On Thu, Feb 3, 2011 at 12:34 PM, Mirko Vukovic <<a href="mailto:mirko.vukovic@gmail.com">mirko.vukovic@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I was wondering whether optimization can help grid-map's performance.  (But<br>
> I really have not done<br>
> much optimizing).  So, I timed the following two functions which map `sin'<br>
> over a really large grid:<br>
><br>
> (in-package :grid)<br>
><br>
> (defun optimized (arg)<br>
>   (grid:map-grid :source arg<br>
>         :element-function<br>
>         #'(lambda (arg)<br>
>         (declare<br>
>          (optimize (speed 3) (safety 0) (debug 0))<br>
>          (double-float arg))<br>
>         (the double-float (sin arg))))<br>
>   (values))<br>
><br>
> (defun unoptimized (arg)<br>
>   (grid:map-grid :source arg<br>
>         :element-function<br>
>         #'(lambda (arg)<br>
>         (sin arg)))<br>
>   (values))<br>
><br>
> (progn<br>
>   (defvar *arg* nil)<br>
>   (setf *arg* (grid:make-grid '((foreign-array 300000) double-float)<br>
>                   :initial-element 1d0))<br>
>   nil)<br>
><br>
> On 64bit linux & SBCL, compilation of the optimized routine generate the<br>
> following notes<br>
> that I don't understand:<br>
><br>
> ; note: unable to avoid inline argument range check<br>
> ; because the argument range (DOUBLE-FLOAT) was not within 2^63<br>
><br>
> ;     #'(LAMBDA (GRID::ARG)<br>
> ;         (DECLARE (OPTIMIZE (SPEED 3) (SAFETY 0) (DEBUG 0))<br>
> ;                  (DOUBLE-FLOAT GRID::ARG))<br>
> ;         (THE DOUBLE-FLOAT (SIN GRID::ARG)))<br>
> ;<br>
> ; note: doing float to pointer coercion (cost 13) to "<return value>"<br>
><br>
> Timing both routines gives very similar results:<br>
><br>
> GRID> (time (unoptimized *arg*))<br>
> Evaluation took:<br>
>   0.112 seconds of real time<br>
>   0.111983 seconds of total run time (0.110983 user, 0.001000 system)<br>
>   [ Run times consist of 0.004 seconds GC time, and 0.108 seconds non-GC<br>
> time. ]<br>
>   100.00% CPU<br>
>   335,890,827 processor cycles<br>
>   19,202,048 bytes consed<br>
><br>
> GRID> (time (optimized *arg*))<br>
> Evaluation took:<br>
>   0.113 seconds of real time<br>
>   0.112983 seconds of total run time (0.111983 user, 0.001000 system)<br>
>   [ Run times consist of 0.003 seconds GC time, and 0.110 seconds non-GC<br>
> time. ]<br>
>   100.00% CPU<br>
>   337,194,558 processor cycles<br>
>   19,202,032 bytes consed<br>
><br>
> Any ideas how to properly optimize the code?<br>
><br>
> Thanks,<br>
><br>
> Mirko<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> GSLL-devel mailing list<br>
> <a href="mailto:GSLL-devel@common-lisp.net">GSLL-devel@common-lisp.net</a><br>
> <a href="http://common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel</a><br>
><br>
><br>
</blockquote></div><br><div style="font-size: 11px; visibility: hidden; position: absolute; z-index: 11000; top: -100px;" id="ArrowLayer1d6e01d"><img style="font-size: 11px; width: 0px; height: 0px; position: absolute; z-index: 11001; top: 0px; left: 0px;" id="arrow_bg_image"></div>
<div style="font-size: 11px; visibility: hidden; position: absolute; z-index: 11000; top: -100px; background-image: url("sacore:inv.gif");" id="InvLayer1d6e01d"></div><div id="BubbleLayer1d6e01d" style="font-size: 11px; text-align: left; visibility: hidden; position: absolute; z-index: 11002; top: -100px;">
        <div style="position: absolute; left: 18px; top: 2px; height: 50px;" id="BALLOONLOGODIV1d6e01d"><table style="height: 100%; border: 0pt none;"><tbody><tr><td style="border: 0pt none;" id="BALLOONLOGO1d6e01d"><img alt="" src="sacore:empty.gif"></td>
</tr></tbody></table></div>

        <table id="BALLOON1d6e01d" style="width: 100%; cursor: default; -moz-user-select: none; border-style: none;" border="0" cellpadding="0" cellspacing="0">
            <tbody><tr>
                <td style="padding: 0pt; border: 0pt none; width: 100%; height: 51px;">
                    <table id="HEADER_ROW1d6e01d" style="margin: 0pt; border: 0pt none; width: 100%; height: 100%;" cellpadding="0" cellspacing="0">
                        <tbody><tr>
                            <td id="HEADER_L1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: no-repeat;" width="18px"> </td>
                            <td id="HEADER_C1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-x; color: Gray;" align="right"> </td>
                            <td id="HEADER_R1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: no-repeat;" valign="middle" width="38px" align="left">
                            <img id="closebutton1d6e01d" onclick="BubbleHide()" style="height: 25px; width: 25px;" src="sacore:empty.gif">
                            </td>
                        </tr>
                    </tbody></table>
                </td>
            </tr>
            <tr>
                <td style="padding: 0pt; border: 0pt none; width: 100%; height: 52px;">
                    <table style="margin: 0pt; border: 0pt none; width: 100%; height: 100%;" cellpadding="0" cellspacing="0">
                        <tbody><tr>
                            <td id="BANNER_BORDER_L1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="2px">
                            </td>
                            <td style="padding: 0pt; border: 0pt none;">
                                <table id="BANNER_ROW1d6e01d" style="margin: 0pt; width: 100%; height: 100%; border: 1px solid White;" cellpadding="0" cellspacing="0">
                                    <tbody><tr>
                                        <td id="BANNER_L1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="13px"> </td>
                                        <td id="BANNER_C1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-x;" valign="middle">
                                        <table style="margin: 0pt; border: 0pt none;" width="100%" cellpadding="0" cellspacing="0" height="100%">
                                            <tbody><tr>
                                                <td id="ICON1d6e01d" style="padding: 0pt; border: 0pt none;" width="54px">
                                                    <img alt="" src="sacore:empty.gif" style="vertical-align: middle;">
                                                </td>
                                                <td style="padding: 0pt; border: 0pt none;" width="10px"> </td>
                                                <td id="BANNER_SEP1d6e01d" style="padding: 0pt; border: 0pt none;" width="10px">
                                                    <img alt="" src="sacore:empty.gif" style="vertical-align: middle;">
                                                </td>
                                                <td style="padding: 0pt; border: 0pt none;" width="10px"> </td>
                                                <td id="RECOMMENDATION1d6e01d" class="sastyle_text_overallrec" style="padding: 0pt; border: 0pt none; color: White;"> </td>
                                                <td style="padding: 0pt; border: 0pt none;" width="10px"> </td>
                                            </tr>
                                        </tbody></table>
                                    
                                        </td>
                                        <td id="BANNER_R1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="13px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                    </tr>
                                </tbody></table>
                            </td>
                            <td id="BANNER_BORDER_R1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="2px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                        </tr> 
                    </tbody></table>
                </td>
            </tr>
        <tr>
            <td style="padding: 0pt; border: 0pt none; height: 100%; width: 100%;">
                    <table id="BOTTOM_ROW1d6e01d" class="sastyle_text_contentclass" style="margin: 0pt; border: 0pt none; width: 100%; height: 100%;" cellpadding="0" cellspacing="0">
                        <tbody><tr>
                            <td id="BOTTOM_L1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="2px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                            <td id="BOTTOM_C1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat; background-position: left bottom;">
                                <table style="margin: 0pt; border: 0pt none;" width="100%" cellpadding="0" cellspacing="0">
                                    <tbody><tr>
                                        <td style="padding: 0pt; border: 0pt none;" width="15px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                        <td id="" style="padding: 0pt; border: 0pt none; background-repeat: repeat;">
                                            <table style="border: 0pt none;" width="100%" cellpadding="0" cellspacing="0">
                                                <tbody><tr><td style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td></tr>
                                                <tr>
                                                    <td id="SATITLE1d6e01d" class="sastyle_text_contentclass" style="padding: 0pt; border: 0pt none; font-weight: bold;">
                                                     
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td id="DOMAIN1d6e01d" class="sastyle_text_contentclass" style="padding: 0pt; border: 0pt none;">
                                                     
                                                    </td>
                                                </tr>
                                                                                        <tr>
                                                    <td id="WARN_TB1d6e01d" class="sastyle_link_moreinfo" style="padding: 0pt; border: 0pt none;"><a id="WARN_LINK1d6e01d" href="#" target="_blank" style="color: rgb(0, 0, 222);"></a></td>

                                                </tr>
                                                <tr><td style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td></tr>
                                            </tbody></table>
                                        </td>
                                        <td id="" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="2px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                    </tr>
                                    <tr>
                                        <td style="padding: 0pt; border: 0pt none; height: 40px;"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                        <td style="padding: 0pt; border: 0pt none;">
                                            <table style="margin: 0pt; border: 0pt none;" width="100%" cellpadding="0" cellspacing="0" height="100%">
                                                <tbody><tr>
                                                    <td id="BOTTOM_LEFT1d6e01d" style="padding: 0pt; border: 0pt none;" valign="top">
                                                        <table style="margin: 0pt; border: 0pt none;" width="100%" cellpadding="0" cellspacing="0" height="100%">
                                                            <tbody><tr>
                                                                <td id="FACET_IMAGE_01d6e01d" style="padding: 0pt; border: 0pt none;" valign="middle" width="21px" height="0px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
 
                                                                <td id="FACET_RECCOMENDATION_01d6e01d" class="sastyle_text_facetrec" style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td>

                                                            </tr>
                                                            <tr>
                                                                <td id="FACET_IMAGE_11d6e01d" style="padding: 0pt; border: 0pt none;" valign="middle" height="0px"><img src="sacore:empty.gif" width="1px" height="1px"></td> 
                                                                <td id="FACET_RECCOMENDATION_11d6e01d" class="sastyle_text_facetrec" style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td>

                                                            </tr>
                                                            <tr>
                                                                <td id="FACET_IMAGE_21d6e01d" style="padding: 0pt; border: 0pt none;" valign="middle" height="0px"><img src="sacore:empty.gif" width="1px" height="1px"></td> 
                                                                <td id="FACET_RECCOMENDATION_21d6e01d" class="sastyle_text_facetrec" style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td>

                                                            </tr>
                                                            <tr>
                                                                <td colspan="2" class="sastyle_link_moreinfo" style="padding: 0pt; border: 0pt none;"><a id="DOSSIER_LINK1d6e01d" href="#" target="_blank" style="text-decoration: underline; color: rgb(0, 0, 222);"></a></td>

                                                            </tr>
                                                        </tbody></table>
                                                    </td>
                                                    <td id="BOTTOM_SEP1d6e01d" style="padding: 0pt; border-left: 1px solid Gray; border-bottom: 0pt none; visibility: hidden;" width="10px" height="100%"><img src="sacore:empty.gif" width="10px" height="1px"></td>

                                                    <td id="BOTTOM_RIGHT1d6e01d" style="padding: 0pt; border: 0pt none;" class="sastyle_text_contentclass" valign="top" width="50%">
                                                        <table style="margin: 0pt; border: 0pt none;" width="100%" cellpadding="0" cellspacing="0">
                                                            <tbody><tr>
                                                                <td id="CCHeader1d6e01d" colspan="2" class="sastyle_text_contentclass" style="padding: 0pt; border: 0pt none; font-weight: bold;" width="100%">
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td id="CC_IMAGE_01d6e01d" style="padding: 0pt; border: 0pt none;" valign="middle" width="8px" height="0px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
 
                                                                <td id="CC_DESC_01d6e01d" class="sastyle_text_contentclass" style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                                            </tr>
                                                            <tr>
                                                                <td id="CC_IMAGE_11d6e01d" style="padding: 0pt; border: 0pt none;" valign="middle" height="0px"><img src="sacore:empty.gif" width="1px" height="1px"></td> 
                                                                <td id="CC_DESC_11d6e01d" class="sastyle_text_contentclass" style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                                            </tr>
                                                            <tr>
                                                                <td id="CC_IMAGE_21d6e01d" style="padding: 0pt; border: 0pt none;" valign="middle" height="0px"><img src="sacore:empty.gif" width="1px" height="1px"></td> 
                                                                <td id="CC_DESC_21d6e01d" class="sastyle_text_contentclass" style="padding: 0pt; border: 0pt none;"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                                            </tr>
                                                            <tr>
                                                                <td colspan="2" class="sastyle_link_moreinfo" style="padding: 5px 0pt 0pt; border: 0pt none;">
                                                                    <a style="text-decoration: none; margin-right: 10px;" id="CCDesc1d6e01d" href="#" target="_blank"></a>
                                                                </td>
                                                            </tr>                                                 
                                                        </tbody></table>                                                
                                                    </td>
                                                </tr>
                                            </tbody></table>
                                        </td>
                                        <td style="padding: 0pt; border: 0pt none;" width="10px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                                    </tr>
                                    <tr><td id="UPSELL_BORDER1d6e01d" colspan="3" style="padding: 0pt; border-left: 0pt none; border-bottom: 0pt none; visibility: hidden;" width="100%" align="right"><img id="UPSELL_SEP1d6e01d" src="sacore:empty.gif" width="1px" height="1px"></td>
</tr>
                                    <tr>
                                        <td id="UPSELL1d6e01d" colspan="3" style="padding: 0pt; border: 0pt none; text-align: right;" align="right">
                                            <img src="sacore:empty.gif" width="1px" height="1px"><a class="sastyle_link_upsell" style="text-decoration: none; margin-right: 10px; color: rgb(0, 0, 222);" id="UPSELL_LINK1d6e01d" href="#" target="_blank"></a>
                                        </td>
                                    </tr>
                                </tbody></table>
                            </td>
                            <td id="BOTTOM_R1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-y;" width="2px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                        </tr>
                    </tbody></table>            
            </td>
        </tr>         
        <tr>
            <td style="padding: 0pt; border: 0pt none; width: 100%;">
                    <table id="FOOTER_ROW1d6e01d" style="margin: 0pt; border: 0pt none; width: 100%; height: 100%;" cellpadding="0" cellspacing="0">
                        <tbody><tr>
                            <td id="FOOTER_L1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: no-repeat;" width="9px" height="9px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                            <td id="FOOTER_C1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: repeat-x;"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                            <td id="FOOTER_R1d6e01d" style="padding: 0pt; border: 0pt none; background-repeat: no-repeat;" width="9px"><img src="sacore:empty.gif" width="1px" height="1px"></td>
                        </tr>
                    </tbody></table>            
            </td>
        </tr>         
        </tbody></table>


</div>