[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT2 performance for number crunching
- From: Mike Pall <mikelu-1102@...>
- Date: Thu, 17 Feb 2011 11:33:06 +0100
T T wrote:
> [...] and added a big loop at the end, so it runs for a bit.
You're passing a new closure every time -- don't do that. The
compiler specializes to each one of them and bad things happen.
Write that stuff as:
local function f(x,y)
return x+y
end
for i=1,1e5 do
ode_dormandprince(f, 0, 1, 1.24, 1e-5, 1, 0.01, 1000)
end
print(ode_dormandprince (f, 0, 1, 1.24, 1e-5, 1, 0.01, 1000))
This improves the runtime by an order of magnitude!
Also, the variant with the inline constants is 10% faster and the
generated machine code is about 40% less (2.8K vs. 4.6K on x64).
The effects on performance are less pronounced with FP constants
than with integer constants. I think this matches my prediction
quite well.
> Is code
> templating/specialization/manual unrolling the only way to address
> that in luajit? Wouldn't it be possible to do something like in the
> example I posted earlier?
There are three different issues:
1. Actual constness of variables that is undetected: needs
global bytecode analysis. Tricky.
2. Specializing to the actual value of a variable (pseudo-const):
needs manually inserted directives; variable may lose this
property if stored/reloaded.
3. Different loop unrolling heuristics: probably needs manually
inserted directives, too.
Not that simple -- send a patch. :-)
--Mike
- References:
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, T T
- Re: LuaJIT2 performance for number crunching, Daurnimator
- Re: LuaJIT2 performance for number crunching, Mike Pall
- Re: LuaJIT2 performance for number crunching, Philippe Lhoste
- Re: LuaJIT2 performance for number crunching, Alexander Gladysh
- Re: LuaJIT2 performance for number crunching, Miles Bader
- Re: LuaJIT2 performance for number crunching, T T