devitocodes / notebooks

BSD 3-Clause "New" or "Revised" License
1 stars 3 forks source link

Numpy-fication vs. Sympy.ufuncify/autowrap #1

Open mlange05 opened 8 years ago

mlange05 commented 8 years ago

Starting from the excellent symbolic description of the Acoustic wave equation provided by @mloubout we now want to speed-up the basic python version of the equation. However, since we are performing a stencil computation the traditional Numpy-fication tricks of applying operations over arrays become very wasteful in terms of memory, because we effectively need to to replicate the matrix for each stencil point. This is illustrated in the bottom figure of this page.

Fortunately, the problem of applying complex Sympy expressions to numeric systems is known and documented here. In particular the ufuncify functionality, or the even lower level autowrap module that provide some control of the JIT process, should allow us to turn the expression stencil in the acoustic wave equation notebook into a compiled function that can be applied to the numpy arrays that represent our grid. This should speed up the notebook computation significantly and give us insights into the necessary steps to generate the core computation kernels, as well as a baseline performance target that opesci-fd will aim to beat.

navjotk commented 8 years ago

@mloubout Please see PR #4 ,implemented using autowrap. A choice based on the simple fact that it seemed to be the easiest to implement of the available options. I'd like some feedback on whether the results are equivalent.