[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT2 performance for number crunching
- From: Alex Bradbury <asb@...>
- Date: Wed, 16 Feb 2011 14:23:42 +0000
On 16 February 2011 13:30, steve donovan <steve.j.donovan@gmail.com> wrote:
>> http://snippets.luacode.org/snippets/Lua_Preprocessor_118, though
>> providing a preprocess function that takes an environment argument.
>
> Yes, that's the way to go... Still thinking about how to organize
> template 'instantiation' since a template function may depend on
> several other template functions.
I just do something like this:
local rlhat_templ = [[
$(include(check_mem_range, {addr=addr, memsize=memsize}))
$(include(check_mem_alignment, {addr=addr, mask=mask}))
local read_result = ffi_cast($(ffitype), cpu.memory + $(addr))[0]
]]
Where check_mem_* are template strings and include is my preprocessor
function, which takes an environment as its second argument. There's
not much need for explicitly creating a new environment - I could just
pass the current environment (accessible as ENV) to the sub-template.
I try to pass all helper functions in as part of the environment so
they can be reused easily across different templates. e.g. I
frequently have $(GETREG(rd)) which returns either 0 or the equivalent
of cpu.regs[$(rd)] depending on if rd == 0. My hope is this will allow
LuaJIT to optimise away instances of bit.bor($(imm), 0) and the like,
which occur pretty frequently. Though I haven't checked to see if it
does this yet.
Alex
- References:
- LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Mike Pall
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Mike Pall
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, Florian Weimer
- 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, Leo Razoumov
- Re: LuaJIT2 performance for number crunching, Francesco Abbate
- Re: LuaJIT2 performance for number crunching, T T
- Re: LuaJIT2 performance for number crunching, steve donovan
- Re: LuaJIT2 performance for number crunching, Alex Bradbury
- Re: LuaJIT2 performance for number crunching, steve donovan