<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">Am 20.12.2014 um 21:37 schrieb Gary Byers <<a href="mailto:gb@clozure.com" class="">gb@clozure.com</a>>:</div><br class="Apple-interchange-newline"><div class="">On 12/20/2014 10:53:40 AM, Rainer Joswig wrote:<br class=""><blockquote type="cite" class="">Hi,<br class="">I just looked a small benchmark someone wrote and tried to improve it.<br class="">The result is here:<br class=""><a href="https://gist.github.com/lispm/6066e1eeadf943910c47" class="">https://gist.github.com/lispm/6066e1eeadf943910c47</a> <<a href="https://gist.github.com/lispm/6066e1eeadf943910c47" class="">https://gist.github.com/lispm/6066e1eeadf943910c47</a>><br class="">The corresponding data file is here:<br class=""><a href="https://raw.githubusercontent.com/logicchains/LPATHBench/master/agraph" class="">https://raw.githubusercontent.com/logicchains/LPATHBench/master/agraph</a><br class="">There were two issues I saw with CCL:<br class="">** first issue:  DEFSTRUCT defined type at compile time unknown? **<br class="">There is a structure declaration ROUTE via a DEFSTRUCT.<br class="">I wanted to use the type ROUTE in a LOOP later in the function<br class="">(defun get-longest-path (nodes node-id visited &aux (max 0))<br class="">  (declare (optimize (speed 3) (space 0) (debug 0) (safety 0) (compilation-speed 0)<br class="">           #+lispworks (fixnum-safety 0))<br class="">           (fixnum max))<br class="">  (setf (svref visited node-id) t)<br class="">  (setf max (loop for neighbour of-type route in (svref nodes node-id)     ; <—  declaration<br class="">                  unless (svref visited (route-dest neighbour))<br class="">                  maximize (+ (the fixnum (route-cost neighbour))<br class="">                              (the fixnum (get-longest-path nodes<br class="">                                                            (route-dest neighbour)<br class="">                                                            visited)))<br class="">                  #+lispworks fixnum))<br class="">  (setf (svref visited node-id) nil)<br class="">  max)<br class="">The CCL compiler did not know about the type ROUTE, so I had to use EVAL-WHEN around the structure definition. Shouldn’t the compiler recognize the type at compile time? The ANSI CL documentation for DEFSTRUCT indicates that…<br class=""></blockquote><br class="">Please read and try to understand section 3.2.3.1.1, then think about whether your understanding of the issues here is correct.  I strongly suspect that it isn’t.<br class=""></div></blockquote><div><br class=""></div>Okay, read it...<br class=""><div><br class=""></div><div>How about: <a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_defstr.htm#defstruct" class="">http://www.lispworks.com/documentation/HyperSpec/Body/m_defstr.htm#defstruct</a></div><div><br class=""></div><div><br class=""></div><div>> If a defstruct form appears as a top level form, the compiler must make the structure type name recognized as a valid type name in subsequent declarations</div><div><br class=""></div><div>My interpretation would be that a type declaration in a LOOP should be able to use a structure type, without compile-time evaluation.</div><div><br class=""></div><div><div>like in the code here:   (loop for neighbour of-type route in (svref nodes node-id) …</div><div><br class=""></div><div>The CCL compiler complains about an unknown type ROUTE.</div><div class=""><br class=""></div></div><br class=""><blockquote type="cite" class=""><div class=""><br class=""><blockquote type="cite" class="">** second issue:  LOOP clause MAXIMIZE**<br class="">in above function there is a clause  MAXIMIZE … FIXNUM .<br class="">In CCL (and several other implementations, with the exception of LispWorks) this causes that a wrong result (a negative number) is computed. Without the FIXNUM declaration the result is correct.<br class=""></blockquote><br class="">Does it return the same result (perhaps more slowly) if the FIXNUM declaration is retained and the OPTIMIZE declaration is changed to something like (SAFETY 3) (SPEED 0) ?<br class=""></div></blockquote><div><br class=""></div><div>The problem seems to appear without optimize declarations...</div><div><br class=""></div><div>(defun get-longest-path (nodes node-id visited &aux (max 0))</div><div>  (setf (svref visited node-id) t)</div><div>  (setf max (loop for neighbour of-type route in (svref nodes node-id)</div><div>                  unless (svref visited (route-dest neighbour))</div><div>                  maximize (+ (the fixnum (route-cost neighbour))</div><div>                              (the fixnum (get-longest-path nodes</div><div>                                                            (route-dest neighbour)</div><div>                                                            visited)))</div><div>                            fixnum))</div><div>  (setf (svref visited node-id) nil)</div><div>  max)</div><div><br class=""></div><div>Safety 3 and Speed 0 takes a long time and returns the wrong result: -1152921504606837995</div><div><br class=""></div><div>The expected result would have been 8981.</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class="">Does the (non-portable, LispWorks-specific) (FIXNUM-SAFETY 0) declaration affect the result returned in LispWorks  ?<br class=""><br class=""></div></blockquote><div><br class=""></div><div>No.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><blockquote type="cite" class="">Regards,<br class="">Rainer Joswig<br class=""></blockquote><br class="">------quoted attachment------<br class=""><blockquote type="cite" class="">_______________________________________________<br class="">Openmcl-devel mailing list<br class=""><a href="mailto:Openmcl-devel@clozure.com" class="">Openmcl-devel@clozure.com</a><br class="">https://lists.clozure.com/mailman/listinfo/openmcl-devel<br class=""></blockquote><br class=""></div></blockquote></div><br class=""></body></html>