[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: question about cdata type identification
- From: Adam Strzelecki <ono@...>
- Date: Mon, 18 Apr 2011 15:39:19 +0200
> I'm currently working on a matrix module based on LuaJIT2 plus FFI
> without any use of any C wrapper functions. The module should permit
> to work with both real and complex number and I'm planning to have
> generic arithmetic operations that can operate with mixed operands of
> real/complex number or real/complex matrices.
Francesco, do you by change hook to BLAS or you roll your own matrix manipulation functions directly in Lua?
I had a similar idea (started some initial work) to get some basic matrix manipulation done with BLAS (Accelerate.framework on Mac) using LuaJIT with FFI, as BLAS seems to be heavily optimized with SSE. There are also CUDA from NVIDIA and OpenCL from AMD BLAS implementations that use GPU, which make big difference if you work on big matrices. I think these can be also easily accessed with FFI too.
Also I thought about having accessors for matrix values with LuaJIT + FFI, so I can write M[x][y] instead of M[M.pitch * y + x] to get cell's value, or M[row] to get matrix row.
> I can imagine some workarounds but these solutions are all not
> satisfying and I have the feeling that we lack a primitive FFI
> function to have information about the C type of a cdata object.
Yeah, also I wished there was a way to get number of elements of FFI allocated VLA. I wonder if FFI does remember that somewhere, I think it does as there's an optimizer option to disable/enable checking for VLA index ranges. Otherwise we would need to store this number somewhere close the the cdata too. And when talking about matrices we need also store size of all dimensions.