[Numpy-discussion] numpy gsoc topic idea: configurable algorithm precision and vector math library integration

Julian Taylor jtaylor.debian at googlemail.com
Mon Mar 3 14:20:31 EST 2014


hi,

as the numpy gsoc topic page is a little short on options I was thinking
about adding two topics for interested students. But as I have no
experience with gsoc or mentoring and the ideas are not very fleshed out
yet I'd like to ask if it might make sense at all:

1. configurable algorithm precision

some functions in numpy could be implemented in different ways depending
on requirements on speed and numerical precision.
Two examples that come to my mind are hypot and sum

hypot (or abs(complex)) use the C99 hypot function which guarantees 1ulp
precision but is very slow compared to a simple sqrt(a**2 +b**2).
This precision might not be required for all applications, overflow
safety might be enough.

summation in numpy 1.9 is performed via pairwise summation which has
O(log(n)*e) error properties, but only for the fast axis.
An alternative O(e) approach would be kahan summation which works for
all axis but is 4 time slower than normal summation (a bit can be
regained via vectorization thought)

My idea is have an option to change the algorithms used in numpy
depending on the set requirements.
E.g.

with np.precmode(default="fast"):
  np.abs(complex_array)

or fast everything except sum and hypot

with np.precmode(default="fast", sum="kahan", hypot="standard"):
  np.sum(d)

I have not though much about implementation, it might be tricky to get
this threadsafe in the current ufunc model.

2. vector math library integration

some operations like powers, sin, cos etc are relatively slow in numpy
depending on the c library used. There are now a few free libraries
available that make use of modern hardware to speed these operations up,
e.g. sleef and yeppp (also mkl but I have no interest in supporting
non-free software)
It might be interesting to investigate if these libraries can be
integrated with numpy.
This also somewhat ties in with the configurable precision mode as the
vector math libraries often have different options depending on
precision and speed requirements.

Do those sound like topics we could add to our wiki?



More information about the NumPy-Discussion mailing list