Pages

Building ATLAS in Mac OSX

The Automatically Tuned Linear Algebra Software (ATLAS) is a popular implementation of the Basic Linear Algebra Subroutines (BLAS) and some LAPACK routines. Such modules are commonly used to speed-up computations in scientific applications that require many and fast matrix operations. Below, I will demonstrate how to build ATLAS in OSX on a MacBook Pro (2015).

For comparison, below are my system specifications.
Modellname:                MacBook Pro
Modell-Identifizierung:    MacBookPro11,5
Prozessortyp:              Intel Core i7
Prozessorgeschwindigkeit:  2,8 GHz
Anzahl der Prozessoren:    1
Gesamtanzahl der Kerne:    4
L2-Cache (pro Kern):       256 KB
L3-Cache:                  6 MB
Speicher:                  16 GB
Systemversion:             macOS 10.13.4
Kernel-Version:            Darwin 17.5.0

To begin, download ATLAS. The latest stable version is 3.10.3 as of writing and this is the version I tested. However, even this latest stable release is dated by about two years (as of 2018) so you might consider trying one of new developer versions of find an alternative to ATLAS that is more actively managed.

Place the tar files in your home directory. Extract the ATLAS tar file using the command below.
tar -xvf atlas3.10.3.tar.bz2

Create a build subdirectory under the ATLAS directory that the tar files were extracted to.
mkdir build
cd build

At this point, make sure that you have a functioning gcc and gfortran compiler. Use Homebrew to install the gcc8 compiler (gfortran is included in gcc8). Type "gfortran" to verify it is working. You need to mess around with aliases or your path variable to compile with gcc, but we will force ATLAS to use clang below.

(Warning: I've tried many times to get this install process working with MacPorts and the compilers it provides without success. I believe this is because the compilers installed by MacPorts were not working nicely with each other or the XCode command line tools. Save yourself some time and use a clean install of Homebrew and the latest gcc.)

From the build directory, run the configure script. You can have ATLAS build a full LAPACK library by downloading a LAPACK tarfile from NetLib and using "--with-netlib-lapack-tarfile=path/to/tarfile" in the configure step, but this is optional.
../configure -A Corei3 -b 64 -D c -DI7CPS=2800 --prefix=/app/atlas3.10.3/build --force-clang=/usr/bin/clang --with-netlib-lapack-tarfile=/app/lapack-3.8.0.tar.gz

Double check the Make.inc file in the build directory for anything unusual. In particular, ATLAS may be unable to detect your chip architecture. I fixed this by adding -A Corei3 to the above command, but double check for your system.

Before building ATLAS, if possible, find a method to disable CPU throttling on OSX as this will disrupt ATLAS's timings which it uses to tune the BLAS to the hardware. There are some suggestions for how to do this on the Web but just as many suggestions say this is not possible for some i7 processors since CPU throttling is done "on-the-fly" in hardware. The solutions I have attempted have had no effect on the quality of the ATLAS build that I can discern.

Once you are ready to build, make sure your device is attached to a power source and all other processes are idle. The build and testing could take several hours, depending on which compiler you chose, and generate a lot of heat. It may be convenient to do this overnight. Enter make build to begin building ATLAS.
make build

The build process will send many hundreds of pages of output to the terminal. This is normal. Keep waiting. If you used the clang compiler, this should not take so long. After this point, if you want to change any of the configuration settings and recompile, it is best to delete the whole build directory and start over to avoid confusing compilation errors.

Once the build has completed, check for any obvious errors in the last several pages of output from the compiler. Then start running the following tests. The full test is only necessary for further debugging if you see weird things in the check and parallel check sections.
make check

make ptcheck

make full_test

Finally, run the timing and install.
make time

make install

The compiled ATLAS library will be in /ATLAS/build/lib/libatlas.a. Link to this library when compiling other programs like Quantum Espresso.

A summary of the necessary commands.
# Place the ATLAS tar file in the home directory

tar -xvf atlas3.10.3.tar.bz2
cd ATLAS
mkdir build
cd build 

/Users/localuser/ATLAS/configure -A Corei3 -b 64 -D c -DI7CPS=2800 --prefix=/Users/nolanpeard/ATLAS/build --force-clang=/usr/bin/clang

make build
make check
make ptcheck
make time
make install

References:
ATLAS
BLAS
LAPACK
ScaLAPACK