[pythran] Re: Trying to understand why Pythran does so well on the diffusion example

  • From: Pierrick Brunet <pierrick.brunet@xxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Sun, 13 Apr 2014 10:35:13 +0200

On 13/04/2014 09:07, serge Guelton wrote:
On Sat, Apr 12, 2014 at 05:42:04PM -0700, Mehdi Amini wrote:
Hi Ian,

I checked the evolve.py test case and I didn't find any magic :)
I would even say that we should be able to do *a lot* better in such
cases (lazy evaluation + fusion)...

Numpy is (only) two times slower but their implementation is in
Python and the algorithm is different.
Here is the numpy implementation: 
https://github.com/numpy/numpy/blob/master/numpy/core/numeric.py#L1314
Here is ours: 
https://github.com/numpy/numpy/blob/master/numpy/core/numeric.py#L1314
(yes our C++ is absolutely awful because of the lack of comments...)
At the C++ level, we also optimize the laplacian expression and the
evolve expression to avoid allocating temporary arrays (well, we still
perform one allocation per np.roll call, and one per laplacain call),
using expression templates, but other compilers should do it, there is
nothing new inside.



I did a test removing expression template in Pythran and we spend 1 more second : 1.18 to 2.08 s I think the only other difference could be roll implementation and ndarray representation.

Other related posts: