Sorry I should have been more clear. I was thinking the actual sample you provided should be included on http://luajit.org/ext_ffi_tutorial.html or added as a example in a sub page. I did read the FFI section but more examples that are small but meaningful will make it easier to get started. eg: http://pastebin.com/24tkRwGA.
On 12/10/2014 12:02 PM, Stefano wrote:
On 10 Dec 2014 19:58, "Joe Ellsworth" <joexdobs@xxxxxxxxx <mailto:joexdobs@xxxxxxxxx>> wrote:>> Just what I wanted. I think it would be worth adding this to the FFI section on the web site.It's listed on the relevant LuaJIT wiki page: http://wiki.luajit.org/FFI-Native-Libraries You might find other libraries useful to your work on that page as well. Stefano > > > On 12/10/2014 11:50 AM, Stefano wrote: >> >>>> On 10 Dec 2014 18:39, "Szabó Antal" <szabo.antal.92@xxxxxxxxx <mailto:szabo.antal.92@xxxxxxxxx>> wrote:>> >>> > 2014-12-10 19:15 GMT+01:00 Joseph Ellsworth <joexdobs@xxxxxxxxx <mailto:joexdobs@xxxxxxxxx>>:>> >>>> >> The sample / example would allocate the array, Fill it with a set of doubles read from a file, Run the sum and return both the sum and average value.>> > >> >>> > Here is a sample code for what I suppose you want: http://pastebin.com/cj7jShfj>> >>> > The summation loop looks like this in x64 assembly (use -jdump with luajit to get it):>> > >> > ->LOOP: >> > 7ffc8350ff80 addsd xmm7, [rax+rdi*8+0x8] >> > 7ffc8350ff86 add edi, +0x01 >> > 7ffc8350ff89 cmp edi, 0x270f >> > 7ffc8350ff8f jle 0x7ffc8350ff80 ->LOOP >> >>> > As far as I can tell, this is the shortest and fastest you can get without using vector instructions, which LuaJIT doesn't currently support.>>>> For something more end-user-friendly (for this project at least) than bare FFI the author might be interested in my the algebra module of an open source project I'm working on:>> >> http://scilua.org/sci_alg.html >> >> Stefano >> >> > >> > >> > Antal Szabó > >