Yes, l2-distance-squared is inlined.  I don't personally see how the
lack of this could be causing a problem converting between dist and
best-dist --- they are both double-floats, and they are both declared
as double-floats, so I'd hope the conversion happens without going
through float-to-pointer.

I'm tenatively guessing that Raymond's suggestion that the system's
out of FP registers is the issue.

rif

> Did you try declaring l2-distance-squared inline?  I'm guessing that's
> the root of the note message.  Probably accounts for all the consing
> too.
> 
> -- MMN
> 
> On Mon, 2003-10-27 at 13:58, rif wrote:
> > 
> > I'm trying to optimize the following function (yes, profiling
> > indicates that this function is the bottleneck, it's taking the lion's
> > share of the time and the consing).
> > 
> > (defun find-closest-index (point centers)
> >   (declare (type simple-array centers)
> >            (type (simple-array double-float) point))
> >   (let ((best-dist most-positive-double-float)
> >         (dist 0.0d0)
> >         (index -1))
> >     (declare (type fixnum index)
> >              (type double-float best-dist)
> >          (type double-float dist))
> >     (fixtimes (i (array-dimension centers 0))
> >        (let ((c (aref centers i)))
> >          (declare (type (simple-array double-float) c))
> >      (setf dist (the double-float (l2-distance-squared point c)))
> >        (when (< dist best-dist)
> >          (progn
> >            (setf index i)
> >            (setf best-dist dist)))))
> >     index))
> > 
> > 
> > One of the compiler notes (settings were speed 3, debug and safety 0)
> > for this function is:
> > 
> > ;   (SETF BEST-DIST DIST)
> > ; ==>
> > ;   (SETQ BEST-DIST DIST)
> > ; Note: Doing float to pointer coercion (cost 13) from DIST to BEST-DIST.
> > 
> > And I cannot for the life of me figure out why I'm getting this.  Any
> > ideas?
> > 
> > Cheers,
> > 
> > rif
> > 
> > ps.  Yes, I know that not all of the current type declarations are
> > necessary.  I'm still in the "better safe than sorry" stage of
> > debugging.  Once I can get that pesky conversion gone, I'll figure out
> > which other type declarations are unnecessary.
> > 
> 
> 


Reply via email to