<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><blockquote type="cite" 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=""><br class=""><pre lang="c" class=""><span lang="c" class=""><span class=""><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class="">MatProductCreateWithMat</span><span style="margin: 0px;" class="">(</span><span style="margin: 0px;" class="">A</span><span style="margin: 0px;" class="">,</span><span style="margin: 0px;" class="">Vmat</span><span style="margin: 0px;" class="">,</span><span style="margin: 0px;" class="">NULL</span><span style="margin: 0px;" class="">,</span><span style="margin: 0px;" class="">Wmat</span><span style="margin: 0px;" class="">);</span></span>
<span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class="">MatProductSetType</span><span style="margin: 0px;" class="">(</span><span style="margin: 0px;" class="">Wmat</span><span style="margin: 0px;" class="">,</span><span style="margin: 0px;" class="">MATPRODUCT_AB</span><span style="margin: 0px;" class="">);</span></span></pre><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class=""><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class="">MatHasOperation</span><span style="margin: 0px;" class="">(</span></span>Wmat,MATOP_MATPRODUCT,&flg); //new support, it calls MatProductSetFromOptions(Wmat)</pre></span></span></pre></span></span></pre></div></blockquote><div><br class=""></div>Hong, this would go in the direction I was outlining here <a href="https://gitlab.com/petsc/petsc/-/issues/608" class="">https://gitlab.com/petsc/petsc/-/issues/608</a></div><div>How about also adding something like</div><div><br class=""></div><div>MatProductIsImplemented(Wmat,&flg)</div><div><br class=""></div><div>That returns true if a specific implementation is available? This way</div><div><br class=""></div><div>This way, if we use both queries, we can assess the presence of the basic fallbacks too, i.e.</div><div> </div><div>MatHasOperation(Wmat,MATOP_MATPRODUCT,&flg1)</div><div><div>MatProductIsImplemented(Wmat,&flg2)</div><div><br class=""></div><div>If flg1 is false, no support at all</div><div>If flg1 is true and flg2 is false -> Basic implementation (i.e, MatShell with products inside)</div><div>If flg1 and flg2 are both true -> Specific implementation available.</div><div class=""><br class=""></div></div><div><blockquote type="cite" 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=""><pre lang="c" class=""><span lang="c" class=""><span class=""><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class=""><pre lang="c" style="background-color: rgb(255, 255, 255);" class="">if (V->vmm && flg) {</pre><pre lang="c" style="background-color: rgb(255, 255, 255);" class="">  MatProductSymbolic(Wmat);</pre><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class="">  MatProductNumeric</span><span style="margin: 0px;" class="">(</span><span style="margin: 0px;" class="">Wmat</span><span style="margin: 0px;" class="">);</span></span></pre><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class="">} else {</span></span></pre><pre lang="c" style="background-color: rgb(255, 255, 255);" class=""><span lang="c" style="margin: 0px;" class=""><span style="margin: 0px;" class="">  MatDestroy(</span></span>Wmat);</pre>  ...</pre><pre lang="c" style="background-color: rgb(255, 255, 255);" class="">}</pre>Hong</span></span></pre><br class=""></span></span></pre><br class=""></div><div id="appendonsend" 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=""></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: 1094.65625px;" 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>Jose E. Roman <<a href="mailto:jroman@dsic.upv.es" class="">jroman@dsic.upv.es</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Tuesday, April 21, 2020 11:21 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span>Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" class="">hzhang@mcs.anl.gov</a>>; 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="BodyFragment" 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;"><font size="2" class=""><span style="font-size: 11pt;" class=""><div class="PlainText"><br class=""><br class="">> El 21 abr 2020, a las 17:53, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>> escribió:<br class="">><span class="Apple-converted-space"> </span><br class="">><span class="Apple-converted-space"> </span><br class="">><span class="Apple-converted-space"> </span><br 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:<br class="">>><span class="Apple-converted-space"> </span><br class="">>> Pierre,<br class="">>> MatMatMult_xxx() is removed from MatOps table.<br class="">><span class="Apple-converted-space"> </span><br class="">> Shouldn’t there be a deprecation notice somewhere?<br class="">> There is nothing about MATOP_MAT_MULT in the 3.13 changelog<span class="Apple-converted-space"> </span><a href="https://www.mcs.anl.gov/petsc/documentation/changes/313.html" class="">https://www.mcs.anl.gov/petsc/documentation/changes/313.html</a><br 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><br class="">> (Maybe José is aware of this and this is just for testing)<br class=""><br class="">No, I was not aware of this. Thanks for bringing this up. Now in 3.13 we are always doing the slow version (column by column), so yes I am interested in a solution for this.<br class=""><br class="">><span class="Apple-converted-space"> </span><br class="">>> MatMatMult() is replaced by<br class="">>> MatProductCreate()<br class="">>> MatProductSetType(,MATPRODUCT_AB)<br class="">>> MatProductSetFromOptions()<br class="">>> MatProductSymbolic()<br class="">>> MatProductNumeric()<br class="">>><span class="Apple-converted-space"> </span><br class="">>> Where/when do you need query a single matrix for its product operation?<br class="">><span class="Apple-converted-space"> </span><br 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.<br 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?<br 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.<br class="">><span class="Apple-converted-space"> </span><br class="">> Thanks,<br class="">> Pierre<br class="">><span class="Apple-converted-space"> </span><br class="">>> Hong<br class="">>><span class="Apple-converted-space"> </span><br class="">>> From: 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="">>> Sent: Tuesday, April 21, 2020 7:50 AM<br class="">>> To: petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>><br class="">>> Subject: [petsc-dev] MATOP_MAT_MULT<br class="">>> <span class="Apple-converted-space"> </span><br class="">>> Hello,<br class="">>> Am I seeing this correctly?<br class="">>> #include <petsc.h><br class="">>><span class="Apple-converted-space"> </span><br class="">>> int main(int argc,char **args)<br class="">>> {<br class="">>>   Mat               A;<br class="">>>   PetscBool         hasMatMult;<br class="">>>   PetscErrorCode    ierr;<br class="">>><span class="Apple-converted-space"> </span><br class="">>>   ierr = PetscInitialize(&argc,&args,NULL,NULL);if (ierr) return ierr;<br class="">>>   ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);<br class="">>>   ierr = MatSetType(A,MATMPIAIJ);CHKERRQ(ierr);<br class="">>>   ierr = MatHasOperation(A,MATOP_MAT_MULT,&hasMatMult);CHKERRQ(ierr);<br class="">>>   printf("%s\n", PetscBools[hasMatMult]);<br class="">>>   ierr = PetscFinalize();<br class="">>>   return ierr;<br class="">>> }<br class="">>><span class="Apple-converted-space"> </span><br class="">>> => FALSE<br class="">>><span class="Apple-converted-space"> </span><br class="">>> I believe this is a regression (or at least an undocumented change) introduced here:<span class="Apple-converted-space"> </span><a href="https://gitlab.com/petsc/petsc/-/merge_requests/2524/" class="">https://gitlab.com/petsc/petsc/-/merge_requests/2524/</a><br class="">>> I also believe Stefano raised a similar point there:<span class="Apple-converted-space"> </span><a href="https://gitlab.com/petsc/petsc/-/issues/608" class="">https://gitlab.com/petsc/petsc/-/issues/608</a><br 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.<br class="">>> There is also a bunch of (previously functioning but now) broken code, e.g.,<span class="Apple-converted-space"> </span><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><span class="Apple-converted-space"> </span>or<span class="Apple-converted-space"> </span><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><br class="">>> Is this being addressed/documented?<br class="">>><span class="Apple-converted-space"> </span><br class="">>> Thanks,<br class="">>> Pierre<br class="">><span class="Apple-converted-space"> </span></div></span></font></div></blockquote></div><br class=""></body></html>