From: Andreas Eder on
Hi Mirko,

>>>>> "Mirko" == Mirko <mirko.vukovic(a)gmail.com> writes:

Mirko> With maximum optimization, I am getting warnings in the following code
Mirko> (elided here)
Mirko> (declare (fixnum index))
Mirko> (floor (sqrt (coerce index 'float)))

Since the index is probably a positive integer :-)
you could replace that piece of code by:
(declare (fixnum index))
(isqrt index)
This should not give a warning and is probably even faster.

Andreas

--
ceterum censeo redmondinem esse delendam.
From: Mirko on
On Jun 10, 1:18 am, Andreas Eder <andreas_e...(a)gmx.net> wrote:
> Hi Mirko,
>
> >>>>> "Mirko" == Mirko  <mirko.vuko...(a)gmail.com> writes:
>
>     Mirko> With maximum optimization, I am getting warnings in the following code
>     Mirko> (elided here)
>     Mirko>  (declare (fixnum index))
>     Mirko>  (floor (sqrt (coerce index 'float)))
>
> Since the index is probably a positive integer :-)
> you could replace that piece of code by:
>   (declare (fixnum index))
>   (isqrt index)
> This should not give a warning and is probably even faster.
>
> Andreas
>
> --
> ceterum censeo redmondinem esse delendam.

I did not know about isqrt - thanks :-)

However, in my case (sbcl), (floor (sqrt ...)) gives a faster
performance than isqrt (6.4 vs 7.8 sec). Also, (unsigned-byte 32)
gives faster than fixnum (7.8 vs 9.1 sec)

Mirko
From: Raymond Toy on
On 06/10/2010 08:54 AM, Mirko wrote:
> On Jun 10, 1:18 am, Andreas Eder<andreas_e...(a)gmx.net> wrote:
>> Hi Mirko,
>>
>>>>>>> "Mirko" == Mirko<mirko.vuko...(a)gmail.com> writes:
>>
>> Mirko> With maximum optimization, I am getting warnings in the following code
>> Mirko> (elided here)
>> Mirko> (declare (fixnum index))
>> Mirko> (floor (sqrt (coerce index 'float)))
>>
>> Since the index is probably a positive integer :-)
>> you could replace that piece of code by:
>> (declare (fixnum index))
>> (isqrt index)
>> This should not give a warning and is probably even faster.
>>
>> Andreas
>>
>> --
>> ceterum censeo redmondinem esse delendam.
>
> I did not know about isqrt - thanks :-)
>
> However, in my case (sbcl), (floor (sqrt ...)) gives a faster
> performance than isqrt (6.4 vs 7.8 sec). Also, (unsigned-byte 32)

This doesn't surprise me. (floor (sqrt index)) could be 3 instructions:
convert int to float, fsqrt, convert float to int.

isqrt has no hardware assist (I think), so many instructions are needed
to compute isqrt.

Ray
From: Mirko on
On Jun 10, 11:18 am, Raymond Toy <toy.raym...(a)gmail.com> wrote:
> On 06/10/2010 08:54 AM, Mirko wrote:
>
>
>
> > On Jun 10, 1:18 am, Andreas Eder<andreas_e...(a)gmx.net>  wrote:
> >> Hi Mirko,
>
> >>>>>>> "Mirko" == Mirko<mirko.vuko...(a)gmail.com>  writes:
>
> >>      Mirko>  With maximum optimization, I am getting warnings in the following code
> >>      Mirko>  (elided here)
> >>      Mirko>    (declare (fixnum index))
> >>      Mirko>    (floor (sqrt (coerce index 'float)))
>
> >> Since the index is probably a positive integer :-)
> >> you could replace that piece of code by:
> >>    (declare (fixnum index))
> >>    (isqrt index)
> >> This should not give a warning and is probably even faster.
>
> >> Andreas
>
> >> --
> >> ceterum censeo redmondinem esse delendam.
>
> > I did not know about isqrt - thanks :-)
>
> > However, in my case (sbcl), (floor (sqrt ...)) gives a faster
> > performance than isqrt (6.4 vs 7.8 sec).  Also, (unsigned-byte 32)
>
> This doesn't surprise me.  (floor (sqrt index)) could be 3 instructions:
>   convert int to float, fsqrt, convert float to int.
>
> isqrt has no hardware assist (I think), so many instructions are needed
> to compute isqrt.
>
> Ray

I noticed that using isqrt reduced consing, by a factor of four or so.
From: Raymond Toy on
On 6/10/10 11:36 AM, Mirko wrote:
> On Jun 10, 11:18 am, Raymond Toy <toy.raym...(a)gmail.com> wrote:
>> On 06/10/2010 08:54 AM, Mirko wrote:
>>
>>
>>
>>> On Jun 10, 1:18 am, Andreas Eder<andreas_e...(a)gmx.net> wrote:
>>>> Hi Mirko,
>>
>>>>>>>>> "Mirko" == Mirko<mirko.vuko...(a)gmail.com> writes:
>>
>>>> Mirko> With maximum optimization, I am getting warnings in the following code
>>>> Mirko> (elided here)
>>>> Mirko> (declare (fixnum index))
>>>> Mirko> (floor (sqrt (coerce index 'float)))
>>
>>>> Since the index is probably a positive integer :-)
>>>> you could replace that piece of code by:
>>>> (declare (fixnum index))
>>>> (isqrt index)
>>>> This should not give a warning and is probably even faster.
>>
>>>> Andreas
>>
>>>> --
>>>> ceterum censeo redmondinem esse delendam.
>>
>>> I did not know about isqrt - thanks :-)
>>
>>> However, in my case (sbcl), (floor (sqrt ...)) gives a faster
>>> performance than isqrt (6.4 vs 7.8 sec). Also, (unsigned-byte 32)
>>
>> This doesn't surprise me. (floor (sqrt index)) could be 3 instructions:
>> convert int to float, fsqrt, convert float to int.
>>
>> isqrt has no hardware assist (I think), so many instructions are needed
>> to compute isqrt.
>>
>> Ray
>
> I noticed that using isqrt reduced consing, by a factor of four or so.

Well, since you only posted a small amount of code, it's really hard to
come up with any kind of overall conclusion. It is a bit surprising
that consing is reduced unless you still get compiler notes about (float
(sqrt index)).

Ray