[Numpy-discussion] Possible to use numexpr with user made ufuncs/scipy ufuncs?
Mon Jun 28 03:57:53 CDT 2010
A Monday 28 June 2010 10:22:31 Pauli Virtanen escrigué:
> ma, 2010-06-28 kello 09:48 +0200, Francesc Alted kirjoitti:
> > But again, the nice thing would be to implement such a special functions
> > in terms of numexpr expressions so that the evaluation itself can be
> > faster. Admittedly, that would take a bit more time.
> Quite often, you need to evaluate a series or continued fraction
> expansion to get the value of a special function at some point, limiting
> the number of terms by stopping when a certain convergence criterion is
> satisfied. Also, which series to sum typically depends on the point
> where things are evaluated. These things don't vectorize very nicely. If
> I understand correctly, numexpr bytecode interpreter does not support
> conditionals and loops like this at the moment?
No, it does not support loops. And conditionals are supported only via
vectorized conditionals (i.e. the `where()` opcode).
> The special function implementations are typically written in bare
> C/Fortran. Do you think numexpr could give speedups there? As I see it,
> speedups (at least with MKL) could come from using faster
> implementations of sin/cos/exp etc. basic functions. Using SIMD to
> maximum effect would then require an amount of cleverness in re-writing
> the evaluation algorithms, which sounds like a major amount of work.
Okay. I thought that special functions were more 'vectorizable', or that it
could be expressed in terms of more basic functions (sin/cos/exp). But if
this is not the case, then it is quite clear that the best solution would be
your first suggestion (i.e. implement user-provide ufunc evaluation).
And definitely, implementing special functions in terms of SIMD would really
be a *major* effort, and only doable by very specialized people ;-)
More information about the NumPy-Discussion