<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=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 22 Apr 2020, at 12:05 AM, Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" class="">hzhang@mcs.anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><span style="font-family: Calibri, sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;" class="">Pierre,</span><br class=""></div><div style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><span style="font-family: Calibri, sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;" class="">The old API, MatMatMult(), MatPtAP() ... are still available as wrappers to the new API:</span></div><div style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><blockquote type="cite" style="color: rgb(50, 49, 48); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif; background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px;" class=""><div style="margin: 0px; font-weight: normal; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class="">MatProductCreate()</span></div><div style="margin: 0px; font-weight: normal; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class="">MatProductSetType(,MATPRODUCT_AB/PtAP)</span><br class=""></span></div><div style="margin: 0px; font-weight: normal; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class="">MatProductSetFromOptions()</span><br class=""></span></span></div><div style="margin: 0px; font-weight: normal; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class="">MatProductSymbolic()</span><br class=""></span></span></span></div><div style="margin: 0px; font-weight: normal; font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class=""><span style="margin: 0px; background-color: rgb(255, 255, 255); display: inline !important;" class="">MatProductNumeric()</span></span></span></span></span></div></div></blockquote>You do not need to change your code.</div></div></blockquote><div><br class=""></div><div>Yes, of course. My concern is not the MatMatMult operation itself, it’s how to know if a MatMatMult implementation is available for a given stencil (A, B).</div><br class=""><blockquote type="cite" class=""><div class=""><div style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">When you call MatMatMult() with seqsbaij and dense matrices, a detailed error message will be out from MatProductSetFromOptions() (or MatMatMult() if you use the wrapper).</div></div></blockquote><div><br class=""></div><div>Well, that’s just not an option. I don’t want the code to error, I want a fallback mechanism so that I can do the MatMatMult myself, column by column (or implement this as part of issue #608 in the case of dense B and C so neither José nor me have to bother about this again).</div><div>That makes MatMatMult very hard to use now, because you can’t tell a priori if your code will run or not if the types of your A and B are variable (because of an unimplemented MatMatMult).</div><br class=""><blockquote type="cite" class=""><div class=""><div style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">I'll discuss Jose's usage in next email.</div></div></blockquote><div><br class=""></div><div>What you propose there looks good to me.</div><div>(Though I’d like to be able to skip MatProductSymbolic() in the case of a dense Wmat allocated in user code, but this is very minor)</div><div><br class=""></div><div>Thanks,</div><div>Pierre</div><br class=""><blockquote type="cite" class=""><div class=""><div style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Hong</div><hr tabindex="-1" style="caret-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; text-decoration: none; display: inline-block; width: 599.75px;" class=""><span style="caret-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; text-decoration: none; float: none; display: inline !important;" class=""></span><div id="divRplyFwdMsg" dir="ltr" style="caret-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; text-decoration: none;" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span><span style="font-family: Calibri, sans-serif; background-color: rgb(255, 255, 255); display: inline !important;" class="">Pierre</span><span class="Apple-converted-space"> </span>Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Tuesday, April 21, 2020 10:53 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" class="">hzhang@mcs.anl.gov</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span>petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [petsc-dev] MATOP_MAT_MULT</font><div class=""> </div></div><div class="" style="caret-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; text-decoration: none; word-wrap: break-word; line-break: after-white-space;"><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 21 Apr 2020, at 5:22 PM, Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" class="">hzhang@mcs.anl.gov</a>> wrote:</div><br class="x_Apple-interchange-newline"><div class=""><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;">Pierre,</span><br class=""></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;">MatMatMult_xxx() is removed from MatOps table.</span></div></div></blockquote><div class=""><br class=""></div><div class="">Shouldn’t there be a deprecation notice somewhere?</div><div class="">There is nothing about MATOP_MAT_MULT in the 3.13 changelog <a href="https://www.mcs.anl.gov/petsc/documentation/changes/313.html" class="">https://www.mcs.anl.gov/petsc/documentation/changes/313.html</a></div><div class="">For example, I see that in SLEPc, José is currently making these checks, which are in practice useless as they always return PETSC_FALSE? <a href="https://gitlab.com/slepc/slepc/-/blob/master/src/sys/classes/bv/impls/contiguous/contig.c#L191" class="">https://gitlab.com/slepc/slepc/-/blob/master/src/sys/classes/bv/impls/contiguous/contig.c#L191</a></div><div class="">(Maybe José is aware of this and this is just for testing)</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;">MatMatMult() is replaced by</span></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;">MatProductCreate()</span></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;">MatProductSetType(,MATPRODUCT_AB)</span><br class=""></span></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;">MatProductSetFromOptions()</span><br class=""></span></span></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;">MatProductSymbolic()</span><br class=""></span></span></span></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;"><span class="" style="background-color: rgb(255, 255, 255); display: inline !important;">MatProductNumeric()</span><br class=""></span></span></span></span></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><br class=""></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;">Where/when do you need query a single matrix for its product operation?</span></div></div></blockquote><div class=""><br class=""></div><div class="">I didn’t want to bother at first with the new API, because I’m only interested in C = A*B with C and B being dense.</div><div class="">Of course, I can update my code, but if I understand Stefano’s issue correctly, and let’s say my A is of type SBAIJ, for which there is no MatMatMult, the code will now error out in the MatProduct?</div><div class="">There is no fallback mechanism? Meaning I could in fact _not_ use the new API and will just have to loop on all columns of B, even for AIJ matrices.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pierre</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><span class="" style="color: rgb(50, 49, 48); background-color: rgb(255, 255, 255); display: inline !important;">Hong</span></div><div id="x_appendonsend" class="" style="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; text-decoration: none;"></div><div class="" style="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; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;"><br class=""></div><hr tabindex="-1" class="" style="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; text-decoration: none; display: inline-block; width: 599.75px;"><span class="Apple-converted-space"> </span><span class="" style="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; text-decoration: none; float: none; display: inline !important;"></span><span class="Apple-converted-space"> </span><div id="x_divRplyFwdMsg" dir="ltr" class="" style="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; text-decoration: none;"><font face="Calibri, sans-serif" class="" style="font-size: 11pt;"><b class="">From:</b><span class="x_Apple-converted-space"> </span>petsc-dev <<a href="mailto:petsc-dev-bounces@mcs.anl.gov" class="">petsc-dev-bounces@mcs.anl.gov</a>> on behalf of Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>><br class=""><b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, April 21, 2020 7:50 AM<br class=""><b class="">To:</b><span class="x_Apple-converted-space"> </span>petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>><br class=""><b class="">Subject:</b><span class="x_Apple-converted-space"> </span>[petsc-dev] MATOP_MAT_MULT</font><div class=""> </div></div><div class="" style="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; text-decoration: none; word-wrap: break-word; line-break: after-white-space;">Hello,<div class="">Am I seeing this correctly?</div><div class=""><div class="">#include <petsc.h></div><div class=""><br class=""></div><div class="">int main(int argc,char **args)</div><div class="">{</div><div class=""> Mat A;</div><div class=""> PetscBool hasMatMult;</div><div class=""> PetscErrorCode ierr;</div><div class=""><br class=""></div><div class=""> ierr = PetscInitialize(&argc,&args,NULL,NULL);if (ierr) return ierr;</div><div class=""> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);</div><div class=""> ierr = MatSetType(A,MATMPIAIJ);CHKERRQ(ierr);</div><div class=""> ierr = MatHasOperation(A,MATOP_MAT_MULT,&hasMatMult);CHKERRQ(ierr);</div><div class=""> printf("%s\n", PetscBools[hasMatMult]);</div><div class=""> ierr = PetscFinalize();</div><div class=""> return ierr;</div><div class="">}</div></div><div class=""><br class=""></div><div class="">=> FALSE</div><div class=""><br class=""></div><div class="">I believe this is a regression (or at least an undocumented change) introduced here: <a href="https://gitlab.com/petsc/petsc/-/merge_requests/2524/" class="">https://gitlab.com/petsc/petsc/-/merge_requests/2524/</a></div><div class="">I also believe Stefano raised a similar point there: <a href="https://gitlab.com/petsc/petsc/-/issues/608" class="">https://gitlab.com/petsc/petsc/-/issues/608</a></div><div class="">This is a performance killer in my case because I was previously using this check to know whether I could use MatMatMult or had to loop on all columns and call MatMult on all of them.</div><div class="">There is also a bunch of (previously functioning but now) broken code, e.g., <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/transpose/transm.c.html#line105" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/transpose/transm.c.html#line105</a> or <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/nest/matnest.c.html#line2105" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/nest/matnest.c.html#line2105</a></div><div class="">Is this being addressed/documented?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pierre</div></div></div></blockquote></div></div></div></blockquote></div><br class=""></body></html>