In response to my earlier post about hidden memory allocations, Jason Cornez pointed out how to rework my loop so that Allegro wouldn’t need to allocate memory. The new structure avoids using the summing keyword in (loop …) and doesn’t use the return-value from (loop …).
(simple-array single-float (3))
(simple-array single-float (3)))
(simple-array single-float (3))) mvl*-na))
(declare (type (simple-array single-float (12)) matrix)
(type (simple-array single-float (3)) vec)
(type (simple-array single-float (3)) ret)
(optimize (speed 3) (safety 0)))
(loop for jj fixnum from 0 below 3
do (let ((offset (* jj 4)))
(declare (type fixnum offset))
(let ((current (aref matrix (+ offset 3))))
(declare (type single-float current))
(loop for ii fixnum from 0 below 3
for kk fixnum from offset below (+ offset 3)
do (incf current
(* (aref vec ii)
(aref matrix kk))))
(setf (aref ret jj) current))))
Now, the Allegro moved up in the rankings. All of the implementations (except 32-bit Clozure) ran slightly faster with this version. Allegro improved the most here though as its allocation/garbage dropped to nothing.
|Allegro 8.1 (Personal)||0.720s||0.720s||0|
|Clozure-64bit 1.3-r11936||1.100s||1.100s||?? 0|
|LispWorks 5.1 (Personal)||12.587s||??||3,120,000,516|
|GNU CLISP 2.47||88.008s||74.455s||2,160,000,000|
CMUCL compiled with 30 Notes. I should look into those some time. It still ran quite fast though.
Allegro definitely liked this version better. It kept from allocating anything.
For comparison, I am including the previous runtimes here as well:
|Clozure-64bit 1.3-r11936||1.272s||1.272s||?? 0|
|Allegro 8.1 (Personal)||6.131s||2.120s||1,440,000,000|
|LispWorks 5.1 (Personal)||14.054s||??||3,360,000,480|
|GNU CLISP 2.47||93.190s||77.356s||2,520,000,000|