Re: [eigen] PyEigen 0.1 released |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] PyEigen 0.1 released*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Wed, 24 Mar 2010 11:50:49 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=UKiZ/ehTwuMJTnjhEh9lEr90rcin0vhLVClAjdHLrnM=; b=QA72yo/1VJViFmOMlffzrFAq5E08BdMlhFbANTxApAAvE72OaD7DWDPQTm/q1UI1mW Oy9gbiv2tBjqNdogBB9Fx9PMpO0YpjXYYhqFBlnssOxnLQrCpwXI2LHl6XCVeevGOCdz jZRrTo/d+bwg6QvgLIweOQMWVL8J4qGWAhg6E=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=QvVILGcckPnk9yC69740JOfa/58i1XquNI7P2H2HEvXnM2r0P60nP8gyz2/m5zWJfK u0lUkAGRAHOGJEklTbYSGaquoIdUrhFnsLfCm0nJ2akA+E8B4HKKgN2FTID6rK5r5n9G iQfmCXHmhPXCuxbVQRPguZvGiyLHVdTOuNMmQ=

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).

**Follow-Ups**:**Re: [eigen] PyEigen 0.1 released***From:*Jussi Lepistö

**References**:**[eigen] PyEigen 0.1 released***From:*Jussi Lepistö

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] PyEigen 0.1 released** - Next by Date:
**Re: [eigen] PyEigen 0.1 released** - Previous by thread:
**[eigen] PyEigen 0.1 released** - Next by thread:
**Re: [eigen] PyEigen 0.1 released**

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