
SDPA 7.3.2 Install Manual

[Copyright (C) 2004-2010 SDPA Project]

This text explains how to install SDPA.
If you have questions on the installation,
please contact us from
http://sdpa.indsys.chuo-u.ac.jp/sdpa/contact.html

The user-manual of SDPA is available at
http://sdpa.indsys.chuo-u.ac.jp/sdpa/files/sdpa.7.1.1.manual.20080618.pdf

--- index ------------------------------------

1. Install the SDPA
2. Compile callable-library example         [optional]
3. Compile SDPA-M (for Matlab and Octave)   [optional]
4. Note for Mac OS X
5. If you have some trouble

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


1. Install the SDPA

(1) Download the SDPA from the SDPA Homepage;

http://sdpa.indsys.chuo-u.ac.jp/sdpa/download.html

You can get the sdpa_7.3.2.tar.gz


(2) configure && make

You can select BLAS library from the three, ATLAS, GotoBLAS and
LAPACK/BLAS. The selection of BLAS library sometimes strongly affects
the performance of SDPA. From our numerical experiments, GotoBLAS
attains best performance. If you are allowed to use GotoBLAS (for the
details, refer the GotoBLAS license), our suggestion is GotoBLAS. The
LAPACK/BLAS is only for the case both ATLAS and Goto BLAS can not be
compiled.

If you install SDPA into **Mac OS X**, then first take a
look this section before your compile. Then, you should read 
Section 4 ``Note for Mac OS X'' and return here.

(2-1) SDPA linked against ATLAS library

Download the ATLAS library from the following web site;

http://math-atlas.sourceforge.net/

Download the LAPACK library from the following web site;

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

Assume that SDPA and ATLAS/LAPACK library are installed into $HOME/sdpa/sdpa-7.3.2 and $HOME/sdpa/lib respectively.

# LAPACK
$ tar xvzf lapack.tgz
$ cd lapack-3.2.1
$ cp ./INSTALL/make.inc.gfortran make.inc
   If your OS is 64bit, modify make.inc
   Old:
    OPTS     = -O2
    NOOPT    = -O0
   New:
    OPTS     = -O2 -fPIC
    NOOPT    = -O0 -fPIC
$ make lapacklib
$ cp lapack_LINUX.a $HOME/sdpa/lib/liblapack.a

# ATLAS
$ tar xvzf atlas3.x.x.tar.gz
$ mkdir -p atlas-tmp; cd atlas-tmp
$ ../ATLAS/configure --prefix=$HOME/sdpa/atlas \
  -Si cputhrchk 0 \
  --with-netlib-lapack=$HOME/sdpa/lib/liblapack.a \
  -C ic gcc -C if gfortran

  If your OS is 64bit, you should configure exlicitly by
$ ../ATLAS/configure --prefix=$HOME/sdpa/atlas \
  -Si cputhrchk 0 \
  --with-netlib-lapack=$HOME/sdpa/lib/liblapack.a \
  -C ic gcc -C if gfortran \
  -b 64 -Fa alg -fPIC

$ make
$ make install
$ cp $HOME/sdpa/atlas/lib/lib*.a $HOME/sdpa/lib/
$ rm -rf $HOME/sdpa/atlas

Note:
   On Mac OS X, 'make' or 'make install'
   of ATLAS sometimes fail. In this case,
   copy from the build directory as follow

   $ cp $HOME/sdpa/atlas-tmp/lib/lib*.a $HOME/sdpa/lib/ 

# SDPA
$ cd $HOME/sdpa 
$ tar xzf sdpa-7.3.2.tar.gz
$ cd sdpa-7.3.2
$ export CC=gcc
$ export CXX=g++
$ export FC=gfortran
$ export CFLAGS="-funroll-all-loops -O2 -m64"
$ export CXXFLAGS="-funroll-all-loops -O2 -m64"
$ export FFLAGS="-funroll-all-loops -O2 -m64"

Note:
   If your OS is 32bit OS or Mac OS X,
   use the following instead the above three.
   $ export CFLAGS="-funroll-all-loops -O2 -m32"
   $ export CXXFLAGS="-funroll-all-loops -O2 -m32"
   $ export FFLAGS="-funroll-all-loops -O2 -m32"

$ ./configure --prefix=$HOME/sdpa --with-blas="-L${HOME}/sdpa/lib -lptf77blas -lptcblas -latlas -lgfortran" --with-lapack="-L${HOME}/sdpa/lib -llapack -lgfortran"

Note:
   If your OS is Mac OS X assign the full paths,
   $ ./configure --prefix=$HOME/sdpa --with-blas="${HOME}/sdpa/lib/libptf77blas.a ${HOME}/sdpa/lib/libatlas.a -lgfortran" --with-lapack="${HOME}/sdpa/lib/liblapack.a -lgfortran"

$ make
$ make install

If you specify the number of threads with the SDPA,
set OMP_NUM_THREADS environment variable(ex. export OMP_NUM_THREADS=4).
If you have dual-core or quad-core CPU, we strongly recommend that set 

$ export OMP_NUM_THREADS=2
or
$ export OMP_NUM_THREADS=4


(2-2) SDPA linked against GotoBLAS library

Download the GotoBLAS library from the following web site;

http://www.tacc.utexas.edu/resources/software/

Download the LAPACK library from the following web site;

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

Assume that SDPA and GotoBLAS/LAPACK library are installed into $HOME/sdpa/sdpa-7.3.2 and $HOME/sdpa/lib respectively.

# GotoBLAS
$ tar xvzf GotoBLAS-1.xx.tar.gz
$ cd GotoBLAS
$ emacs Makefile.rule

Edit the file "Makefile.rule" as follows; 

# USE_SIMPLE_THREADED_LEVEL3 = 1
-->
  USE_SIMPLE_THREADED_LEVEL3 = 1

# CCOMMON_OPT    += -DTHREAD_TIMEOUT=26
-->
 CCOMMON_OPT    += -DTHREAD_TIMEOUT=1

Depending on OS bit (64 or 32),
$ ./quickbuild.64bit or ./quickbuild.32bit
[If you are going to use mex files on Mac OS X 
 with Matlab 2009a or earlier, we suggest 
 you use 32bit (because Matlab 2009a on Mac OS X
 is 32bit)]

$ cp libgoto.a $HOME/sdpa/lib/

# LAPACK
$ tar xvzf lapack.tgz
$ cd lapack-3.2.1
$ cp ./INSTALL/make.inc.gfortran make.inc
$ make lapacklib
$ cp lapack_LINUX.a $HOME/sdpa/lib/liblapack.a

# SDPA
$ cd $HOME/sdpa 
$ tar xzf sdpa-7.3.2.tar.gz
$ cd sdpa-7.3.2
$ export CC=gcc
$ export CXX=g++
$ export FC=gfortran
$ export CFLAGS="-funroll-all-loops -O2 -m64"
$ export CXXFLAGS="-funroll-all-loops -O2 -m64"
$ export FFLAGS="-funroll-all-loops -O2 -m64"

Note:
   If your OS is 32bit OS or Mac OS X,
   use the following instead the above three.
   $ export CFLAGS="-funroll-all-loops -O2 -m32"
   $ export CXXFLAGS="-funroll-all-loops -O2 -m32"
   $ export FFLAGS="-funroll-all-loops -O2 -m32"

$ ./configure --prefix=$HOME/sdpa --with-blas="-L${HOME}/sdpa/lib -lgoto" --with-lapack="-L${HOME}/sdpa/lib -llapack -lgoto" 

Note:
   If your OS is Mac OS X assign the full paths,
   $ ./configure --prefix=$HOME/sdpa --with-blas="${HOME}/sdpa/lib/libgoto.a" --with-lapack="${HOME}/sdpa/lib/liblapack.a ${HOME}/sdpa/lib/libgoto.a"


$ make
$ make install

If you specify the number of threads with both of the SDPA and GotoBLAS,
set OMP_NUM_THREADS environment variable(ex. export OMP_NUM_THREADS=4).
If you have dual-core or quad-core CPU, we strongly recommend that set 

$ export OMP_NUM_THREADS=2
or
$ export OMP_NUM_THREADS=4
 

(2-3) SDPA linked against LAPACK/BLAS library

Download the LAPACK/BLAS library from the following web site;

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

Assume that SDPA and LAPACK/BLAS library are installed into $HOME/sdpa/sdpa-7.3.2 and $HOME/sdpa/lib respectively.

# LAPACK/BLAS
$ tar xvzf lapack.tgz
$ cd lapack-3.2.1
$ cp ./INSTALL/make.inc.gfortran make.inc
   If your OS is 64bit, modify make.inc
   Old:
    OPTS     = -O2
    NOOPT    = -O0
   New:
    OPTS     = -O2 -fPIC
    NOOPT    = -O0 -fPIC
$ make blaslib lapacklib
$ cp blas_LINUX.a $HOME/sdpa/lib/libblas.a
$ cp lapack_LINUX.a $HOME/sdpa/lib/liblapack.a

# SDPA
$ cd $HOME/sdpa 
$ tar xzf sdpa-7.3.2.tar.gz
$ cd sdpa-7.3.2
$ export CC=gcc
$ export CXX=g++
$ export FC=gfortran
$ export CFLAGS="-funroll-all-loops -O2 -m64"
$ export CXXFLAGS="-funroll-all-loops -O2 -m64"
$ export FFLAGS="-funroll-all-loops -O2 -m64"
$ ./configure --with-blas="-L${HOME}/sdpa/lib -lblas" --with-lapack="-L${HOME}/sdpa/lib -llapack"
$ make
$ make install

If you specify the number of threads with the SDPA,
set OMP_NUM_THREADS environment variable(ex. export OMP_NUM_THREADS=4).
If you have dual-core or quad-core CPU, we strongly recommend that set 

$ export OMP_NUM_THREADS=2
or
$ export OMP_NUM_THREADS=4


The details of the configure script option for each OS
can be found in sdpa user manual.
(http://sdpa.indsys.chuo-u.ac.jp/sdpa/files/sdpa.7.1.1.manual.20080618.pdf)

(3) execute
Try the following command to execute sdpa
   $ cd $HOME/sdpa/bin/
   $ ./sdpa
Then you will see message from SDPA and can check command line options.
To solve input dat-s and write its result,
   $ ./sdpa $HOME/sdpa/share/sdpa/example/example1.dat-s example1.result

----------------------------------------------    
2. Compile callable-library example (optional)

To compile callable-library example, use 'make' command 
in 'libexample' directory
   $ cd $HOME/sdpa/share/sdpa/libexample
   $ make

The details of callable-library can be found in 
SDPA user manual in $HOME/sdpa/share/sdpa/

----------------------------------------------    
3. Compile SDPA-M (optional)

To compile SDPA-M, use 'make' command 
in 'mex' directory
   $ cd $HOME/sdpa/share/sdpa/mex
   $ make 

If you use Octave instead of Matlab, then
   $ cd $HOME/sdpa/share/sdpa/mex
   $ make COMPILE_ENVIRONMENT=octave

The make command automatically searches 'mex' command 
by invoking 'matlab' command. If this auto-search fails,
you setup the full-path for 'mex' command in Makefile
in the 'mex' directory and use 'make' command again.

Since the usage of this new SDPA-M as SDPA-M 6.2.0,
SDPA-M 6.2.0 manual is very useful.
(http://sdpa.indsys.chuo-u.ac.jp/sdpa/files/sdpa.6.2.0.manual.pdf)

----------------------------------------------    
4. Note for Mac OS X

Since the installation of SDPA requires gfortran, 
we recommend the users install 'fink' system, 
which is a package manager for Mac OS X.
(You need an administrator authority for your system).

To install fink system, please refer 
http://www.finkproject.org/
and
http://www.finkproject.org/download/index.php?phpLang=en

In particular, the following URLs are useful when 
you have trouble with fink.
http://www.finkproject.org/faq/upgrade-fink.php?phpLang=en
http://www.finkproject.org/faq/index.php?phpLang=en

(1-1)  SDPA linked against ATLAS library

Install atlas by the fink system. 
(You can install atlas by following Section 1 above;
but the installation by the fink system is easier.)

$ sudo fink install atlas

The atlas package in the fink system also contains
lapack library. If your system does not have gcc-4
or gfortran, the fink system automatically installs
them before compiling the atlas package.

You can check whether your system successfully installed 
gcc-4 and atlas by the following command.

[To check gcc-4]
$ /sw/bin/gcc-4 -v
$ /sw/bin/g++-4 -v
$ /sw/bin/gfortran -v

[To check atlas]
$ ls -l /sw/lib/libptf77blas.a
$ ls -l /sw/lib/libptcblas.a
$ ls -l /sw/lib/libatlas.a
$ ls -l /sw/lib/liblapack.a

To install SDPA, download the SDPA from the SDPA Homepage;
http://sdpa.indsys.chuo-u.ac.jp/sdpa/download.html
You can get the sdpa-7.3.2.tar.gz

Then the following commands will install SDPA.

$ mkdir $HOME/sdpa
$ cd $HOME/sdpa 
$ tar xzf sdpa-7.3.2.tar.gz
$ cd sdpa-7.3.2
$ export CC=/sw/bin/gcc-4
$ export CXX=/sw/bin/g++-4
$ export FC=/sw/bin/gfortran
$ export CFLAGS="-funroll-all-loops -O2 -m32"
$ export CXXFLAGS="-funroll-all-loops -O2 -m32"
$ export FFLAGS="-funroll-all-loops -O2 -m32"
$ ./configure --with-blas="/sw/lib/libptf77blas.a /sw/lib/libptcblas.a /sw/lib/libatlas.a" --with-lapack="/sw/lib/liblapack.a"
$ make
$ make install

(1-2) SDPA linked against GotoBLAS library or LAPACK/BLAS library

In these cases, instead of installing atlas, you need to 
install gfortran into Mac OS X. You can install gfortran 
by the following command:

$ fink install gcc43

After installing gfortran, go back to (2-2) of Section 2. 
(Even if you have already installed LAPACK into your computer 
by using fink system, it is inappropriate to link with GotoBLAS
(since the LAPACK of the fink system has some ATLAS interface)
and you need to install LAPACK by following (2-2) of Section 2.)

(1-3) compile callable-library example and SDPA-M in Mac OS X

To use callable library and SDPA-M,
after using make install, you need to modify
etc/make.inc to remove "-lcrt1.10.5"
(due to a confliction between Mac OS X and Matlab).

$ cd $HOME/sdpa/sdpa-7.3.2/etc
$ sed -e 's/-lcrt1.10.5.o//g' -i .bak make.inc

Then

$ cd $HOME/sdpa/share/sdpa/libexample
$ make
$ cd $HOME/sdpa/share/sdpa/mex
$ make

Sometimes 'make' command in the 'mex' directory fails,
since Matlab directory may depend on your environment.
In the case, modify 'Makefile' in the 'mex' directory
from 
    MEX = /Applications/MATLAB_R2008b.app/bin/mex
to (for example)
    MEX = /Applications/MATLAB_R2007b/bin/mex
and use 'make' command again.

In addition, some warning may be displayed due to
a confliction between Mac OS X and Matlab.

-------------------------------------------------------
5. If you have some trouble

If some bugs are found or you encounter some trouble
when you are compiling SDPA, please let us know from
http://sdpa.indsys.chuo-u.ac.jp/sdpa/contact.html

In particular, attaching error messages and/or 'config.log' file
is very useful to let us understand your situation.

When you have trouble with SDPA-M(Matlab environment),
the following command will display useful messages.

$ matlab -Dgdb
[On gdb environment]
(gdb) run -nodisplay
[On Matlab environment]
>> (Call SDPA-M by sdpam or sedumiwrap)
If Matlab aborts, try the following command in gdb environment.
(gdb) where
The command 'where' will display what happened.
To exit gdb environment,
(gdb) quit
