Liam,
I'm sorry, I now see a difference between the original gref* and your modified version of it. I guess I forgot to reload the Lisp image last time, so both timings had been obtained using the new gref*. There is still consing, but it's already reduced by a factor of three. Can be reduced by a further ~60% by using (the double-float (grid:gref* ...)) instead of just gref*; I assume this is due to to the float->pointer coercion done to gref*'s <return-value>.(?) Here's the new timing data (dim = 15):
"gref" Evaluation took: 0.063 seconds of real time 0.056171 seconds of total run time (0.044926 user, 0.011245 system) [ Run times consist of 0.006 seconds GC time, and 0.051 seconds non-GC time. ] 88.89% CPU 28 lambdas converted 137,624,278 processor cycles 4,032,960 bytes consed
"gref*" Evaluation took: 0.012 seconds of real time 0.011932 seconds of total run time (0.011929 user, 0.000003 system) 100.00% CPU 26,178,823 processor cycles 785,360 bytes consed
"modified gref*" Evaluation took: 0.001 seconds of real time 0.001202 seconds of total run time (0.000884 user, 0.000318 system) 100.00% CPU 3,126,090 processor cycles 278,512 bytes consed
"hardwired cffi:mem-aref" Evaluation took: 0.000 seconds of real time 0.000033 seconds of total run time (0.000032 user, 0.000001 system) 100.00% CPU 66,462 processor cycles 0 bytes consed
I have attached the lisp file used to obtain these timings.
thanks, Sebastian