[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: question about cdata type identification
- From: Francesco Abbate <francesco.bbt@...>
- Date: Mon, 18 Apr 2011 18:14:46 +0200
2011/4/18 Adam Strzelecki <ono@java.pl>:
> Francesco, do you by change hook to BLAS or you roll your own matrix manipulation functions directly in Lua?
Hi Adam,
I've already made a good bit of work in this direction. I'm using the
BLAS routine for low level operation, to use Lua to unroll everything
would be a waste of time. Actually I'm not using the BLAS library
directly but the GSL BLAS function that provides the BLAS function but
for GSL matrix/vector objects.
My implementation of a matrix module with FFI use the GSL matrix C
objects and I found this approach very convenient. To work directly
with array is possible but it does add a lot of small details and
potential errors thta make programming more awkward. GSL function are
designed smartly to provide a good wrapper for the concept of
matrix/vector and are yet flexible enough to perform all the
operations that you could perform with low-level arrays.
> 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.
May be we can share our work. I've already a starting implementation
that basically work with LuaJIT from the git HEAD.
> 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.
Matrix accessor is my big big pain!!! The option M[x][y] is highly
inefficient but somewhat convenient. I'm using the direct access
M[M.pitch * y + x] for optimized routine but I propose the syntax:
m:get(i, j)
to the user. Quite ugly but I don't have anything better. M[x] to
obtain a row is implemented but it is inefficient because it does
generate a new object and copy the data each time.
I hope that we will find a solution with Mike for this problem. We
have already 99% of what we need...
--
Francesco