[SciPy-Dev] Speeding up scipy.special.erf()?

Travis Oliphant travis at continuum.io
Sat Mar 21 00:13:37 EDT 2015


I have not tested this, but I suspect that the MATLAB routine is using the
erf implementation from the Intel Math Kernel Libraries (MKL).

There is a function in MKL called vdErf that takes a vector of doubles and
is likely tuned to the hardware.    This could be linked to NumPy with
similar speed benefits.

-Travis


On Fri, Mar 20, 2015 at 5:02 PM, Julian Taylor <
jtaylor.debian at googlemail.com> wrote:

> On 20.03.2015 22:08, Pauli Virtanen wrote:
> > 20.03.2015, 20:29, Will Adler kirjoitti:
> > [clip]
> >> Is there anything that can be done to speed up SciPy’s erf()?
> >
> > Possibly.
> >
> >
> https://github.com/scipy/scipy/blob/master/scipy/special/cephes/ndtr.c#L483
> >
> > The simplest thing would probably be just to write the Pade approximant
> > in a form the C compiler can inline. erf and erfc are also in C99, so
> > glibc may have a fast implementation.
> >
>
> using glibc is unlikely to be faster, as they focus on correctness and
> not speed. Though its worth a try.
>
> The two 4 coefficient evaluations can be perfectly vectorized, just
> needs rearranging the static coefficient tables, that should give a
> decent speedup.
> Also the isnan call could be turned into a builtin instead of the
> function call gcc/glibc does.
> In total with this implementation I guess 40-50% improvement should be
> possible.
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>



-- 

Travis Oliphant
CEO
Continuum Analytics, Inc.
http://www.continuum.io
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20150320/52936b02/attachment.html>


More information about the SciPy-Dev mailing list