lua-users home
lua-l archive

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


On Thu, Feb 10, 2011 at 12:51 PM, Geoff Leyland
<geoff_leyland@fastmail.fm> wrote:
> On 11/02/2011, at 7:12 AM, Mike Pall wrote:
>
>> So what magical things does that C++ code do and why can this not
>> be written in Lua? No, you don't have to answer that, better work
>> on fixing it.
>
> One use case is calling Lua functions from numerical libraries.  For example, ipopt [1] is a C++/FORTRAN library that finds a local minimum of a nonlinear optimisation problem.  ipopt calls a set of user-defined functions to evaluate objective functions, constraints and various derivatives.  Rima has an interface to ipopt now, so in that case ipopt is calling Lua functions repeatedly.
>
> You're right, someone *could* rewrite ipopt in Lua, but, for me at least, that seems about as hard as rewriting LuaJIT would be, and anyway, maybe next week I'll want to use couenne [2].  I don't expect any magic from LuaJIT to help in this situation, but I think it does occur legitimately.

If I understand correctly, someone could use ipopt from within LuaJIT,
with callbacks written in Lua (as soon as Mike finishes adding
callbacks to the FFI), and then they would get close to the same
performance if the entire thing was written in C, right?

Also, in Shawn's case, if he could call into his C/C++ main loop using
the FFI, after also using the (as yet unimplemented) callback
functionality to register his Lua callbacks with the C/C++ code, then
he would also reap the benefits of having his lua code JITed?

If my understanding of this is correct, then I'm very much looking
forward to being able to use the FFI callback functionality.

>
>
> Cheers,
> Geoff
>
>
> [1] https://projects.coin-or.org/Ipopt
> [2] https://projects.coin-or.org/Couenne
>
>
>
>



-- 
Paul Bonser
http://probablyprogramming.com