> >>>>> "Michael" == Michael Naunton <[EMAIL PROTECTED]> writes: > > Michael> On Mon, 2003-10-27 at 17:11, rif wrote: > >> > >> 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. > >> > > Michael> I'd also buy Raymond's explanation. There are things > Michael> going on with the optimizer that I don't understand. > > But my guess is probably wrong. I looked at the generated assembly. > Only a couple of FP registers are in use. > > Another bit of info. Every time I've seen this they've all had the > same construct: > > (let ((x <init>)) > (declare (double-float x)) > <some code that setf's x> > x)
But in my example, best-dist is not returned. Only index (a fixnum) is returned, and there are no compiler notes associated with fixnum. In this case, it seems like your out-of-registers explanation is correct. l2-distance-squared is an inlined function that seems like it'd use quite a few floating point registers. Furthermore, if I uninline l2-distance-squared, this particular compiler note goes away. (The whole program gets much slower, because I get an extra function call and a floater-to-point conversion for EVERY iteration, but at least that particular warning goes away.). In response to something else you said earlier, about array dimensions, my programs in general take arrays where the length is fixed over the course of an "experiment", but I don't want to recompile between experiments, when the array lengths often do change. When I use an array, I almost invariably iterate over the entire array, and these arrays often have hundred or thousands of elements. So my intuition is always that it's worth optimizing the O(n) operation (making sure I don't have to cons or convert for each element of the array), but that doing a length check at the beginning is an O(1) operation which will be amortized away. Does this seem reasonable? Note that in AllegroCL the situation is somewhat different, in that it's crucially important to declare that your arrays are 1D: (declare (type (simple-array fixnum *) foo)) rather than (declare (type (simple-array fixnum) foo)) but in CMUCL I don't believe this makes any difference. Cheers, rif
