gundamlh
gundamlh

Reputation: 183

Numpy with ATLAS or OpenBLAS?

After spending a huge amount of time on building the ATLAS from the source code, I found that libopenblas and libatals in the OpenSUSE 13.1 repository. My questions are

  1. Does that easy-install (without tuning on your own computer) "libatlas" in the repository really improve the computation performance?

  2. Is OpenBLAS better than ATLAS or only better than the easy-install "libatlas" in the repository of a flavor of Linux? See For faster R use OpenBLAS instead: better than ATLAS, trivial to switch to on Ubuntu.

  3. I followed this post Compiling Numpy with OpenBLAS but cannot find "numpy.core._dotblas" module. Morever I couldn't build Numpy with ATLAS and OpenBLAS at the same time.

  4. Could someone post a .py file or bash code for doing the comparison between ATLAS and OpenBLAS? For example.

  5. I built Numpy-1.9 with my own ATLAS, compiled OpenBLAS from the source code and installed the "libopenblaso" (OpenMP version) and "libopenblasp" (pthreads version) in the repository of OpenSUSE 13.1. How to configure the links and the libraries so that one can tell Numpy-1.9 to use OpenBLAS instead of ATLAS without rebuilding the Numpy-1.9 package.

Note: If you install "libatlas" in the repository, the ATLAS is not tuned for your computer and cannot the computation performance much. Therefore, I built and tuned the ATLAS first, then built Numpy with my own ATLAS. After that I tried to link OpenBLAS to Numpy but failed.

Many thanks in advance!


Thank you @Dmitry for the quick reply! But the questions are not solved...

Install

$ sudo zypper in libopenblasp0

The following NEW package is going to be installed:
  libopenblasp0 

1 new package to install.
Overall download size: 3.0 MiB. After the operation, additional 30.3 MiB will be used.
Continue? [y/n/? shows all options] (y): 
Retrieving package libopenblasp0-0.2.11-11.1.x86_64      (1/1),   3.0 MiB ( 30.3 MiB unpacked)
Retrieving: libopenblasp0-0.2.11-11.1.x86_64.rpm ...........................[done (2.1 MiB/s)]
(1/1) Installing: libopenblasp0-0.2.11-11.1 ............................................[done]

Additional rpm output:
/sbin/ldconfig: Can't link /usr/lib64//usr/local/atlas/lib/libtatlas.so to libopenblas.so.0

Q: Why is there a funny double slash "..64//usr.."?

Link the library

$ /usr/sbin/update-alternatives --config libblas.so.3

  Selection    Path                               Priority   Status
------------------------------------------------------------
  0            /usr/local/atlas/lib/libtatlas.so   70        auto mode
  1            /usr/lib64/blas/libblas.so.3        50        manual mode
  2            /usr/lib64/libopenblasp.so.0        20        manual mode
  3            /usr/local/atlas/lib/libcblas.a     50        manual mode
  4            /usr/local/atlas/lib/libptcblas.a   60        manual mode
  5            /usr/local/atlas/lib/libsatlas.so   65        manual mode
* 6            /usr/local/atlas/lib/libtatlas.so   70        manual mode

Q: Is this configuration fine, as some static libraries ".a" are linked?

Note: "libopenblasp.so.0" is linked automatically after "zypper in", whilst all "atlas" libraries are manually created by the command:

$ /usr/sbin/update-alternatives --install /usr/lib64/blas/libblas.so.3 libblas.so.3 /usr/local/atlas/lib/libxxxx.x <Integer>

Upvotes: 13

Views: 9618

Answers (2)

KJ7LNW
KJ7LNW

Reputation: 1901

This article shows some benchmarks and how to compile the different linear algebra packages. Clearly compiling yourself gives better performance than the default in the author's case, but of course YMMV.

Quoting from the article with minor edits:

Link against the default system cblas:

$ gcc time_dgemm.c -lcblas && ./a.out
10.997839 s

The single threaded optimized [atlas] version gets a ~3x speedup:

$ gcc time_dgemm.c -L$HOME/opt/atlas/lib -lsatlas && ./a.out
3.237809 s

Linking the same code against our threaded blas, I get a ~10x speedup:

$ gcc time_dgemm.c -L$HOME/opt/atlas/lib -ltatlas && ./a.out
1.302789 s

Using OpenBLAS 0.2.8, I get better performance than ATLAS:

$ gcc time_dgemm.c -L$HOME/opt/openblas-0.2.8/lib -lopenblas && ./a.out
1.031470 s

Using (nonfree) MKL, the performance is pretty similar. But the link line is much more complex:

$ gcc -fopenmp -m64 -I$MKLROOT/include time_dgemm.c -L$MKLROOT/lib/intel64 -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm && ./a.out
0.951390 s

Upvotes: 1

Dmitry
Dmitry

Reputation: 86

You can switch between system BLAS and LAPACK implementations by using update-alternatives. For example:

/usr/sbin/update-alternatives --config libblas.so.3

http://en.opensuse.org/openSUSE:Science_Linear_algebra_libraries

I don't know about atlas packages, but we provide openblas with multiarch support. Math kernel includes all processor specific optimizations and set right variant dynamically. Note, there are 3 versions of openblas library: serial, pthreads and openmp version. You need to use pthreads or openmp.

Upvotes: 6

Related Questions