[Numpy-discussion] Numpy question: Best hardware for Numpy?

Francesc Alted faltet at pytables.org
Mon Sep 21 09:07:58 EDT 2009


A Monday 21 September 2009 13:59:39 Romain Brette escrigué:
> David Warde-Farley a écrit :
> > On 20-Sep-09, at 2:17 PM, Romain Brette wrote:
> >> Would anyone have thoughts about what the best hardware would be for
> >> Numpy? In
> >> particular, I am wondering about Intel Core i7 vs Xeon. Also, I feel
> >> that the
> >> limiting factor might be memory speed and cache rather than
> >> processor speed.
> >> What do you think?
> >
> > So, there are several different chips that bear the Xeon brand, you'd
> > have to look at individual benchmarks. But if you're concerned about
> > linear algebra performance, I'd say to go with the desktop version and
> > spend some of the money you save on a license for the Intel Math
> > Kernel Library to link NumPy against:
> > http://software.intel.com/en-us/intel-mkl/
> >
> > David
>
> Interesting, I might try Intel MKL. I use mostly element-wise operations
> (e.g. exp(x) or x>x0, where x is a vector), do you think it would make a
> big difference?

MKL should represent a big advantage for the exp(x) operation.  For example, 
numexpr, that can optionally make use of MKL, gives these figures:

In [1]: import numpy as np

In [3]: a = np.random.rand(1e7)

In [4]: timeit np.exp(a)
10 loops, best of 3: 251 ms per loop

In [5]: import numpy as np

In [6]: import numexpr as ne

In [7]: timeit ne.evaluate("exp(a)")
10 loops, best of 3: 78.7 ms per loop

That is, MKL's exp() is around 3x faster than plain C's exp().

You can also set different accuracy modes in MKL:

In [8]: ne.set_vml_accuracy_mode('low')
Out[8]: 'high'

In [9]: timeit ne.evaluate("exp(a)")
10 loops, best of 3: 70.5 ms per loop  # 3.5x speedup

In [10]: ne.set_vml_accuracy_mode('fast')
Out[10]: 'low'

In [11]: timeit ne.evaluate("exp(a)")
10 loops, best of 3: 62.8 ms per loop   # 4x speedup

For the x>x0, you won't get any speed-up from using MKL, as this operation is 
bounded by memory speed.

-- 
Francesc Alted



More information about the NumPy-Discussion mailing list