[Numpy-discussion] performance matrix multiplication vs. matlab
Fri Jun 5 05:20:28 CDT 2009
Sebastian Walter wrote:
> On Fri, Jun 5, 2009 at 11:58 AM, David
> Cournapeau<firstname.lastname@example.org> wrote:
>> Sebastian Walter wrote:
>>> On Thu, Jun 4, 2009 at 10:56 PM, Chris Colbert<email@example.com> wrote:
>>>> I should update after reading the thread Sebastian linked:
>>>> The current 1.3 version of numpy (don't know about previous versions) uses
>>>> the optimized Atlas BLAS routines for numpy.dot() if numpy was compiled with
>>>> these libraries. I've verified this on linux only, thought it shouldnt be
>>>> any different on windows AFAIK.
>>> in the best of all possible worlds this would be done by a package
>> Numpy packages on windows do use ATLAS, so I am not sure what you are
>> referring to ?
> I'm on debian unstable and my numpy (version 1.2.1) uses an unoptimized blas.
Yes, it is because the package on Linux are not well done in that
respect (to their defense, numpy build is far from being packaging
friendly, and is both fragile and obscure).
> I had the impression that most ppl that use numpy are on linux.
Sourceforge numbers tell a different story at least. I think most users
on the ML use linux, and certainly almost every developer use linux or
mac os x. But ML already filter most windows users - only geeks read ML
:) I am pretty sure a vast majority of numpy users never even bother to
look for the ML.
>> On a side note, correctly packaging ATLAS is almost
>> inherently impossible, since the build method of ATLAS can never produce
>> the same binary (even on the same machine), and the binary is optimized
>> for the machine it was built on. So if you want the best speed, you
>> should build atlas by yourself - which is painful on windows (you need
> in the debian repositories there are different builds of atlas so
> there could be different builds for numpy, too.
> But there aren't....
There are several problems:
- packagers (rightfully) hate to have many versions of the same software
- as for now, if ATLAS is detected, numpy is built differently than
if it is linked against conventional blas/lapack
- numpy on debian is not built with atlas support
But there is certainly no need to build one numpy version for every
atlas: the linux loader can load the most appropriate library depending
on your architecture, the so called hwcap flag. If your CPU supports
SSE2, and you have ATLAS installed for SSE2, then the loader will
automatically load the libraries there instead of the one in /usr/lib by
But because ATLAS is such a pain to support in a binary form, only
ancient versions of ATLAS are packaged anyways (3.6.*). So if you care
so much, you should build your own.
>> On windows, if you really care about speed, you should try linking
>> against the Intel MKL. That's what Matlab uses internally on recent
>> versions, so you would get the same speed. But that's rather involved.
It really depends on the CPU, compiler, how atlas was compiled, etc...
it can be slightly faster to 10 times faster (if you use a very poorly
For some recent benchmarks:
More information about the Numpy-discussion