[Numpy-discussion] Numpy matrix multiplication slow even though ATLAS linked
Jan-Willem van de Meent
vandemeent at damtp.cam.ac.uk
Thu Oct 30 07:19:00 EDT 2008
Dear all,
This is my first post to this list. I am having perfomance issues with with
numpy/atlas. Doing dot(a,a) for a 2000x2000 matrix takes about 1m40s, even
though numpy is appears to link to my atlas libraries:
I did a quick benchmark by running the following script:
#! /usr/bin/env python
import numpy
import time
try:
import numpy.core._dotblas
print 'Using ATLAS:'
except ImportError:
print 'No ATLAS:'
t = time.time()
x = numpy.random.random((1000,1000))
y = numpy.random.random((1000,1000))
z = numpy.dot(x, y)
print time.time()-t
My laptop is a Dell D620 Core Duo T2300 1.66 Ghz, running Archlinux with GCC
4.3.2, atlas 3.8.2, python 2.5.2 and numpy 1.2.1. Output of the script above
is:
Using ATLAS:
7.99549412727
A department desktop PC, Pentium D 3.00 Ghz, running Scientific Linux, with
GCC 4.1.2, atlas 3.7.30, python 2.5.1 and numpy 1.1.0, runs this test 24
times faster:
Using ATLAS:
0.337520122528
So even though _dotblas.so exists, matrix multiplication appears to run at
pretty much the same speed as if atlas were not available. Running ldd on
_dotblas.so suggests that numpy is indeed linking to the atlas libs:
ldd /usr/lib/python2.5/site-packages/numpy/core/_dotblas.so
linux-gate.so.1 => (0xb7fcf000)
libatlas.so => /usr/lib/libatlas.so (0xb7cb5000)
liblapack.so => /usr/lib/liblapack.so (0xb77ab000)
libcblas.so => /usr/lib/libcblas.so (0xb778b000)
libf77blas.so => /usr/lib/libf77blas.so (0xb776f000)
libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb7630000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7618000)
libc.so.6 => /lib/libc.so.6 (0xb74d6000)
libm.so.6 => /lib/libm.so.6 (0xb74b0000)
libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0xb73ff000)
libdl.so.2 => /lib/libdl.so.2 (0xb73fb000)
libutil.so.1 => /lib/libutil.so.1 (0xb73f6000)
/lib/ld-linux.so.2 (0xb7fd0000)
Something appears to be going wrong in the compilation process. In particular,
the compile process appears unable to determine the version of the atlas libs
installed (I get NO_ATLAS_INFO). I've pasted some snippets from the build
output which may be relevant below.
Can anyone help me figure this out?
Many thanks in advance,
Jan-Willem
--
Jan-Willem van de Meent
Research Student
Goldstein Lab, DAMTP
University of Cambridge
--
Snippets from setup.py output
...
atlas_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in /usr/lib
numpy.distutils.system_info.atlas_threads_info
Setting PTATLAS=ATLAS
Setting PTATLAS=ATLAS
FOUND:
libraries =
['lapack', 'atlas', 'lapack', 'cblas', 'f77blas', 'ptcblas', 'ptf77blas']
library_dirs = ['/usr/lib']
language = f77
include_dirs = ['/usr/include']
...
customize Gnu95FCompiler using config
compiling '_configtest.c':
/* This file is generated from numpy/distutils/system_info.py */
void ATL_buildinfo(void);
int main(void) {
ATL_buildinfo();
return 0;
}
C compiler:
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=i686 -mtune=generic -O2 -pipe -fPIC
compile options: '-c'
gcc: _configtest.c
gcc -pthread
_configtest.o -L/usr/lib -llapack -latlas -llapack -lcblas -lf77blas -lptcblas -lptf77blas -o
_configtest
/usr/bin/ld: _configtest: hidden symbol `__powidf2'
in /usr/lib/gcc/i686-pc-linux-gnu/4.3.2/libgcc.a(_powidf2.o) is referenced by
DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
/usr/bin/ld: _configtest: hidden symbol `__powidf2'
in /usr/lib/gcc/i686-pc-linux-gnu/4.3.2/libgcc.a(_powidf2.o) is referenced by
DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
failure.
removing: _configtest.c _configtest.o
Status: 255
Output:
FOUND:
libraries =
['lapack', 'atlas', 'lapack', 'cblas', 'f77blas', 'ptcblas', 'ptf77blas']
library_dirs = ['/usr/lib']
language = f77
define_macros = [('NO_ATLAS_INFO', 2)]
include_dirs = ['/usr/include']
More information about the NumPy-Discussion
mailing list