1 Stratimikos Unified Wrapper to Trilinos Linear Solvers and Preconditioners Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation Sandia.

Slides:



Advertisements
Similar presentations
Modular Programming With Functions
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
Exceptions Objectives At the conclusion of this lesson, students should be able to Explain the need for exceptions Correctly write programs that use.
MOOCHO and TSFCore object-oriented software and interfaces for the development of optimization and other advanced abstract numerical algorithms Roscoe.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
MS17 A Case Study on the Vertical Integration of Trilinos Solver Algorithms with a Production Application Code Organizer: Roscoe A. Bartlett Sandia National.
Using Belos: Next-generation Iterative Solvers November 6 th, 2007 Using Belos: Next-generation Iterative Solvers November 6 th, 2007 Mike Heroux Rich.
Page 1 Trilinos Software Engineering Technologies and Integration Capability Area Overview Roscoe A. Bartlett Department.
Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary of Lockheed Martin Corporation,
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
Java: Chapter 1 Computer Systems Computer Programming II.
Teuchos: Utilities for Developers & Users November 4 th, 1:15-4:30pm Roscoe Bartlett Mike Heroux Kris Kampshoff Kevin Long Paul Sexton Heidi Thornquist.
Trilinos: From a User’s Perspective Russell Hooper Nov. 7, 2007 SAND P Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed.
Integrating Trilinos Solvers to SEAM code Dagoberto A.R. Justo – UNM Tim Warburton – UNM Bill Spotz – Sandia.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
PyTrilinos: A Python Interface to Trilinos Bill Spotz Sandia National Laboratories Reproducible Research in Computational Geophysics August 31, 2006.
Page 1 Trilinos Software Engineering Technologies and Integration Capability Area Overview Roscoe A. Bartlett Department.
Page 1 Trilinos Software Engineering Technologies and Integration Numerical Algorithm Interoperability and Vertical Integration –Abstract Numerical Algorithms.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Large-Scale Stability Analysis Algorithms Andy Salinger, Roger Pawlowski, Ed Wilkes Louis Romero, Rich Lehoucq, John Shadid Sandia National Labs Albuquerque,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
Page 1 Embedded Sensitivities and Optimization From Research to Applications Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation Sandia.
Strategic Goals: To align the many efforts at Sandia involved in developing software for the modeling and simulation of physical systems (mostly PDEs):
Java Introduction to JNI Prepared by Humaira Siddiqui.
Amesos Sparse Direct Solver Package Ken Stanley, Rob Hoekstra, Marzio Sala, Tim Davis, Mike Heroux Trilinos Users Group Albuquerque 3 Nov 2004.
Contract based programming Using pre- and post-conditions, and object invariants Contract based programming1.
Tammy Dahlgren with Tom Epperly, Scott Kohn, and Gary Kumfert Center for Applied Scientific Computing Common Component Architecture Working Group October.
1 ModelEvaluator Scalable, Extendable Interface Between Embedded Nonlinear Analysis Algorithms and Applications Roscoe A. Bartlett Department of Optimization.
Sensitivities and Optimization: Going Beyond the Forward Solve (to Enable More Predictive Simulations) Roscoe A. Bartlett Department of Optimization &
ML: Multilevel Preconditioning Package Trilinos User’s Group Meeting Wednesday, October 15, 2003 Jonathan Hu Sandia is a multiprogram laboratory operated.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Strategies for Solving Large-Scale Optimization Problems Judith Hill Sandia National Laboratories October 23, 2007 Modeling and High-Performance Computing.
Software Construction Lecture 18 Software Testing.
Solvers Made Easy (to use and use together) Thyra, Stratimikos, Handles and More... Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation.
An Overview of the Thyra Interoperability Effort Current Status and Future Plans Roscoe A. Bartlett Department 1411: Optimization and Uncertainty Estimation.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
Danny Dunlavy, Andy Salinger Sandia National Laboratories Albuquerque, New Mexico, USA SIAM Parallel Processing February 23, 2006 SAND C Sandia.
Amesos Interfaces to sparse direct solvers October 15, :30 – 9:30 a.m. Ken Stanley.
Scalable Linear Algebra Capability Area Michael A. Heroux Sandia National Laboratories Sandia is a multiprogram laboratory operated by Sandia Corporation,
Thyra from a Developer's Perspective Roscoe A. Bartlett Department 1411: Optimization and Uncertainty Estimation Sandia National Laboratories Sandia is.
New Features in ML 2004 Trilinos Users Group Meeting November 2-4, 2004 Jonathan Hu, Ray Tuminaro, Marzio Sala, Michael Gee, Haim Waisman Sandia is a multiprogram.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
Teuchos: Utilities for Developers & Users November 2nd, 3:30-4:30pm Roscoe Bartlett Mike Heroux Kris Kampshoff Kevin Long Paul Sexton Heidi.
Thyra For Developers Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation Sandia National Laboratories Trilinos Users Group Meeting (Developers.
Using Thyra and Stratimikos to Build Blocked and Implicitly Composed Solver Capabilities Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation.
Trilinos Strategic (and Tactical) Planning Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United.
An Overview of Belos and Anasazi October 16 th, 11-12am Heidi Thornquist Teri Barth Rich Lehoucq Mike Heroux Computational Mathematics and Algorithms Sandia.
Page 1 CMake Trilinos? Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation Esteban J. Guillen Department.
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy’s National Nuclear.
Photos placed in horizontal position with even amount of white space between photos and header Sandia National Laboratories is a multi-program laboratory.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 34.
ML: A Multilevel Preconditioning Package Copper Mountain Conference on Iterative Methods March 29-April 2, 2004 Jonathan Hu Ray Tuminaro Marzio Sala Sandia.
Combining Trilinos Packages To Solve Linear Systems Michael A. Heroux Sandia National Labs.
What’s New for Epetra Michael A. Heroux Sandia National Laboratories Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin.
Page 1 Open-Source Software for Interfacing and Support of Large-scale Embedded Nonlinear Optimization Roscoe A. Bartlett
DOE/Office of Science/ASCR (Sandia National Laboratories)
User-Written Functions
ModelEvaluator Scalable, Extendable Interface Between Embedded Nonlinear Analysis Algorithms and Applications Roscoe A. Bartlett Department of Optimization.
Chapter 5 - Functions Outline 5.1 Introduction
Higher-Order Procedures
Trilinos Software Engineering Technologies and Integration
Embedded Nonlinear Analysis Tools Capability Area
CSE 1020:Software Development
Overview Activities from additional UP disciplines are needed to bring a system into being Implementation Testing Deployment Configuration and change management.
Presentation transcript:

1 Stratimikos Unified Wrapper to Trilinos Linear Solvers and Preconditioners Roscoe A. Bartlett Department of Optimization & Uncertainty Estimation Sandia National Laboratories April 3 rd, 2008 Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy under contract DE-AC04-94AL85000.

2 Motivation for Stratimikos

3 Nonlinear Algorithms and Applications : Everyone for Themselves? NOX / LOCA RythmosMOOCHO XyceCharonAriaTramonto Aleph … … Trilinos and non-Trilinos Preconditioner and Linear Solver Capability Key Point BAD Nonlinear ANA Solvers in Trilinos Sandia Applications

4 Nonlinear Algorithms and Applications : Thyra & Model Evaluator! Trilinos and non-Trilinos Preconditioner and Linear Solver Capability NOX / LOCA MOOCHO XyceCharonAriaTramonto Aleph … … Key Points Provide single interface from nonlinear ANAs to applications Provide single interface for applications to implement to access nonlinear ANAs Provides shared, uniform access to linear solver capabilities Once an application implements support for one ANA, support for other ANAs can quickly follow Nonlinear ANA Solvers in Trilinos Sandia Applications Rythmos Stratimikos! Model Evaluator

5 Stratimikos Overview

6 Introducing Stratimikos Stratimikos created Greek words "stratigiki“ (strategy) and "grammikos“ (linear) Based on the foundation of abstract interface layer Thyra Defines class Stratimikos::DefaultLinearSolverBuilder Provides common access to: Linear Solvers: Amesos, AztecOO, Belos, … Preconditioners: Ifpack, ML, … Reads in options through a parameter list (read from XML?) Accepts any linear system objects that provide Epetra_Operator / Epetra_RowMatrix view of the matrix SPMD vector views for the RHS and LHS (e.g. Epetra_[Multi]Vector objects) Provides uniform access to linear solver options that can be leveraged across multiple applications and algorithms Future: TOPS-2 will add PETSc and other linear solvers and preconditioners! Key Points Stratimikos is an important building block for creating more sophisticated linear solver capabilities!

7 Preconditioners and Preconditioner Factories Create preconditioner prec with preconditioner operators P L and/or P R such that P L A, or AP R, or P L AP R is “easier” to solve than unpreconditioned A. PreconditionerFactoryBase createPrec() : PreconditionerBase initializePrec( in fwdOp, inout prec ) PreconditionerFactoryBase : Creates and initializes PrecondtionerBase objects > prec Allows unlimited creation/reuse of preconditioner objects Supports reuse of factorization structures Adapters currently available for Ifpack and ML New Stratimikos package provides a singe parameter-driver wrapper for all of these PreconditionerBase getLeftPrecOp() : LinearOpBase getRightPrecOp() : LinearOpBase getUnspecifiedPrecOp() : LinearOpBase Key Points You can create your own PreconditionerFactory subclass!

8 Linear Operator With Solve and Factories LinearOpBase LinearOpWithSolveBase solve( in B, inout X, … ) Appropriate for both direct and iterative solvers Supports multiple simultaneous solutions as multi-vectors Allows targeting of different solution criteria to different RHSs Supports a “default” solve LinearOpWithSolveFactoryBase createOp() : LinearOpWithSolveBase initializeOp( in fwdOp, inout Op ) initializePreconditionedOp( in fwdOp, in prec, inout Op) LinearOpWithSolveBase : Combines a linear operator and a linear solver LinearOpWithSolveFactoryBase : Uses LinearOpBase objects to initialize LOWSB objects LinearOpWithSolveBase > Allows unlimited creation/reuse of LinearOpWithSolveBase objects Supports reuse of factorizations/preconditioners Supports client-created external preconditioners (which are ignored by direct solvers) Appropriate for both direct and iterative solvers Concrete adaptors for Amesos, AztecOO, and Belos are available New Stratimikos package provides a single parameter-driven wrapper to all of these! Key Points You can create your own subclass!

9 Simple Stratimikos Example

10 Simple Stratimikos Example simple_stratimikos_example.cpp Demonstrates how to solve single-RHS linear systems expressed as Epetra objects Typical steps for “using a solver that accepts Thyra objects”: A)Setup the environment for the program => Read in command-line options B)Create the input objects using your data structures (independent of Thyra) => Read in linear system objects in terms of Epetra objects C)Wrap your objects as Thyra objects (The “glue”) => Use Epetra-to-Thyra wrapper functions D)Call the solver through Thyra interfaces (Thyra-specific) => Create the LinearOpWithSolve[Factory]Base objects and solve … E)Post process the solution (if needed) using your objects (independent of Thyra) => Post process solution and check in terms of Epetra objects (Not Thyra!!!)

11 A) Setup the environment for the program // // A) Program setup code // // Read options from command-line // std::string matrixFile = ""; … Stratimikos::DefaultLinearSolverBuilder linearSolverBuilder; CommandLineProcessor clp(false); // Don't throw exceptions // Set up command-line options for the linear solver that will be used! linearSolverBuilder.setupCLP(&clp); clp.setOption( "matrix-file", &matrixFile,"Defines the matrix and perhaps the RHS and LHS for a linear system to be solved." ); … CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv); if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return; See the file simple_stratimikos_example.cpp for more details …

12 B) Create the input objects using your data structures // // B) Epetra-specific code that sets up the linear system to be solved // // While the below code reads in the Epetra objects from a file, you can // setup the Epetra objects any way you would like. Note that this next // set of code as nothing to do with Thyra at all, and it should not. // *out << "\nReading linear system in Epetra format from the file \'"<<matrixFile<<"\'...\n"; #ifdef HAVE_MPI Epetra_MpiComm comm(MPI_COMM_WORLD); #else Epetra_SerialComm comm; #endif RCP epetra_A; RCP epetra_x, epetra_b; EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_A, NULL, &epetra_x, &epetra_b ); if(!epetra_b.get()) { *out << "\nThe RHS b was not read in so generate a new random vector...\n"; epetra_b = rcp(new Epetra_Vector(epetra_A->OperatorRangeMap())); epetra_b->Random(); } if(!epetra_x.get()) { *out << "\nThe LHS x was not read in so generate a new zero vector...\n"; epetra_x = rcp(new Epetra_Vector(epetra_A->OperatorDomainMap())); epetra_x->PutScalar(0.0); // Initial guess is critical! } Create the Epetra objects any way that you would like …

13 C) Wrap your objects as Thyra objects (The “glue”) // // C) The "Glue" code that takes Epetra objects and wraps them as Thyra // objects // // This next set of code wraps the Epetra objects that define the linear // system to be solved as Thyra objects so that they can be passed to the // linear solver. // RCP > A = Thyra::epetraLinearOp( epetra_A ); RCP > x = Thyra::create_Vector( epetra_x, A->domain() ); RCP > b = Thyra::create_Vector( epetra_b, A->range() ); Turning Epetra objects into Thyra objects is easy! Epetra-to-Thyra wrapper functions are found in Thyra_EpetraThyraWrappers.hpp

14 D) Call the solver through Thyra interfaces // // D) Thyra-specific code for solving the linear system // // Note that this code has no mention of any concrete implementation and // therefore can be used in any use case. // // Reading in the solver parameters from the parameters file and/or from // the command line. This was setup by the command-line options // set by the setupCLP(...) function above. linearSolverBuilder.readParameters(out.get()); // Create a linear solver factory given information read from the // parameter list. RCP > lowsFactory = linearSolverBuilder.createLinearSolveStrategy(""); // Setup output stream and the verbosity level lowsFactory->setOStream(out); lowsFactory->setVerbLevel(Teuchos::VERB_LOW); // Create a linear solver based on the forward operator A RCP > lows = Thyra::linearOpWithSolve(*lowsFactory,A); // Solve the linear system (note: the initial guess in 'x' is critical) Thyra::SolveStatus status = Thyra::solve(*lows,Thyra::NOTRANS,*b,&*x); *out << "\nSolve status:\n" << status; // Write the linear solver parameters after they were read linearSolverBuilder.writeParamsFile(*lowsFactory); This part of the code has nothing to do with Epetra! This is really only a trivial interaction with Thyra!

15 // // E) Post process the solution and check the error // // Note that the below code is based only on the Epetra objects themselves // and does not in any way depend or interact with any Thyra-based // objects. The point is that most users of Thyra can largely gloss over // the fact that Thyra is really being used for anything. // // Wipe out the Thyra wrapper for x to guarantee that the solution will be // written back to epetra_x! x = Teuchos::null; *out << "\nSolution ||epetra_x||2 = " << epetraNorm2(*epetra_x) << "\n"; *out << "\nTesting the solution error ||b-A*x||/||b|| computed through the Epetra objects...\n"; // r = b - A*x Epetra_Vector epetra_r(*epetra_b); { Epetra_Vector epetra_A_x(epetra_A->OperatorRangeMap()); epetra_A->Apply(*epetra_x,epetra_A_x); epetra_r.Update(-1.0,epetra_A_x,1.0); } const double nrm_r = epetraNorm2(epetra_r), nrm_b = epetraNorm2(*epetra_b), rel_err = ( nrm_r / nrm_b ); const bool passed = (rel_err <= tol); *out << "||b-A*x||/||b|| = " << nrm_r << "/" << nrm_b << " = " << rel_err << " < tol = " << tol << " ? " << ( passed ? "passed" : "failed" ) << "\n"; E) Post process the solution (if needed) using your objects

16 Stratimikos Parameter Lists

17 Stratimikos Parameter List and Sublists Linear Solvers Preconditioners Sublists passed on to package code! Top level parameters Every parameter and sublist not in red is handled by Thyra code and is fully validated!

18 Automatically Generated Parameter List Documentation “Human readable” automatically generated documentation for Stratimikos Linear Solver Type : string = Amesos # Determines the type of linear solver that will be used. # The parameters for each solver type are specified in the sublist "Linear Solver Types" # Valid values: "Belos", "Amesos", "AztecOO" Preconditioner Type : string = ML # Determines the type of preconditioner that will be used. # This option is only meaningful for linear solvers that accept preconditioner factory objects! # The parameters for each preconditioner are specified in the sublist "Preconditioner Types" # Valid values: "None", "Ifpack", "ML" Linear Solver Types -> AztecOO -> Output Every RHS : bool = 0 # Determines if output is created for each individual RHS (true or 1) or if output # is just created for an entire set of RHSs (false or 0). Forward Solve -> Max Iterations : int = 400 # The maximum number of iterations the AztecOO solver is allowed to perform. Tolerance : double = 1e-06 # The tolerence used in the convergence check (see the convergence test # in the sublist "AztecOO Settings") AztecOO Settings -> Aztec Solver : string = GMRES # Type of linear solver algorithm to use. # Valid values: "CG", "GMRES", "CGS", "TFQMR", "BiCGStab", "LU" Convergence Test : string = r0 # The convergence test to use for terminating the iterative solver. # Valid values: "r0", "rhs", "Anorm", "no scaling", "sol"... See Doxygen documentation for Stratimikos::DefaultLinearSolverBuilder!

19 Output of Default Parameter Values Example input parameter (sub)list to Stratimikos (use simple_stratimikos_example.exe)... Output (augmented) parameter (sub)list => Ifpack is not showing its default parameters!

20 Parameter List Validation

21 Error Messages for Improper Parameters/Sublists Example: User misspells “Aztec Solver” as “ztec Solver” Error message generated from PL::validateParameters(…) with exception: Error, the parameter {name="ztec Solver",type="string",value="GMRES"} in the parameter (sub)list "RealLinearSolverBuilder->Linear Solver Types->AztecOO->Forward Solve->AztecOO Settings" was not found in the list of valid parameters! The valid parameters and types are: { "Aztec Preconditioner" : string = ilu "Aztec Solver" : string = GMRES … }

22 Error Messages for Improper Parameters/Sublists Example: User specifies the wrong type for “Aztec Solver” Error message generated from PL::validateParameters(…) with exception: Error, the parameter {paramName="Aztec Solver",type="int"} in the sublist "DefaultRealLinearSolverBuilder->Linear Solver Types->AztecOO->Forward Solve- >AztecOO Settings" has the wrong type. The correct type is "string"!

23 Error Messages for Improper Parameters/Sublists Example: User specifies the wrong value for “Aztec Solver” Error message generated from PL::validateParameters(…) with exception: Error, the value "GMRESS" is not recognized for the parameter "Aztec Solver" in the sublist "". Valid selections include: "CG", "GMRES", "CGS", "TFQMR", "BiCGStab", "LU".

24 Future Plans for Stratimikos TOPS-2 PETSc/Trilinos Interoperability Fill PETSc matrices & vectors and use Trilinos preconditioners and linear solvers Access PETSc preconditioners and solvers through a parameter list in Stratimikos? Fortran 2003 interface through Stratimikos Built on Fotran/Epetra wrappers GUI to manipulate Parameter List XML files “Smart” linear solver & preconditioner builders?