[Numpy-discussion] odd performance of sum?
eat
e.antero.tammi@gmail....
Thu Feb 10 11:53:51 CST 2011
Thanks Chuck,
for replying. But don't you still feel very odd that dot outperforms sum in
your machine? Just to get it simply; why sum can't outperform dot? Whatever
architecture (computer, cache) you have, it don't make any sense at all that
when performing significantly less instructions, you'll reach to spend more
time ;-).
Regards,
eat
On Thu, Feb 10, 2011 at 7:10 PM, Charles R Harris <charlesr.harris@gmail.com
> wrote:
>
>
> On Thu, Feb 10, 2011 at 8:29 AM, eat <e.antero.tammi@gmail.com> wrote:
>
>> Hi,
>>
>> Observing following performance:
>> In []: m= 1e5
>> In []: n= 1e2
>> In []: o= ones(n)
>> In []: M= randn(m, n)
>> In []: timeit M.sum(1)
>> 10 loops, best of 3: 38.3 ms per loop
>> In []: timeit dot(M, o)
>> 10 loops, best of 3: 21.1 ms per loop
>>
>> In []: m= 1e2
>> In []: n= 1e5
>> In []: o= ones(n)
>> In []: M= randn(m, n)
>> In []: timeit M.sum(1)
>> 100 loops, best of 3: 18.3 ms per loop
>> In []: timeit dot(M, o)
>> 10 loops, best of 3: 21.2 ms per loop
>>
>> One would expect sum to outperform dot with a clear marginal. Does there
>> exixts any 'tricks' to increase the performance of sum?
>>
>>
>
> I'm not surprised, much depends on the version of ATLAS or MKL you are
> linked to. If you aren't linked to either and just using numpy's version
> then the results are a bit strange. With numpy development I get
>
> In [1]: m= 1e5
>
> In [2]: n= 1e2
>
> In [3]: o= ones(n)
>
> In [4]: M= randn(m, n)
>
> In [5]: timeit M.sum(1)
> 100 loops, best of 3: 19.2 ms per loop
>
> In [6]: timeit dot(M, o)
> 100 loops, best of 3: 15 ms per loop
>
> In [7]: m= 1e2
>
> In [8]: n= 1e5
>
> In [9]: o= ones(n)
>
> In [10]: M= randn(m, n)
>
> In [11]: timeit M.sum(1)
> 100 loops, best of 3: 17.4 ms per loop
>
> In [12]: timeit dot(M, o)
> 100 loops, best of 3: 14.2 ms per loop
>
> Chuck
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110210/e9181192/attachment.html
More information about the NumPy-Discussion
mailing list