2010-04-01

Compiling ATLAS with LAPACK on CentOS 5.4

by Forrest Sheng Bao http://fbao.net

I did this on a cluster using Intel Xeon CPUs and CentOS 5.4(equivalent to Red Hat Enterprise Linux 5.4). I think this note also works for other Linux distributions, if you wanna compile ATLAS from scratch. You may do so to prepare other software that needs ATLAS, such as numpy.

Step 1: download and prepare files


1.1 Get to ATLAS project homepage to download ATLAS. The version I downloaded was ATLAS 3.9 http://math-atlas.sourceforge.net/

1.2 Get LAPACK from LAPACK project homepage http://www.netlib.org/lapack/ The version I downloaded was 3.2.1. The file name is lapack.tgz.

1.3 Make sure to place LAPACK and ATLAS source package (in either tar.gz or tar.bz2 balls)

1.4 Extract ATLAS source package. A folder named ATLAS should be created.

Step 2: Compile ATLAS into static library (with LAPACK)

2.1
cd ATLAS
2.2 Create a folder. I called it DONE
mkdir DONE
From now on, everything remaining is done under the folder DONE, either under DONE/bin or DONE/lib.
2.3
cd DONE
2.4
../configure -Fa alg -fPIC --with-netlib-lapack-tarfile=../../lapack.tgz
2.3
make
2.4
make check
(optional)
2.5
make time
(optional)

Step 3: Compile ATLAS static library into dynamic library (optional, but you need this step mostly)


3.1:
cd ../lib
(lib under DONE)

3.2: Edit Make.inc. Change F77SYSLIB variable from Intel Fortran library into your gcc Fortran library (Optional. On my computer, Intel and GNU environmental variables are messed up coz my system administrator installed Intel C Compiler with Intel C Library whereas I always go GNU.)

On my computer, I change the line
F77SYSLIB = -L/opt/intel/Compiler/11.1/056/lib/intel64 -lgfortran
into
F77SYSLIB = -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -lgfortran

3.3 Edit Make.inc. Change -lgfortran in F77SYSLIB variable into -lgfortranbegin
On my computer, after step 3.2, I change the line
F77SYSLIB = -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -lgfortran
into
F77SYSLIB = -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -lgfortranbegin

3.4 Edit Makefile. Change the DESTDIR library if your installation destination is not /usr/local/atlas. This variable is not set accordingly if you use --prefix in configuring.

On my computer, I manually set it to the directory of compiled ATLAS library. Thus, change line
DESTDIR=/usr/local/atlas
into
DESTDIR=/home/bao/installtest/ATLAS/DONE

3.5 Make into dynamic library.
make shared

Step 4: Set environmental variables


4.1 Set a variable ATLAS, pointing to the lib folder under DONE. On my computer, I add this line into my ~/.bashrc
export ATLAS=/home/bao/installtest/ATLAS/DONE/lib

4.2 Add $ATLAS into LD_LIBRARY_PATH
On my computer, I add this line into my ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ATLAS

4.3 Activate new environmental variables
You can either source ~/.bashrc or simply log out and re-login in.

Step 5: Test ATLAS
ATLAS source package comes with several examples. You can run them to test.
cd ../bin
make xdlutst_dyn
./xdlutst_dyn

If you run into the error like
./xdlutst_dyn: error while loading shared libraries: /usr/local/atlas/lib/libf77blas.so: cannot open shared object file: No such file or directory
, go back to step 3.5. Delete libf77blas.so under DONE/lib and rerun make shared. Then come back to step 5.

No comments: