Setting up optimized ATLAS libraries for development on Fedora 17
Fedora 17 (Beefy Miracle) provides optimized BLAS and LAPACK libraries using ATLAS. ATLAS libraries should be tuned to the machine on which they are used. However, as Fedora supports a wide variety of hardware with the same x8664 binaries, a more complex mechanism is needed for enabling optimized ATLAS libraries. The scheme consists of installing two ATLAS packages:
- generic package (
atlas
andatlas-devel
) for unoptimized libraries - machine-specific packages (
atlas-XXX
andatlas-XXX-devel
) for optimized libraries
The choices for optimized ATLAS packages (at the time of writing) include:
atlas-3dnow atlas-sse atlas-sse2 atlas-sse3
For the rest of this tutorial, we will assume that atlas-sse3.x86_64
is the best match for the machine of interest. The ATLAS package can be
installed using yum
:
yum install atlas atlas-devel atlas-sse3 atlas-sse3-devel
Upon installing the packages, one can see the correct include directory set up:
$ alternatives --display atlas-inc
atlas-inc - status is auto.
link currently points to /usr/include/atlas-x86_64-sse3
/usr/include/atlas-x86_64-base - priority 64
/usr/include/atlas-x86_64-sse3 - priority 68
Current `best' version is /usr/include/atlas-x86_64-sse3.
However, if compiling an application that uses blas
, the linker
complains that libcblas.so
and friends are not found in the linker
search path. For some reason, the Fedora maintainers do not provide
automatic symbolic links for the compiled libraries. The fix is to
manually make the alternatives visible:
alternatives --install /usr/lib64/libatlas.so atlas-lib /usr/lib64/atlas/libatlas.so 64 \ --slave /usr/lib64/libcblas.so atlas-libcblas /usr/lib64/atlas/libcblas.so \ --slave /usr/lib64/libclapack.so atlas-libclapack /usr/lib64/atlas/libclapack.so \ --slave /usr/lib64/libf77blas.so atlas-libf77blas /usr/lib64/atlas/libf77blas.so \ --slave /usr/lib64/liblapack.so atlas-liblapack /usr/lib64/atlas/liblapack.so \ --slave /usr/lib64/libptcblas.so atlas-libptcblas /usr/lib64/atlas/libptcblas.so \ --slave /usr/lib64/libptf77blas.so atlas-libptf77blas /usr/lib64/atlas/libptf77blas.so alternatives --install /usr/lib64/libatlas.so atlas-lib /usr/lib64/atlas-sse3/libatlas.so 68 \ --slave /usr/lib64/libcblas.so atlas-libcblas /usr/lib64/atlas-sse3/libcblas.so \ --slave /usr/lib64/libclapack.so atlas-libclapack /usr/lib64/atlas-sse3/libclapack.so \ --slave /usr/lib64/libf77blas.so atlas-libf77blas /usr/lib64/atlas-sse3/libf77blas.so \ --slave /usr/lib64/liblapack.so atlas-liblapack /usr/lib64/atlas-sse3/liblapack.so \ --slave /usr/lib64/libptcblas.so atlas-libptcblas /usr/lib64/atlas-sse3/libptcblas.so \ --slave /usr/lib64/libptf77blas.so atlas-libptf77blas /usr/lib64/atlas-sse3/libptf77blas.so
Note that root
permissions are required to issue the commands above.
For an i686
machine which uses a different optimized ATLAS package,
you will need to modify the library path to lib
(replacing lib64
)
and will also need to pick the correct library directory names, e.g.,
via
rpm -ql atlas-devel atlas-XXX-devel
Now, the choice of the ATLAS library packages can be configured easily:
$ alternatives --display atlas-lib
atlas-lib - status is auto.
link currently points to /usr/lib64/atlas-sse3/libatlas.so
/usr/lib64/atlas/libatlas.so - priority 64
slave atlas-libcblas: /usr/lib64/atlas/libcblas.so
slave atlas-libclapack: /usr/lib64/atlas/libclapack.so
slave atlas-libf77blas: /usr/lib64/atlas/libf77blas.so
slave atlas-liblapack: /usr/lib64/atlas/liblapack.so
slave atlas-libptcblas: /usr/lib64/atlas/libptcblas.so
slave atlas-libptf77blas: /usr/lib64/atlas/libptf77blas.so
/usr/lib64/atlas-sse3/libatlas.so - priority 68
slave atlas-libcblas: /usr/lib64/atlas-sse3/libcblas.so
slave atlas-libclapack: /usr/lib64/atlas-sse3/libclapack.so
slave atlas-libf77blas: /usr/lib64/atlas-sse3/libf77blas.so
slave atlas-liblapack: /usr/lib64/atlas-sse3/liblapack.so
slave atlas-libptcblas: /usr/lib64/atlas-sse3/libptcblas.so
slave atlas-libptf77blas: /usr/lib64/atlas-sse3/libptf77blas.so
Current `best' version is /usr/lib64/atlas-sse3/libatlas.so.
We have opted to keep the same priority values (64 and 68 in the example
above) that the Fedora maintainers used for atlas-inc
; we recommend
that you do the same.