ATLAS - shawfdong/hyades GitHub Wiki

ATLAS (Automatically Tuned Linear Algebra Software) is an open source efficient and full implementation of BLAS APIs for C and Fortran 77. It also implements a a few routines from LAPACK. While its performance often trails that of specialized libraries written for one specific hardware platform, e.g., Intel MKL, it is a large improvement over the generic BLAS available at Netlib.

Table of Contents

Building ATLAS 3.10.2

Download the latest stable release of ATLAS and unpack the tarball:

$ cd /scratch
$ wget http://downloads.sourceforge.net/project/math-atlas/Stable/3.10.2/atlas3.10.2.tar.bz2
$ tar xfj atlas3.10.2.tar.bz2

Create a build directory:

$ mkdir ATLAS_Linux_SandyBridge
$ cd ATLAS_Linux_SandyBridge

According to :

CPU throttling makes pretty much all timings completely random, and so any ATLAS install will be junk. Therefore, before installing ATLAS, turn off CPU throttling.

Let's check the CPU throttling status on Hyades:

$ cat /proc/acpi/processor/CPU0/info
processor id:            0
acpi id:                 1
bus mastering control:   yes
power management:        no
throttling control:      no
limit interface:         no
CPU throttling is disabled. Excelente!

Unload the default modules to ensure that GCC will be used to compile ATLAS:

$ module unload intel_mpi
$ module unload intel_compilers

Configure ATLAS 3.10.2:

$ /scratch/ATLAS/configure --help
$ /scratch/ATLAS/configure \
-Fa alg -fPIC -b 64 -D c \
-DPentiumCPS=2200 \
--prefix=/pfs/sw/serial/gcc/atlas-3.10.2 \
--with-netlib-lapack-tarfile=/scratch/lapack-3.5.0.tgz
Note:
  1. the frequency of the CPUs in Hyades is 2.2 GHz ()
  2. I use the compiler flag to generate position-independent code (PIC), suitable for dynamic linking[1]. This is necessary, e.g., if you want to build SciPy with ATLAS.
Tune and build ATLAS 3.10.2:
$ make build
which will create the following libraries:
liblapack.a : The serial LAPACK routines provided by ATLAS, including both Fortran and ATLAS's clapack[2] (which is different from either LAPACKE or Netlib CLAPACK) interfaces.
libcblas.a : The ANSI C interface to the BLAS.
libf77blas.a : The Fortran77 interface to the BLAS.
libptlapack.a : The threaded LAPACK routines provided by ATLAS.
libptcblas.a : The ANSI C interface to the threaded BLAS.
libptf77blas.a : The Fortran77 interface to the threaded BLAS.
libatlas.a : The main ATLAS library, providing low-level routines for all interface libs.
Sanity-check the serial libraries:
$ make check

Sanity-check the threaded libraries:

$ make ptcheck

Check the performance of the libraries:

$ make time

Reference clock rate=3292Mhz, new rate=2200Mhz
   Refrenc : % of clock rate achieved by reference install
   Present : % of clock rate achieved by present ATLAS install

                    single precision                  double precision
            ********************************   *******************************
                  real           complex           real           complex
            ---------------  ---------------  ---------------  ---------------
Benchmark   Refrenc Present  Refrenc Present  Refrenc Present  Refrenc Present

=========   ======= =======  ======= =======  ======= =======  ======= =======

  kSelMM     1289.9  1521.7   1188.7  1321.7    686.7   815.2    647.4   747.6
  kGenMM      198.2   180.7    198.5   161.2    193.9   221.6    196.0   217.3
  kMM_NT      193.7   220.5    195.2   223.8    184.2   217.5    188.5   222.6
  kMM_TN      198.5   151.0    197.9   227.0    189.8   211.5    189.5   216.9
  BIG_MM     1213.8  1386.0   1241.3  1288.0    652.0   736.0    661.4   752.2
   kMV_N      224.3    68.1    438.8   511.6    115.9    42.6    205.8   266.0
   kMV_T      224.6    89.0    460.3   595.3    123.2    43.8    211.3    81.0
    kGER      148.3    75.8    290.2   159.1     73.3    34.7    144.3    70.8

Install the libraries:

$ make install

Using ATLAS

ATLAS 3.10.2 is installed at .

To compile a Fortran program and link with the serial BLAS library provided by ATLAS, using [3]:

$ gfortran -o blaspgm.x blaspgm.f -L/pfs/sw/serial/gcc/atlas-3.10.2/lib -lf77blas -latlas

To compile a Fortran program and link with the serial BLAS library provided by ATLAS, using the :

$ ifort -o blaspgm.x blaspgm.f -L/pfs/sw/serial/gcc/atlas-3.10.2/lib -lf77blas -latlas -lgfortran

To compile a C program and link with the serial CBLAS library provided by ATLAS, using :

$ gcc -o cblaspgm.x cblaspgm.c -I/pfs/sw/serial/gcc/atlas-3.10.2/include -L/pfs/sw/serial/gcc/atlas-3.10.2/lib -lcblas -latlas

To compile a C program and link with the serial CBLAS library provided by ATLAS, using the :

$ icc -o cblaspgm.x cblaspgm.c -I/pfs/sw/serial/gcc/atlas-3.10.2/include -L/pfs/sw/serial/gcc/atlas-3.10.2/lib -lcblas -latlas

To compile a Fortran program and link with the serial LAPACK library provided by ATLAS, using :

$ gfortran -o lapackpgm.x lapackpgm.f -L/pfs/sw/serial/gcc/atlas-3.10.2/lib -llapack -lf77blas -lcblas -latlas

To compile a Fortran program and link with the serial LAPACK library provided by ATLAS, using the :

$ ifort -o lapackpgm.x lapackpgm.f -L/pfs/sw/serial/gcc/atlas-3.10.2/lib -llapack -lf77blas -lcblas -latlas -lgfortran

Note:

  1. The full LAPACK library is created by merging ATLAS and Netlib LAPACK, so linking with the LAPACK library requires both C and Fortran77 BLAS interfaces.
  2. The threaded ATLAS libraries should be avoided in a cluster environment like Hyades; because the maximum number of threads to use is determined at compile time and one can't vary the number of threads ATLAS uses dynamically[4].
  3. To facilitate the usage of ATLAS, I've created a module to set up its environment. If you load the module, you can use more concise commands to link with the ATLAS libraries. For example, to compile a C program and link with the serial BLAS library provided by ATLAS, you can now use a much shorter command:
$ module load lapack/s_gcc_ATLAS_3.10.2
$ gcc -o cblaspgm.x cblaspgm.c -lcblas -latlas

Building SciPy using ATLAS

BLAS and LAPACK libraries are required for building SciPy. Now we can build SciPy with ATLAS[5]:

$ export BLAS=/pfs/sw/serial/gcc/atlas-3.10.2/lib/libf77blas.a
$ export LAPACK=/pfs/sw/serial/gcc/atlas-3.10.2/lib/liblapack.a
$ export ATLAS=/pfs/sw/serial/gcc/atlas-3.10.2/lib/libatlas.a
$ cd scipy-0.14.0
$ python setup.py build
$ python setup.py install

References

  1. ^ GCC - Options for Code Generation Conventions
  2. ^ ATLAS's clapack API
  3. ^ How do I link with the BLAS libraries?
  4. ^ Can I vary the number of threads ATLAS uses dynamically?
  5. ^ Building SciPy From Source on Linux
⚠️ **GitHub.com Fallback** ⚠️