[Numpy-discussion] dot() performance depends on data?
Charles R Harris
charlesr.harris@gmail....
Fri Sep 10 20:10:43 CDT 2010
On Fri, Sep 10, 2010 at 7:04 PM, David Cournapeau <cournape@gmail.com>wrote:
> On Sat, Sep 11, 2010 at 9:47 AM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
> >
> >
> > On Fri, Sep 10, 2010 at 6:41 PM, David Cournapeau <cournape@gmail.com>
> > wrote:
> >>
> >> On Sat, Sep 11, 2010 at 2:57 AM, Charles R Harris
> >> <charlesr.harris@gmail.com> wrote:
> >> >
> >> >
> >> > On Fri, Sep 10, 2010 at 11:36 AM, Hagen Fürstenau <
> hagen@zhuliguan.net>
> >> > wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I'm multiplying two 1000x1000 arrays with numpy.dot() and seeing
> >> >> significant performance differences depending on the data. It seems
> to
> >> >> take much longer on matrices with many zeros than on random ones. I
> >> >> don't know much about optimized MM implementations, but is this
> normal
> >> >> behavior for some reason?
> >> >>
> >> >
> >> > Multiplication by zero used to be faster than multiplication by random
> >> > numbers. However, modern hardware and compilers may have changed that
> to
> >> > pretty much a wash. More likely you are seeing cache issues due to
> data
> >> > localization or even variations in the time given the thread running
> the
> >> > multiplication.
> >>
> >> That's actually most likely a denormal issue. The a and b matrix (from
> >> mm.py) have many very small numbers, which could cause numbers to be
> >> denormal. Maybe a has more denormals than b. Denormal cause
> >> significant performance issues on Intel hardware at least.
> >>
> >> Unfortunately, we don't have a way in numpy to check for denormal that
> >> I know of.
> >>
> >
> > The matrices could be scaled up to check that.
>
> Indeed - and I misread the script anyway, I should not investigate
> this kind of things after waking up :)
>
> Anyway, seems it is indeed a denormal issue, as adding a small (1e-10)
> constant gives same speed for both timings.
>
Ah, that's probably one of the reasons the lapack lstsqr's routine scales
the matrices to a nice range. I was wondering.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100910/e1f1d4fd/attachment.html
More information about the NumPy-Discussion
mailing list