lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 8/4/09, Asko Kauppi <askok@dnainternet.net> wrote:
>
>  I'd like to make a point that such GC-avoiding optimizations only make sense (imho) when matrices are rather small in size. That is, when the pure mathematical time taken does not grow essential.
>
>  Or am I wrong?
>
>  We're currently using Lua for matrix calculations with matrix sizes around 50x60 to 500x600. Operations are SSE optimized, but we do not do any operation merging or GC avoidance.
>
>  - asko

In general, the "temporaries in a loop" problem bites at both ends of
the spectrum.
For large matrices (complex number matrix 1000x1000) GC will run on
almost every iteration. In  addition, moving massive matrices from
heap to CPU cache and back will cause CPU cache misses and defeat
processor optimizations. For small matrices, excessive calls to malloc
slow you down. Also when GC runs it will have to collect lots of small
objects and it is slow. In general, in numerics you simply do not
allocate/free any resources inside the loops. Fortran does it all
nicely for you in a compiler. C/C++ folks manage resources manually.
C++ has also "expressions template" approach which uses template
mechanism to rewrite expressions but  it is compile time thing and is
useless for Lua expressions that are run-time entities.

--Leo--