| 1 |
\documentclass[xcolor=dvipsnames]{beamer} |
| 2 |
|
| 3 |
\usecolortheme[named=brown]{structure} |
| 4 |
\useoutertheme{infolines} |
| 5 |
%\usefonttheme{serif} |
| 6 |
\usefonttheme[stillsansseriftext]{serif} |
| 7 |
%\usetheme{Singapore} |
| 8 |
\usetheme[height=7mm]{Madrid} |
| 9 |
\setbeamertemplate{navigation symbols}{} |
| 10 |
\setbeamercovered{dynamic} |
| 11 |
|
| 12 |
%------------------------------------------------------------------------------- |
| 13 |
% get epsf.tex file, for encapsulated postscript files: |
| 14 |
\input epsf |
| 15 |
%------------------------------------------------------------------------------- |
| 16 |
% macro for Postscript figures the easy way |
| 17 |
% usage: \postscript{file.ps}{scale} |
| 18 |
% where scale is 1.0 for 100%, 0.5 for 50% reduction, etc. |
| 19 |
% |
| 20 |
|
| 21 |
\newcommand{\postscript}[2] |
| 22 |
{\setlength{\epsfxsize}{#2\hsize} |
| 23 |
\centerline{\epsfbox{#1}}} |
| 24 |
%------------------------------------------------------------------------------- |
| 25 |
|
| 26 |
\usepackage{graphics} |
| 27 |
\usepackage{color} |
| 28 |
\usepackage{epsfig} |
| 29 |
\usepackage{microtype} |
| 30 |
\usepackage{verbatim} |
| 31 |
\usepackage{listings} |
| 32 |
\lstset{ |
| 33 |
language=C++, |
| 34 |
basicstyle=\small, |
| 35 |
identifierstyle=\ttfamily, |
| 36 |
flexiblecolumns=true % improve the letter kerning in listings |
| 37 |
} |
| 38 |
\usepackage{ifthen} |
| 39 |
\usepackage{tikz} |
| 40 |
\usetikzlibrary{shapes.multipart} |
| 41 |
\usetikzlibrary{arrows} |
| 42 |
\usetikzlibrary{calc} |
| 43 |
\usetikzlibrary{fit} |
| 44 |
\tikzset{ |
| 45 |
every text node part/.style={text centered}, |
| 46 |
rectangle split empty part height=0pt, |
| 47 |
implementation/.style={>=open triangle 60,dashed,->}, |
| 48 |
generalization/.style={>=open triangle 60,->}, |
| 49 |
dependency/.style={>=angle 60,dashed,->}, |
| 50 |
association/.style={>=angle 60,->} |
| 51 |
} |
| 52 |
|
| 53 |
% For drawing UML classes |
| 54 |
% Parameters: |
| 55 |
% #1 => width of the box (defaults to 3.5cm) |
| 56 |
% #2 => position of the box (coordinate or relative) |
| 57 |
% #3 => name of the tikz node |
| 58 |
% #4 => class name |
| 59 |
% #5 => (optional) class template parameter |
| 60 |
% #6 => class members |
| 61 |
% #7 => class methods |
| 62 |
\newcommand{\myclass}[7][3.5cm] |
| 63 |
{ |
| 64 |
\node[rectangle split, |
| 65 |
rectangle split parts=3, |
| 66 |
draw, |
| 67 |
fill=white, |
| 68 |
text width=#1] (#3) at #2 |
| 69 |
{ \textbf{#4} |
| 70 |
\nodepart{second} |
| 71 |
#6 |
| 72 |
\nodepart{third} |
| 73 |
#7 |
| 74 |
}; |
| 75 |
|
| 76 |
\ifthenelse{\equal{#5}{}}{}{ |
| 77 |
\node[rectangle,dashed,draw,fill=white,anchor=base] at (#3.north east) |
| 78 |
{ #5 }; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
\renewcommand{\thefootnote}{} |
| 83 |
|
| 84 |
\title[Amesos2]{Amesos2: Common Interface to Direct Solvers} |
| 85 |
\author[Bavier,Boman,Rajamanickam]{Eric Bavier and Erik Boman and Siva Rajamanickam} |
| 86 |
\institute[SNL]{ |
| 87 |
Sandia National Laboratories |
| 88 |
} |
| 89 |
\date[]{July 6, 2011} |
| 90 |
|
| 91 |
|
| 92 |
\begin{document} |
| 93 |
|
| 94 |
\begin{frame}[plain] |
| 95 |
\titlepage |
| 96 |
\footnote{\tiny{Sandia National Laboratories is a multi mission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-NA0003525.}} |
| 97 |
\end{frame} |
| 98 |
|
| 99 |
\section{Introduction} |
| 100 |
|
| 101 |
\begin{frame} |
| 102 |
\frametitle{Amesos2 Motivation} |
| 103 |
|
| 104 |
\begin{itemize} |
| 105 |
\item Uniform Interface to common third-party direct solvers. |
| 106 |
\medskip |
| 107 |
\item Support a variety of scalar and ordinal datatypes |
| 108 |
\medskip |
| 109 |
\item Support Epetra and Tpetra data structures and allow a design that can |
| 110 |
extend to other matrix types (for eg.: PetSc matrix, compressed column |
| 111 |
matrix) |
| 112 |
\medskip |
| 113 |
\item Revisit Amesos design choices and redesign to easily support more |
| 114 |
solvers and matrix types. |
| 115 |
\end{itemize} |
| 116 |
\end{frame} |
| 117 |
|
| 118 |
\section{Design} |
| 119 |
|
| 120 |
\section{Examples} |
| 121 |
|
| 122 |
\begin{frame}[fragile] % ``fragile'' for slides with verbatim |
| 123 |
\frametitle{Use Case 1: Simple Solve.} |
| 124 |
|
| 125 |
$A$, $X$, $B$ all known when creating the solver and the user |
| 126 |
requires one direct solve. |
| 127 |
|
| 128 |
\begin{lstlisting} |
| 129 |
RCP<MAT> A; RCP<MV> X; RCP<MV> B; |
| 130 |
// initialize A and B |
| 131 |
RCP<Solve<MAT,MV> > solver = Amesos::create(A, X, B); |
| 132 |
solver->solve(); // solution placed in X |
| 133 |
\end{lstlisting} |
| 134 |
\end{frame} |
| 135 |
|
| 136 |
\begin{frame}[fragile] |
| 137 |
\frametitle{Typical Usage: Preorder, Symbolic, Numeric, Solve} |
| 138 |
|
| 139 |
$A$, $X$, $B$ all known when creating the solver and the user |
| 140 |
requires one or multiple solves. Different steps of the |
| 141 |
factorization could be called in different places. |
| 142 |
|
| 143 |
\begin{lstlisting} |
| 144 |
RCP<MAT> A; RCP<MV> X; RCP<MV> B; |
| 145 |
// initialize A and B |
| 146 |
RCP<Solve<MAT,MV> > solver = Amesos::create(A, X, B); |
| 147 |
solver->preOrdering(); |
| 148 |
solver->symbolicFactorization(); |
| 149 |
solver->numericFactorization(); |
| 150 |
solver->solve(); |
| 151 |
\end{lstlisting} |
| 152 |
\end{frame} |
| 153 |
|
| 154 |
\begin{frame} |
| 155 |
\frametitle{Solver Interface and Creating a Solver} |
| 156 |
\begin{itemize} |
| 157 |
\item The basic solver interface |
| 158 |
\begin{itemize} |
| 159 |
\item \texttt{preOrdering()} |
| 160 |
\item \texttt{symbolicFactorization()} |
| 161 |
\item \texttt{numericFactorization()} |
| 162 |
\item \texttt{solve()} or \texttt{solve(X,B)} |
| 163 |
\end{itemize} |
| 164 |
\item Creation of an Amesos2 solver |
| 165 |
\begin{enumerate} |
| 166 |
\item Solver name (optional, defaults to ``KLU2'') |
| 167 |
\item The matrix A (RCP or pointer) |
| 168 |
\item X and B (multi)vectors (optional if using \texttt{solve(X,B)} interface) |
| 169 |
\end{enumerate} |
| 170 |
\end{itemize} |
| 171 |
\end{frame} |
| 172 |
|
| 173 |
\begin{frame} |
| 174 |
\frametitle{Solver Interface and Creating a Solver} |
| 175 |
\framesubtitle{Summary of creation options} |
| 176 |
\begin{itemize} |
| 177 |
\item \texttt{create("SuperLU", A, X, B)} |
| 178 |
\item \texttt{create("SuperLU", A)} |
| 179 |
\item \texttt{create(A, X, B)} |
| 180 |
\item \texttt{create(A)} |
| 181 |
\end{itemize} |
| 182 |
\end{frame} |
| 183 |
|
| 184 |
\begin{frame}[fragile] |
| 185 |
\frametitle{Amesos2 Parameters vs Solver Parameters} |
| 186 |
\small |
| 187 |
\texttt{<ParameterList name="Amesos2">}\\ |
| 188 |
\texttt{~~<Parameter name="Tranpose" type="bool" value="true" />}\\ |
| 189 |
\uncover<2->{ |
| 190 |
\texttt{~~<ParameterList name="SuperLU\_MT">}\\ |
| 191 |
\texttt{~~~~<Parameter name="nprocs" type="int" value="8" />}\\ |
| 192 |
\texttt{~~</ParameterList>}\\ |
| 193 |
} |
| 194 |
\uncover<3->{ |
| 195 |
\texttt{~~<ParameterList name="SuperLU">}\\ |
| 196 |
\texttt{~~~~<Parameter name="DiagPivotThresh" type="double" value=".1" />}\\ |
| 197 |
\texttt{~~</ParameterList>}\\ |
| 198 |
} |
| 199 |
\texttt{</ParameterList>} |
| 200 |
\end{frame} |
| 201 |
|
| 202 |
\begin{frame} |
| 203 |
\frametitle{Solvers supported in Amesos2} |
| 204 |
These solvers will be supported by the Sept. release: |
| 205 |
\begin{itemize} |
| 206 |
\item KLU2 (in progress) |
| 207 |
\item SuperLU |
| 208 |
\item SuperLU\_MT |
| 209 |
\item SuperLU\_DIST (in progress) |
| 210 |
\end{itemize} |
| 211 |
We are also considering adding LAPACK (for almost dense matrices in CrsMatrix |
| 212 |
format) and Pardiso. |
| 213 |
\end{frame} |
| 214 |
|
| 215 |
\begin{frame} |
| 216 |
\frametitle{Support for New Solvers} |
| 217 |
\begin{itemize} |
| 218 |
\item Set up necessary internal data structures to interface with |
| 219 |
the TPL |
| 220 |
\item Implement |
| 221 |
\begin{itemize} |
| 222 |
\item \texttt{preOrdering\_impl()} |
| 223 |
\item \texttt{symbolicFactorization\_impl()} |
| 224 |
\item \texttt{numericFactorization\_impl()} |
| 225 |
\item \texttt{solve\_impl(X, B)} |
| 226 |
\item \texttt{matrixShapeOK\_impl()} |
| 227 |
\item \texttt{setParameters\_impl()} |
| 228 |
\item \texttt{getValidParameters\_impl()} |
| 229 |
\end{itemize} |
| 230 |
\item Do not need to worry about |
| 231 |
\begin{itemize} |
| 232 |
\item creating timers |
| 233 |
\item checking compatibility of $A$, $X$, and $B$ |
| 234 |
\item keeping track of solver status |
| 235 |
\end{itemize} |
| 236 |
\end{itemize} |
| 237 |
\end{frame} |
| 238 |
|
| 239 |
\begin{frame} |
| 240 |
\frametitle{Support for New Matrices and Multivectors} |
| 241 |
|
| 242 |
The amount of effort required depends on what object is being added. |
| 243 |
|
| 244 |
\begin{itemize} |
| 245 |
\item Extends \texttt{Epetra\_RowMatrix} or |
| 246 |
\texttt{Tpetra::RowMatrix}? Very little, only a method that |
| 247 |
imports the object into a new object with a given map. |
| 248 |
\item Otherwise, implement functions relating to |
| 249 |
\begin{itemize} |
| 250 |
\item getting a compressed row or column copy |
| 251 |
\item getting global/local matrix statistics |
| 252 |
\item getting row/col map |
| 253 |
\item import method |
| 254 |
\end{itemize} |
| 255 |
\item Multivectors require methods for |
| 256 |
\begin{itemize} |
| 257 |
\item getting global/local statistics |
| 258 |
\item getting the map |
| 259 |
\item getting a contiguous 1-D copy |
| 260 |
\item setting/globalizing a 1-D array |
| 261 |
\end{itemize} |
| 262 |
\end{itemize} |
| 263 |
\end{frame} |
| 264 |
|
| 265 |
\begin{frame}[fragile] |
| 266 |
\frametitle{Expert Usage} |
| 267 |
\framesubtitle{Releasing $A$ after numeric factorization} |
| 268 |
|
| 269 |
For preconditoners or smoothers when there is one often one numeric |
| 270 |
factorization and multiple solves. |
| 271 |
|
| 272 |
\begin{lstlisting} |
| 273 |
RCP<MAT> A; |
| 274 |
// Get A from somewhere |
| 275 |
RCP<Solver<MAT,MV> > solver = Amesos::create("SuperLU", A); |
| 276 |
solver->symbolicFactorization().numericFactorization(); |
| 277 |
A = Teuchos::null; // no longer need A |
| 278 |
solver.setA(Teuchos::null); // tell solver to release A |
| 279 |
RCP<MV> X; RCP<MV> B; |
| 280 |
// do some other work, finally get B's values |
| 281 |
solver->solve(X, B); // solution placed in X |
| 282 |
\end{lstlisting} |
| 283 |
\end{frame} |
| 284 |
|
| 285 |
\begin{frame}[fragile] |
| 286 |
\frametitle{Expert Usage} |
| 287 |
\framesubtitle{Reusing the solver for a different matrix} |
| 288 |
|
| 289 |
Amesos does not support this expert-only usecase, but Amesos2 does: |
| 290 |
Use the same solver instance for solving different linear systems. |
| 291 |
|
| 292 |
\begin{lstlisting} |
| 293 |
RCP<MAT> A1, A2; |
| 294 |
// initialize A1, A2, and B |
| 295 |
RCP<Solver<MAT,MV> > solver = Amesos::create(A1,X,B); |
| 296 |
solver->solve(); // solution in X |
| 297 |
solver->setA(A2); |
| 298 |
solver->solve(); // refactorizes A2 first |
| 299 |
\end{lstlisting} |
| 300 |
\end{frame} |
| 301 |
|
| 302 |
|
| 303 |
\begin{frame}[fragile,shrink] |
| 304 |
\frametitle{Internal Design: Solver Hierarchy} |
| 305 |
|
| 306 |
%% \begin{verbatim} |
| 307 |
%% +--------+ |
| 308 |
%% +------------+ MAT,MV | |
| 309 |
%% | <Interface> +-------+ |
| 310 |
%% | Solver | |
| 311 |
%% +-------------+ |
| 312 |
%% | <MAT,MV> |
| 313 |
%% | +-----------------------+ |
| 314 |
%% +------------+ ConcreteSolver,MAT,MV | |
| 315 |
%% | SolverCore +----------------------+ |
| 316 |
%% +-------------+ |
| 317 |
%% <Superlu,MAT,MV> | |
| 318 |
%% +--------------+-----+ <Klu2,MAT,MV> |
| 319 |
%% | | |
| 320 |
%% | +--------+ | +--------+ |
| 321 |
%% +---+----+ MAT,MV | +---+-+ MAT,MV | |
| 322 |
%% | SuperLU +-------+ | Klu2 +-------+ |
| 323 |
%% +---------+ +------+ |
| 324 |
%% \end{verbatim} |
| 325 |
|
| 326 |
\centering |
| 327 |
\begin{tikzpicture} |
| 328 |
\myclass[3.7cm]{(6,1.3)}{solvercore}{SolverCore}{CS,M,V}{}{symbolicFactorization()\\numericFactorization()\\solve()} |
| 329 |
\myclass[3.7cm]{($(solvercore) + (-6,0)$)}{solver}{\itshape $<<$Interface$>>$\\Solver}{M,V}{}{\itshape symbolicFactorization()\\numericFactorization()\\solve()} |
| 330 |
\myclass[3.1cm]{(4,-2)}{superlu}{Amesos::SuperLU}{M,V}{}{solve\_impl($X$,$B$)} |
| 331 |
\myclass[3cm]{(4,-4)}{tsuperlu}{TPL::SuperLU}{}{}{dgssvx(\ldots)\ldots} |
| 332 |
\myclass[3cm]{(8,-2)}{klu2}{Amesos::Klu2}{M,V}{}{solve\_impl($X$,$B$)} |
| 333 |
\myclass[3cm]{(8,-4)}{tklu2}{TPL::Klu2}{}{}{} |
| 334 |
|
| 335 |
\draw[implementation] (solvercore) -- node[above] {$<$M,V$>$} (solver); |
| 336 |
\draw[generalization] (superlu) -- node[left] {$<$Superlu,M,V$>$} (solvercore); |
| 337 |
\draw[generalization] (klu2) -- node[right] {$<$Klu2,M,V$>$} (solvercore); |
| 338 |
\draw[association] (tsuperlu) -- (superlu); |
| 339 |
\draw[association] (tklu2) -- (klu2); |
| 340 |
|
| 341 |
%\node[rectangle, red, fit=(solver) (tsuperlu) (superlu) (tmumps) (mumps)] {}; |
| 342 |
\end{tikzpicture} |
| 343 |
\end{frame} |
| 344 |
|
| 345 |
\begin{frame}[fragile,shrink,c] |
| 346 |
\frametitle{Internal Design: MatrixAdapter Hierarchy} |
| 347 |
%% \begin{verbatim} |
| 348 |
%% +---+ |
| 349 |
%% +--------------+ M | |
| 350 |
%% | MatrixAdapter +--+ |
| 351 |
%% +---------------+ |
| 352 |
%% | RCP<M> mat_ | +-------------------------+ |
| 353 |
%% +---------------+ | ... | |
| 354 |
%% | getCrs() ..........| getGlobalRowCopy(...) |... |
| 355 |
%% | getCcs() | | ... | . |
| 356 |
%% +---------------+ +-------------------------+ . |
| 357 |
%% <Derived> ^ . |
| 358 |
%% | +---------------+ . |
| 359 |
%% +------------------------------+ Abstr,Derived | . |
| 360 |
%% | AbstractConcreteMatrixAdapter +--------------+ . |
| 361 |
%% +-------------------------------+ . |
| 362 |
%% | getGlobalRowCopy_impl() | <............................. |
| 363 |
%% +-------------------------------+ calls |
| 364 |
%% <super_t,M> ^ |
| 365 |
%% | +---+ |
| 366 |
%% +----------------------+ M | |
| 367 |
%% | ConcreteMatrixAdapter +--+ |
| 368 |
%% +-----------------------+ |
| 369 |
%% \end{verbatim} |
| 370 |
\begin{centering} |
| 371 |
\begin{tikzpicture} |
| 372 |
\myclass[3.7cm]{(0,0)}{matrixadapter}{MatrixAdapter}{M}{RCP$<$M$>$ mat\_}{getCrs()\ldots} |
| 373 |
\path ($(matrixadapter) + (-3,-3.2)$) coordinate(ghost) ; |
| 374 |
\draw[generalization] (ghost) -- node[left,pos=.7]{$<$Derived$>$} (matrixadapter); |
| 375 |
\myclass[4cm]{(ghost)}{acmatadpte}{ACMatrixAdapter}{Epetra\_RM,Derived}{}{getGlobalRowCopy\_impl()} |
| 376 |
\myclass[4cm]{($(matrixadapter) + (3,-3.2)$)}{acmatadptt}{ACMatrixAdapter}{Tpetra::RM,Derived}{}{getGlobalRowCopy\_impl()} |
| 377 |
|
| 378 |
\myclass[4cm]{($(acmatadptt) + (0,-3)$)}{cmatadpttcrs}{CMatrixAdapter}{Tpetra::CrsMat}{}{} |
| 379 |
\myclass[4cm]{($(acmatadpte) + (0,-3)$)}{cmatadptecrs}{CMatrixAdapter}{Epetra\_CrsMat}{}{} |
| 380 |
|
| 381 |
\draw[generalization] (acmatadptt) -- node[right]{$<$Derived$>$} (matrixadapter); |
| 382 |
\draw[generalization] (cmatadpttcrs) -- node{$<$Tpetra::RM,Tpetra::CrsMat$>$} (acmatadptt); |
| 383 |
\draw[generalization] (cmatadptecrs) -- node{$<$Epetra\_RM,Epetra\_CrsMat$>$} (acmatadpte); |
| 384 |
|
| 385 |
\node[draw,densely dashed,rectangle,anchor=west] (method) at ($(matrixadapter.third east) + (0.5,0)$) {getGlobalRowCopy(\ldots);} ; |
| 386 |
|
| 387 |
\draw[dotted,o-] ($(matrixadapter.third east) - (.4,0)$) -- (method); |
| 388 |
|
| 389 |
\draw[->] (method.east) -- +(0.5,0) |- (cmatadpttcrs); |
| 390 |
\end{tikzpicture} |
| 391 |
\end{centering} |
| 392 |
\end{frame} |
| 393 |
|
| 394 |
\begin{frame} |
| 395 |
\frametitle{Future Work} |
| 396 |
\begin{itemize} |
| 397 |
\item Need better support for pre-ordering: Zoltan2 will provide |
| 398 |
both graph partitoning based and minimum degree based orderings. |
| 399 |
\item Currently we use SuperLU's internal orderings. KLU2 uses the |
| 400 |
orderings from Amesos. |
| 401 |
\item Need to support more solvers and matrix types. |
| 402 |
\end{itemize} |
| 403 |
\end{frame} |
| 404 |
|
| 405 |
\end{document} |