SPAI – SParse Approximate Inverse PreconditionerMarcus Grote 1 Michael Hagemann 2 |
gunzip spai-3.2.tar.gz tar xvf spai-3.2.tar cd spai-3.2
(Please note that a working Fortran compiler is required to detect the system calling conventions. Furthermore, Matlab needs to be in the current $PATH in order to be detected and used. See Section 3.2.3 for further configuration options on various platforms.)configure --with-matlab make make check
(Please note that the matrix file needs to be the first parameter.)cd src ./spai ../data/m1.mm ./spai ../data/m1.mm -sc 1 -ta 0.7
cd ../matlab
matlab
>> help spai
>> % Load A as matrix `m1.dat' and create RHS b=A*1.
>> A = spconvert(load('m1.dat'));
>> b = A * ones(size(A,1), 1);
>> % Solve Ax=b, without preconditioning
>> x = bicgstab(A, b, 1e-8, 200);
>> % Compute adaptive SPAI preconditioner (SPAI 3.1)
>> M = spai(A);
>> spy(M);
>> % Solve Ax=b, with SPAI preconditioning
>> x = bicgstab(A, b, 1e-8, 200, @(y) M*y);
>> % Compute block SPAI preconditioner (block size=3)
>> M = spai(A, 0.6, 5, 5, 3, 100000, 0);
>> % Compute threshold based SPAI preconditioner
>> M = spaitau(A, 0.8, 0);
>> % Compute banded SPAI preconditioner
>> M = spaidiags(A, 5, 5, 0);
./configure --with-blas="-L/opt/atlas -lf77blas -lcblas -latlas"If no suitable system BLAS library is found, a local library is built. This will typically decrease the performance of spai.
Or on systems that have the env program, you can do it like this:CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
We have successfully installed and tested SPAI on the following systems:env CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
CC=cc F77=f90 CFLAGS="-xopenmp=stubs" ./configureThe sunperf libraries are detected automatically. If you want to compile the Matlab interface, you cannot link to the sunperf libraries. A possible solution is to compile the local BLAS and LAPACK libraries with:
CC=cc F77=f90 CFLAGS="-xopenmp=stubs" ./configure \
--with-matlab --with-blas=no --with-lapack=no
./configure --with-blas=/opt/acml/gnu64/lib/libacml.aWith Matlab, the following options were necessary, in order to make the library dynamically linkable:
CFLAGS=-fpic ./configure --with-matlab \
--with-blas=/opt/acml/gnu64/lib/libacml.a
>> addpath /dir1 /dir2
>> p = path() >> path (p, '/dir1')
$(PREFIX)/bin $(PREFIX)/bin/spai $(PREFIX)/bin/convert $(PREFIX)/lib $(PREFIX)/lib/libspai.a $(PREFIX)/matlab $(PREFIX)/matlab/spai $(PREFIX)/matlab/spai/spai_full.mexglx $(PREFIX)/matlab/spai/spai.m $(PREFIX)/matlab/spai/spaitau.m $(PREFIX)/matlab/spai/spaidiags.m $(PREFIX)/share $(PREFIX)/share/doc $(PREFIX)/share/doc/spai $(PREFIX)/share/doc/spai/spaidoc.ps $(PREFIX)/share/doc/spai/spaidoc.pdfYou can change the $PREFIX directory with the --prefix= option of the configure script.
while the parallel version is executed with:spai <A> [b] [options]
(Items in <> are required; items in [] are optional.)mpirun -np <n> ./spai <A> [b] [options]
convert ../data/m1.mm m1.binary spai m1.binary -bi 1
Anything much worse than this points to an error. Note that the test may still be considered as "passed" by make.63c63 < 10 4.020936e-10 --- > 10 4.020935e-10 65c65 < 12 2.528134e-12 --- > 12 2.528133e-12 check difference in output!!!
3,5c3,5 < Copyright 1984-2000 The MathWorks, Inc. < Version 6.0.0.88 Release 12 < Sep 21 2000 --- > Copyright 1984-2001 The MathWorks, Inc. > Version 6.1.0.450 Release 12.1 > May 18 2001 check difference in output!!!
if (debug) {
fprintf(fptr_dbg,...);
fflush(fptr_dbg);
}
See the file spai.c in lib for an example.This document was translated from LATEX by HEVEA.