Installing BLAS, LAPACK, PETSc, and TAO on Cygwin

 

 

Last update: August 5, 2007

 

 

The TAO installation includes 5 components:

 

1.  MPI:       http://www.mcs.anl.gov/mpi/mpich (In this note, we won't install or use MPI)

2.  BLAS:    http://www.netlib.org/blas/

3.  Lapack:  http://www.netlib.org/lapack

4.  PETSc:   http://www.mcs.anl.gov/petsc

5.  TAO:     http://www-unix.mcs.anl.gov/tao/

 

The versions used here: Lapack 3.1.1, PETSc 2.3.0, TAO 1.8.  Blas does not have version number.  We will not use MPI. 

The OS and CPU we used are:

Cygwin: CYGWIN_NT-5.1 1.5.24 (0.156/4/2) (check "cat /proc/version").

WinXP: version 2002 Service Pack 2.

CPU: Intel(R) Pentium(R) M processor. (check "cat /proc/cpuinfo").

 

If you really meet with some unexpected problem, you may download a compiled copy of TAO 1.8 here (7 MB), PETSc 2.3.0 here (25 MB), using compiled Lapack 3.1.1 here (3MB), and Blas here.  The environment is as above.

 

 

Details:  

 

First of all, Cygwin must be installed with necessary packages:  make, patch, python, rebase, gcc, g++, g77.  The Cygwin installation guide on www.cygwin.com is sufficient.  The only hint is: for those in Singapore, a fastest download site is: ftp.nctu.edu.tw .  For those in Australia, find any one ending with .au (e.g., ftp://mirror.aarnet.edu.au).

 

We suppose that we wish to install all software under /home/usr/packages/ (assuming ${HOME}=/home/usr).  We will create 4 folders: /home/usr/packages/Blas, /home/usr/packages/Lapack, /home/usr/packages/petsc-3.2.0, and /home/usr/packages/tao-1.8.  We deliberately do not install them in system directory like /lib, because we assume you do not have the privilege to do that (well, this assumption is more realistic on shared Linux servers than on personal Cygwin's).

 

If you only want to use TAO and PETSc, and you have no interest in using Blas and Lapack elsewhere, then you can skip step 2 and 3, and pay attention to the 3rd point in the special notes of Step 4.

 

Step 1:  Install MPI, it is a package for utilizing parallel machines.  For our uni-processor cases, there is no need to install it because TAO have included a stripped-down version of MPI that allows TAO to be compiled without installing an external version of MPI.  But if you really want to use MPI, I recommend that you download it from the official web site.

 

Step 2:  Install  Blas.  Blas seems to be unversioned.

            2.1   Download the source files from from http://www.netlib.org/blas/blas.tgz

            2.2   Decompress it by using "gunzip -c blas.tgz | tar xf -" and put the files in folder /home/usr/packages/Blas. 

            2.3   Modify make.inc in the folder /home/usr/packages/Blas.  Change line 10 from "PLAT = _LINUX" to "PLAT = _Cygwin".

            2.4   Run "make" in /home/usr/packages/Blas/.

            After building completes, a new library file "blas_Cygwin.a" will be created in /home/usr/packages/Blas/.

 

Step 3: Install Lapack.  Here we use version 3.1.1.

            3.1   Download Lapack from http://www.netlib.org/lapack/lapack-3.1.1.tgz.

            3.2   Decompress it by using "gunzip -c blas.tgz | tar xf -" and put the files in folder /home/usr/packages/lapack-3.1.1

            3.3   "cd /home/usr/packages/lapack-3.1.1", and then run "cp make.inc.example make.inc".

            3.4   Modify the make.inc in the folder /home/usr/packages/lapack-3.1.1. 

                        Change line 10 from "PLAT = _LINUX" to "PLAT = _Cygwin".

                        Change line 52 from "BLASLIB = ../../blas$(PLAT).a" to "BLASLIB = /home/usr/packages/Blas/blas$(PLAT).a".

            3.5  Run "make".

            After building completes, a new library file "lapack_Cygwin.a" will be created in /home/usr/packages/lapack-3.1.1/.

 

Step 4: Install PETSc.  Here we use version 3.2.0.

            4.1  Download PETSc 3.2.0 from ftp://ftp.mcs.anl.gov/pub/petsc/software_old/v2.3.0.petsc.tar.gz.

            4.2  Decompress it by using "gunzip -c v2.3.0.petsc.tar.gz | tar -xof -" and put the files in folder /home/usr/packages/petsc-2.3.0 

            4.3  "cd /home/usr/packages/petsc-2.3.0". 

            4.4  Run "export PETSC_DIR=`pwd`" (don't key in the double quotation marks ").

            4.5  Run "export PETSC_ARCH=cygwin".

            4.6  Run "./config/configure.py --with-mpi=0 --with-shared --with-clanguage=C++ --with-blas-lib=${HOME}/Toolkits/Optimization/BLAS/blas_Cygwin.a --with-lapack-lib=${HOME}/Toolkits/Optimization/Lapack-3.1.1/lapack_Cygwin.a".  Note it is a one-line command, your Internet browser might have split it into 2 or more lines.

            4.7  Run "make".

            4.8  Modify ${HOME}/.bash_profile, add "export PETSC_DIR=/home/usr/packages/petsc-2.3.0" and "export PETSC_ARCH=cygwin".  So whenever we start cygwin, these environment variable are automatically set.

            After building completes, nine new library files will be created in /home/usr/packages/petsc-2.3.0/lib/cygwin.

 

            Special notes:

            1. In my experience, to specify the value for --with-lapack-lib or --with-blas-lib (i.e., the location of blas and lapack library files), you MUST use the absolute directory or ${HOME}.  So in the above, I used ${HOME}/packages/Blas/blas_Cygwin.a.  If one uses "../Blas/ or blas_Cygwin.a" or "~/packages/Blas/blas_Cygwin.a", then the configure.py will not be able to find the blas library.

            2. We did not want to use MPI, so I set --with-mpi=0.

            3. If you only want to use TAO and PETSc, and you have no interest in using Blas and Lapack elsewhere, then you do not need to manually download and install Blas and Lapack.  Simply use --download-f-blas-lapack=1 in ./config/configure.py, and omit the "--with-blas-lib" and "--with-lapack-lib" options.  The Blas and Lapack packages will be automatically downloaded from the Internet, so make sure you have network connection.  I guess it will not exceed 10 MB for Lapack and 1 MB for Blas.

 

 

Step 5: Install TAO.  Here we use version 1.8.

            5.1  Download TAO 1.8 from http://www-unix.mcs.anl.gov/tao/download/index.html.

            5.2  Decompress it by using "gunzip -c tao-1.8.tar.gz | tar -xof -" and put the files in folder /home/usr/packages/tao-1.8.

            5.3  "cd /home/usr/packages/tao-1.8".

            5.4  Run "export TAO_DIR=`pwd`".

            5.5  Run "make".

            5.6  Modify ${HOME}/.bash_profile, add "export TAO_DIR=/home/usr/packages/tao-1.8".

            After building completes, three new library files will be created in /home/usr/packages/tao-1.8/lib/cygwin.

 

 

Now we are done.  To have a quick test, let's go to /home/usr/packages/tao-1.8/examples.  Run "make".  Then run "./rosenbrock1 3 10".  This example tries to find the minimizer of sum_{i=0}^{n/2-1} ( alpha*(x_{2i+1}-x_{2i}^2)^2 + (1-x_{2i})^2 ), where n is the first command line argument (default 2), and alpha is the second one (default 99).  If the program exits without any error, then it means our installation is fine.  If you are curious of the result, you can add a line "VecView(x,PETSC_VIEWER_STDOUT_WORLD);" to the line 100 of rosenbrock1.c,  re-run "make" and "./rosenbrock1 3 10".  It will print the optimal solution found by TAO.

 

Amen.

 

 

-----------------------------------------

God has a Book where he maintains the best proofs of all mathematical theorems, proofs that are elegant and perfect...

You don't have to believe in God, but you should believe in the Book.


-- Paul Erdos
 

 

 

Back to my IT notes in Research