<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
I have no objections to a single mat type and would be happy to refactor it that way. But before I do that, I think some discussion on the subject is useful.
<div class=""><br class="">
</div>
<div class="">AIJ matrices in PETSc are structured similarly to the LMVM matrices. They have a base type, MATAIJ. They have major subtypes like MATSEQAIJ and MATMPIAIJ. And then they have a third layer, minor subtypes, like MATSEQAIJMKL. Furthermore, the minor
 subtypes also have their own special constructors like MatCreateSeqAIJMKL. Most importantly though, there is no such thing as a MatAIJType or MatSeqAIJType. All of the subtypes, on both second and third layers, are directly defined as MatType. LMVM is doing
 the same thing. In fact it’s explicitly modeled after the AIJ code structure. It is indeed missing the *additional* ability to get and set subtypes, but that’s not a replacement to the existing code. It’s an additional functionality. In that sense, creating
 a MatLMVMType and preventing subtypes from being created directly in the top level Mat interface would go against what has been previously done for other Mat types in PETSc.</div>
<div class=""><br class="">
</div>
<div class="">Jed is right, by the way, about packing optimization specific things here. However, the modularity benefits are significant. Furthermore, good and bad Broyden methods are actually used almost exclusively for general nonlinear system solutions
 instead of optimization, because they cannot produce symmetric approximations necessary for Hessians. Implementing these things as Mat objects enables both SNES and TAO to make use of them (although currently only TAO uses them). They are not true matrices.
 They encode nonlinear algorithm information in matrix-like formats. That’s unusual, I agree, but hardcoding them to the algorithms themselves results in massive amounts of duplicate code whenever anyone wants to use these types of things in other places besides
 the specific algorithm they’ve been written into.</div>
<div class=""><br class="">
</div>
<div class="">The two basic Broyden methods can indeed bet combined into one object easily, but that’s not as true for other subtypes. Mathematical formulations differ significantly between BFGS, DFP, symmetric Broyden and SR1 methods. They can be combined
 on paper, because they’re all symmetric Broyden-class of updates. However, doing so causes BFGS, DFP and SR1 to have inflated memory footprints and additional algebra operations that they don’t actually need. Eliminating those in a single object requires either
 a lot of ugly conditionals/switches, or playing with function pointers. Doing the latter basically gets us 99% of the way to separating them into different objects though, which is what the current implementation does.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
——<br class="">
<b class="">Alp Dener</b></div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
Argonne National Laboratory</div>
<div style="text-align: start; text-indent: 0px;"><a href="http://www.mcs.anl.gov/person/alp-dener" class="">http://www.mcs.anl.gov/person/alp-dener</a></div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<br class="">
</div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
</div>
</div>
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Sep 11, 2018, at 10:33 AM, Munson, Todd <<a href="mailto:tmunson@mcs.anl.gov" class="">tmunson@mcs.anl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class=""><br class="">
I would be happy with one matrix type and removing the convenience functions<br class="">
from the code.  I am surprised that the dark lord did not mention it when<br class="">
he approved the pull request...<br class="">
<br class="">
Matt: the difference in the subtypes is that they are using different formulas <br class="">
that result in different approximations.  BFGS is for symmetric problems and <br class="">
is a rank-2 update that maintains positive definiteness, SR1 is for <br class="">
symmetric problems and is a rank-1 update that can be indefinite.<br class="">
<br class="">
The nonsymmetric equivalents (BadBroyden and GoodBroyden) are also different <br class="">
and bad Broyden is typically better than good Broyden.<br class="">
<br class="">
Performance on a particular problem varies greatly depending on both the<br class="">
specific problem and the approximation type selected.<br class="">
<br class="">
Recall to get performance, you can either make the computational kernels<br class="">
run faster, change the algorithm, or both.  Changing the matrix <br class="">
approximations changes the algorithm.<br class="">
<br class="">
Todd.<br class="">
<br class="">
<blockquote type="cite" class="">On Sep 11, 2018, at 10:12 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:<br class="">
<br class="">
On Tue, Sep 11, 2018 at 9:47 AM Dener, Alp <<a href="mailto:adener@anl.gov" class="">adener@anl.gov</a>> wrote:<br class="">
1 base type and 8 subtypes. If there’s a better convention/structure to do this in PETSc, I’d be happy to get a refactoring done ASAP this week so that it’s cleaner in the release.<br class="">
<br class="">
I guess what Lisandro is asking is, what backend differences are there to make so many type necessary.<br class="">
<br class="">
Looking at the few I recognize, it seems like they encode the sum of rank 1 matrices (BFGS, SR1). Why<br class="">
would we have separate types for this two things?<br class="">
<br class="">
 Thanks,<br class="">
<br class="">
    Matt<br class="">
<br class="">
—<br class="">
Alp Dener<br class="">
Argonne National Laboratory<br class="">
<a href="https://mcs.anl.gov/person/alp-Dener" class="">https://mcs.anl.gov/person/alp-Dener</a><br class="">
<br class="">
On Sep 11, 2018, at 5:10 AM, Lisandro Dalcin <dalcinl@gmail.com> wrote:<br class="">
<br class="">
<blockquote type="cite" class="">So now we have 9 new, top-level, public matrix types for LMVM... Really?<br class="">
<br class="">
#define MATLMVM            "lmvm"<br class="">
#define MATLMVMDFP         "lmvmdfp"<br class="">
#define MATLMVMBFGS        "lmvmbfgs"<br class="">
#define MATLMVMSR1         "lmvmsr1"<br class="">
#define MATLMVMBRDN        "lmvmbrdn"<br class="">
#define MATLMVMBADBRDN     "lmvmbadbrdn"<br class="">
#define MATLMVMSYMBRDN     "lmvmsymbrdn"<br class="">
#define MATLMVMSYMBADBRDN  "lmvmsymbadbrdn"<br class="">
#define MATLMVMDIAGBRDN    "lmvmdiagbrdn"<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
-- <br class="">
Lisandro Dalcin<br class="">
============<br class="">
Research Scientist<br class="">
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)<br class="">
Extreme Computing Research Center (ECRC)<br class="">
King Abdullah University of Science and Technology (KAUST)<br class="">
http://ecrc.kaust.edu.sa/<br class="">
<br class="">
4700 King Abdullah University of Science and Technology<br class="">
al-Khawarizmi Bldg (Bldg 1), Office # 0109<br class="">
Thuwal 23955-6900, Kingdom of Saudi Arabia<br class="">
http://www.kaust.edu.sa<br class="">
<br class="">
Office Phone: +966 12 808-0459<br class="">
</blockquote>
<br class="">
<br class="">
-- <br class="">
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">
-- Norbert Wiener<br class="">
<br class="">
https://www.cse.buffalo.edu/~knepley/<br class="">
</blockquote>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>