If matrix-ref is inlined into the calculation
(fl+ a (fl* (matrix-ref m1 i k) (matrix-ref m2 k j))))))))))))))
then there is even greater speedup, partly because no flonums need to be boxed as return values of matrix-ref. The compiler inlines some uses, but I tried to inline all uses with inlining-limit, but failed (bug 117, I think), but after writing matrix-ref and matrix-set! as macros, I get the following runtimes (on a different machine than before).
Original code (but compiled using gsc -exe, so twice as fast as original report, "with all possible optimizations turned on"): 1344 ms cpu time (1340 user, 4 system) Using declarations, fixnum- and flonum-specific operations, and f64vectors: 784 ms cpu time (776 user, 8 system) Using named let: 336 ms cpu time (328 user, 8 system) Inlining all (not just some) instances of matrix-ref and matrix-set!: 124 ms cpu time (120 user, 4 system)
I'm planning to use Gambit again in my numerical PDE class next semester, so I'd like to win these benchmark games ;-).
Brad
On Thu, 2009-10-15 at 12:22 -0400, Bradley Lucier wrote:
Marc:
At the end of this message I suggest a compiler transformation of do-loops that doubles the speed of the sample code.
A matrix multiplication benchmark recently was posted to the Chicken list, see the thread beginning here:
http://lists.gnu.org/archive/html/chicken-users/2009-10/msg00050.html
The Gambit version of the benchmark has no Gambit-specific declarations, uses generic vectors and arithmetic.