[Openmcl-devel] consing iterating through a loop

Randall Beer beer at eecs.cwru.edu
Thu Jan 27 10:03:21 PST 2005


Yes, a Lisp compiler should be able to produce code to execute this 
loop without consing more than the 16 bytes needed to hold the double 
result. However, the OpenMCL compiler does not currently do the 
floating pointing optimization that SBCL does and, to my knowledge, 
there is no DECLARE magic that will fix this.

Yes, OpenMCL's floating-point optimization could be improved to produce 
code competitive with SBCL, but this has not yet been done.  FPC-PPC 
was written because this has been the situation in OpenMCL (and MCL) 
for many years.

On Jan 27, 2005, at 12:23 PM, Cyrus Harmon wrote:

>
> Randy et al.,
>
> This is, of course, very cool, but I'd like to point out that other 
> implementations such as SBCL (SBCL on PPC) don't cons on this example. 
> Clearly different compilers have strengths and weaknesses and OpenMCL 
> is great at a lot of things. While use fpc-ppc is a reasonable answer, 
> two other alternatives come to mind. First, I'm by no means an expert 
> in lisp compiler declarations, so it seemed reasonable that there 
> might be something I was forgetting here that would keep OpenMCL from 
> consing. Second, assuming all the declare options are correct, is 
> there anything that can be done in the compiler to fix this? I know 
> Gary Byers has better things to do than explain compiler internals to 
> folks like me all day, but if anyone knows why we're consing here, I'd 
> love to hear the answer.
>
> Thanks,
>
> Cyrus
>
>
> On Jan 27, 2005, at 5:37 AM, Randall Beer wrote:
>
>> Cyrus,
>>
>> This is pretty much the kind of thing that FPC-PPC 
>> (http://vorlon.cwru.edu/~beer/index.html#software) was written for:
>>
>> ? (flet ((foo ()
>>             (declare (optimize (speed 3) (safety 0) (space 0)))
>>             (let ((z 2.0d0))
>>               (WITH-TEMP-DOUBLE-FLOATS (a)
>>                 (dotimes  (i 500000)
>>                   (declare (fixnum i))
>>                   (%SET-DOUBLE! a (+ a z)))
>>                 (%COPY-FLOAT a)))))
>>        (time (foo)))
>>
>> (FOO) took 16 milliseconds (0.016 seconds) to run.
>> Of that, 20 milliseconds (0.020 seconds) were spent in user mode
>>          0 milliseconds (0.000 seconds) were spent in system mode
>>  16 bytes of memory allocated.
>> 1000000.0D0
>>
>> Randy
>>
>>
>> On Jan 26, 2005, at 8:01 PM, Cyrus Harmon wrote:
>>
>>> In OpenMCL:
>>>
>>> (FOO) took 760 milliseconds (0.760 seconds) to run.
>>> Of that, 150 milliseconds (0.150 seconds) were spent in user mode
>>>          50 milliseconds (0.050 seconds) were spent in system mode
>>>          560 milliseconds (0.560 seconds) were spent executing other 
>>> OS processes.
>>> 361 milliseconds (0.361 seconds) was spent in GC.
>>>  8,000,000 bytes of memory allocated.
>>>
>>> 1000000.0D0
>>
>




More information about the Openmcl-devel mailing list