Re: [eigen] PyEigen 0.1 released

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



Hi Jussi,

nice job, I'm sure many users will be very happy to see this project.

Now, I'm curious, and I wanted to estimate the overhead of such a wrapper. So I ran your mini benchmark and got:

PyEigen
Add: [0.086457014083862305, 0.079709053039550781, 0.079714059829711914]
Multiply: [0.085667133331298828, 0.085672140121459961, 0.085747003555297852]
Scalar multiply: [0.10933780670166016, 0.10931515693664551, 0.11152315139770508]

Since a simple matrix add appears to be as costly as a simple scalar multiple or matrix addition, it is pretty clear that the overall cost is largely dominated by the common overhead, and that the real computation cost is negligible. So I ported your benchmark to c++ (using non inlined wrapper functions doing the add, mul and scale) and as expected I got:

add  0.00450739s
mul  0.0172055s
scal 0.00451088s

For the record is the mul function I benched:
EIGEN_DONT_INLINE Matrix4f mul(Matrix4f& a, Matrix4f& b) { return a*b; }

Then I've seen the python wrapper creates all objects on the heap, so I've also tried variants doing so, e.g. the mul function becomes:

EIGEN_DONT_INLINE Matrix4f* mul(Matrix4f& a, Matrix4f& b) { Matrix4f* r = new Matrix4f; *r = a*b; return r; }

and I got:

add  0.0576869
mul  0.064709
scal 0.0592508

meaning the overhead of such a wrapper is largely dominated by calls to operator new. So maybe the conclusions of that could be:
- is there a way to reduce such heap allocations ? and if not:
- for the user prefer "inplace" operators whenever it is possible
- functions like add(a,b,r) doing r = a+b would be ugly but much faster than r = a+b,
  well, unless there is a way in python to map r = a+b to add(a,b,r) ?
- I'm only nitpicking ? ;)


cheers,
gael




2010/3/24 Jussi Lepistö <jussi.lepisto@xxxxxx>
I’m happy to announce PyEigen, a new linear algebra module for Python that’s many times faster than existing solutions. Notably, PyEigen is about 10x faster than NumPy for 4×4 matrix multiplication and 4x faster than cgkit 1.2.0, the fastest current solution.

Python Package Index:
http://pypi.python.org/pypi/PyEigen/

Launchpad project page:
http://launchpad..net/pyeigen

Development blog:
http://www.brainfold.org/blog

About
=====

PyEigen is a Python wrapper for the C++ linear algebra library Eigen.

PyEigen is currently considered PRE-ALPHA quality software and has not been widely tested outside the unit tests. The API is not stable yet and might change between releases without warning. Testing and all kinds of feedback are welcome however! Compatibility reports with different operating systems, compilers and Python versions are especially welcome.

Features
========

The first release of PyEigen includes basic support for fixed-size vectors (2-4-dimensional) and matrices (2×2, 3×3 and 4×4).





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/