A Tutorial on Anasazi and Belos 2011 Trilinos User Group Meeting November 1st, 2011 Chris Baker David Day Mike Heroux Mark Hoemmen Rich Lehoucq Mike Parks Heidi Thornquist (Lead) Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary of Lockheed Martin Corporation, for the U.S. Department of Energy's National Nuclear Security Administration under contract DE-AC04-94AL85000. 2011-8264P
42
Embed
A Tutorial on Anasazi and Belos 2011 Trilinos User Group Meeting November 1st, 2011 Chris Baker David Day Mike Heroux Mark Hoemmen Rich Lehoucq Mike Parks.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
A Tutorial on Anasazi and Belos
2011 Trilinos User Group Meeting November 1st, 2011
Chris BakerDavid Day
Mike Heroux Mark HoemmenRich Lehoucq
Mike ParksHeidi Thornquist (Lead)
Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation,
a wholly owned subsidiary of Lockheed Martin Corporation, for the U.S. Department of Energy's
National Nuclear Security Administration under contract DE-AC04-94AL85000.
2011-8264P
Outline
Belos and Anasazi Framework Background / Motivation Framework overview Available solver components
Using Anasazi and Belos Simple examples Through Stratimikos (Belos) Through LOCA (Anasazi)
Summary
Background / Motivation
Several iterative linear solver / eigensolver libraries exist: PETSc, SLAP, LINSOL, Aztec(OO), … SLEPc, PRIMME, ARPACK, …
None of the linear solver libraries can efficiently deal with multiple right-hand sides or sequences of linear systems
Stopping criteria are predetermined for most libraries The underlying linear algebra is static
AztecOO
A C++ wrapper around Aztec library written in C Algorithms: GMRES, CG, CGS, BiCGSTAB, TFQMR Offers status testing capabilities Output verbosity level can be determined by user Interface requires Epetra objects
Double-precision arithmetic
Interface to matrix-vector product is defined by the user through the Epetra_Operator
ARnoldi PACKage(ARPACK)
Written in Fortran 77 Algorithms: Implicitly Restarted Arnoldi/Lanczos Static convergence tests Output formatting, verbosity level is determined by
user Uses LAPACK/BLAS to perform underlying vector
space operations Offers abstract interface to matrix-vector products
through reverse communication
Scalable Library for Eigenvalue Problem Computations (SLEPc)
Written in C (Campos, Román, Romero, and Thomás, 2011). Provides some basic eigensolvers as well as wrappers around:
(BLZPACK), LOBPCG (BLOPEX), and Lanczos (TRLAN) Static convergence tests Uses PETSc to perform underlying vector space operations,
matrix-vector products, and linear solves Allows the creation / registration of new matrix-vector products
Next generation linear solver (Belos) and eigensolver (Anasazi) libraries, written in templated C++. Iterative methods for solving sparse, matrix-free systems
Provide a generic interface to a collection of algorithms for solving linear problems and eigenproblems.
Algorithms developed with generic programming techniques. Algorithmic components:
• Ease the implementation of complex algorithms Operator/MultiVector interface (and Teuchos::ScalarTraits):
• Allow the user to leverage their existing software investment• Multi-precision solver capability
Design offers: Interoperability, extensibility, and reusability
Includes block linear solvers and eigensolvers.
Anasazi and Belos
Why are Block Solvers Useful? In general, block solvers enable the use of faster computational
kernels.
Block Eigensolvers ( Op(A)X = X ): Reliably determine multiple and/or clustered eigenvalues. Example applications:
Single RHS: Ax = b Multiple RHS (available simultaneously): AX = B Multiple RHS (available sequentially): Axi = bi , i=1,…,k
Sequential Linear systems: Aixi = bi , i=1,…,k
Linear Least Squares: min || Ax – b ||2
Leverage research advances of solver community: Block methods: block GMRES [Vital], block CG/BICG [O’Leary] “Seed” solvers: hybrid GMRES [Nachtigal, et al.] “Recycling” solvers for sequences of linear systems [Parks, et al.] Restarting, orthogonalization techniques
Provides an interface between the basic iterations and the eigenproblem to be solved.
Abstract base class Anasazi::Eigenproblem Allows spectral transformations to be removed from the algorithm. Differentiates between standard and generalized eigenproblems. Stores number of requested eigenvalues, symmetry, initial vector,
Concrete class Anasazi::BasicEigenproblem Describes standard or general, Hermitian or non-Hermitian
eigenproblems.
Belos LinearProblem Interface
Provides an interface between the basic iterations and the linear problem to be solved.
Templated class Belos::LinearProblem<ST,MV,OP> Allows preconditioning to be removed from the algorithm. Behavior defined through traits mechanisms. Methods:
StatusTest Interface Informs solver iterate of change in state, as defined by user. Similar to NOX / AztecOO. Multiple criterion can be logically connected using StatusTestCombo Abstract base class [Anasazi/Belos]::StatusTest
Anasazi Eigensolver Example(Construct the eigenproblem)
// Create eigenproblemconst int nev = 5;RefCountPtr<Anasazi::BasicEigenproblem<ScalarType,MV,OP> > problem = Teuchos::rcp( new Anasazi::BasicEigenproblem<ScalarType,MV,OP>(K,M,ivec) );//// Inform the eigenproblem that it is Hermitianproblem->setHermitian(true);//// Set the number of eigenvalues requestedproblem->setNEV( nev );//// Inform the eigenproblem that you are done passing it informationbool ret = problem->setProblem();if (boolret != true) { // Anasazi::BasicEigenproblem::SetProblem() returned with error!!! …}
Anasazi Eigensolver Example(Construct and run the eigensolver)
// Create parameter list to pass into the solver managerTeuchos::ParameterList MyPL;MyPL.set( "Verbosity", Anasazi::Errors + Anasazi::Warnings );MyPL.set( "Which", "SM" );MyPL.set( "Block Size", 5 );MyPL.set( "Num Blocks", 8 );MyPL.set( "Maximum Restarts", 100 );MyPL.set( "Convergence Tolerance", 1.0e-6 );MyPL.set( "Use Locking", true );MyPL.set( "Locking Tolerance", tol/10 );//// Create the solver managerAnasazi::BlockDavidsonSolMgr<ScalarType,MV,OP> MySolverMan(problem, MyPL);
// Solve the problem to the specified tolerances or lengthAnasazi::ReturnType returnCode = MySolverMan.solve();if (returnCode != Anasazi::Converged) { // Solver failed!!! // But wait, we may still have some eigenpairs.}
Anasazi Eigensolver Example(Retrieve the eigenpairs)
// Get the eigenvalues and eigenvectors from the eigenproblemAnasazi::Eigensolution<ScalarType,MV> sol = problem->getSolution();std::vector<MagnitudeType> evals = sol.Evals;RefCountPtr<MV> evecs = sol.Evecs;int numev = sol.numVecs;//// Check to see if there are any computed eigenpairsif (numev > 0) { // Do something with computed eigenpairs …}…
Belos Linear Solver Example(Construct the linear problem)
int main(int argc, char *argv[]) { MPI_Init(&argc,&argv); Epetra_MpiComm Comm(MPI_COMM_WORLD); int MyPID = Comm.MyPID();
bool verbose = false, debug = false, proc_verbose = false; int frequency = -1; // frequency of status test output. int blocksize = 1; // blocksize int numrhs = 1; // number of right-hand sides to solve for int maxiters = 100; // maximum number of iterations allowed int maxsubspace = 50; // maximum number of blocks int maxrestarts = 15; // number of restarts allowed MT tol = 1.0e-5; // relative residual tolerance
const int NumGlobalElements = B->GlobalLength(); ParameterList belosList; belosList.set( "Num Blocks", maxsubspace); // Maximum number of blocks in Krylov
factorization belosList.set( "Block Size", blocksize ); // Blocksize to be used by iterative solver belosList.set( "Maximum Iterations", maxiters ); // Maximum number of iterations allowed belosList.set( "Maximum Restarts", maxrestarts ); // Maximum number of restarts allowed belosList.set( "Convergence Tolerance", tol ); // Relative convergence tolerance requested int verbosity = Belos::Errors + Belos::Warnings; if (verbose) { verbosity += Belos::TimingDetails + Belos::StatusTestDetails; if (frequency > 0) belosList.set( "Output Frequency", frequency ); } if (debug) { verbosity += Belos::Debug; } belosList.set( "Verbosity", verbosity );
Belos Linear Solver Example(Set the solver parameters)
// Construct linear problem instance. Belos::LinearProblem<double,MV,OP> problem( A, X, B ); bool set = problem.setProblem(); if (set == false) { std::cout << std::endl << "ERROR: Belos::LinearProblem failed to
• Belos and Anasazi are next-generation linear and eigensolver libraries• Designed for interoperability, extensibility, and reusability
• Belos and Anasazi are readily available:• Can be used as standalone linear and eigensolvers• Belos available through Stratimikos• Anasazi available through LOCA