<div dir="ltr"><div>Il giorno mer 6 mag 2020 alle ore 17:50 Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov">hzhang@mcs.anl.gov</a>> ha scritto:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Stefano,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
How about you work on this issue? </div></div></blockquote><div><br></div><div>here you have <a href="https://gitlab.com/petsc/petsc/-/commit/1c88b2e1d7c133c480fe45577b7a34a84969dc11">https://gitlab.com/petsc/petsc/-/commit/1c88b2e1d7c133c480fe45577b7a34a84969dc11</a></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7763001458059488600divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>><br>
<b>Sent:</b> Wednesday, May 6, 2020 2:09 AM<br>
<b>To:</b> Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>><br>
<b>Cc:</b> Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>>; Jose E. Roman <<a href="mailto:jroman@dsic.upv.es" target="_blank">jroman@dsic.upv.es</a>>; petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>>; Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-dev] MATOP_MAT_MULT</font>
<div> </div>
</div>
<div style="overflow-wrap: break-word;">Hong
<div><br>
</div>
<div>If the product is not supported, the type of C will never be set anyway, so you cannot call MatHasOperation after MatProductSetFromOptions.</div>
<div>The purpose of MatProductSetFromOptions is to populate the function pointers for symbolic and numeric phases. If not found, they should be set to null instead of erroring as it is now.</div>
<div>What I propose is to have MatProductHasOperation (not MatHasOperation): this function will be identical to MatHasOperation, with the only difference that does not call PetscValidType on the input mat.</div>
<div><br>
</div>
<div>Meanwhile, I’m coding a basic MatMat (and MatTransposeMat) driver to loop over dense columns and apply MatMult. (Or MatMultTranspose) without memory movement.</div>
<div>This will be valid for all B matrices being of type dense (and its derivations), with C of type dense too. This in principle will fix Jose and Pierre’s issues (they can correct me if I’m wrong)</div>
<div><br>
</div>
<div>However, we should definitely have a way for the user to enquire if a given operation is supported or not. </div>
<div><br>
</div>
<div>Thanks</div>
<div>Stefano</div>
<div>
<div><br>
<blockquote type="cite">
<div>On May 6, 2020, at 12:03 AM, Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:</div>
<br>
<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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">Stefano:</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">Now, we need address this bug report: enable MatHasOperation(C,MATOP_MAT_MULT,&flg) for matrix products, e.g., C=A*B, which is related to your issue <a href="https://gitlab.com/petsc/petsc/-/issues/608" title="https://gitlab.com/petsc/petsc/-/issues/608" target="_blank">https://gitlab.com/petsc/petsc/-/issues/608</a>.</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><br>
</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">In petsc-3.13:</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">1) <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MATOP_MAT_MULT, ..., <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MATOP_MATMAT_MULT
are removed from the MATOP table (they are still listed in petscmat.h -- an overlook, I'll remove them). </span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MATOP_MAT_MULT_SYMBOLIC/NUMERIC
... are still in the table.</span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">2) <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatHasOperation(C,...)
must be called for the matrix product C, not matrix A or B (slepc needs to fix this after this reported bug is fixed).</span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Like
MatSetOption(), MatHasOperation() must be called AFTER MatSetType(). You moved MatSetType() from MatProductSetFromOptions() back to <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatProductSymbolic()
in your latest patch, thus user has to call <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatHasOption()<span> after <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatProductSymbolic():</span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductCreate(A,B,NULL,&C);</span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSetType(C,...);</span><br>
</span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">...</span></span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSetFromOptions();
//if the product is not supported for the given mat types, currently petsc crashes here, which we can replace with an error output</span><br>
</span></span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSymbloc();
-> call MatSetType()</span><br>
</span></span></span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatHasOperation(C,<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MATOP_MAT_MULT,&flg)</span></span><br>
</span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Question:
how to call <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatHasOperation(C,..) when <span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSymbloc()
is not supported?</span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">My
fix to this bug:</span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Resume
MatSetType() in <span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSetFromOptions().
Then user calls:</span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">
<div style="margin:0px;font-size:12pt;font-family:Calibri,Arial,Helvetica,sans-serif">
<span style="margin:0px"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px"><span style="margin:0px;background-color:rgb(255,255,255);display:inline">Mat<span style="margin:0px;background-color:rgb(255,255,255);display:inline">ProductCreate(A,B,NULL,&C);</span></span></span></span></span></span></span></span></span></div>
<div style="margin:0px;font-size:12pt;font-family:Calibri,Arial,Helvetica,sans-serif">
<span style="margin:0px"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;background-color:rgb(255,255,255);display:inline">ProductSetType(C,...);</span></span></span></span></span></span></span></span></span></span></div>
</span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">...</span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSetFromOptions(C); <span> //if <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">the
product is not supported for the given mat types,<span> C->ops->productsymbolic=NULL;</span></span></span></span><br>
</span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatHasOperation(C,</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MATOP_PRODUCT<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">SYMBOLIC</span>,&flg);</span><br>
</span></span></span></span></span></span></span></span></span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
if (flg) { </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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Mat</span><span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">ProductSymbolic(C);</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"> ...</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">} else {</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"> MatDestroy(&C);</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"> ...</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="margin:0px;font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">}</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><br>
</span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Either
you take care of this bug report, or let me know your thoughts about how to fix this bug.</span></span></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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">Hong</span></span></span></div>
<div id="gmail-m_-7763001458059488600x_appendonsend" 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>
<hr 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:735.969px">
<span 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"></span>
<div id="gmail-m_-7763001458059488600x_divRplyFwdMsg" dir="ltr" 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" style="font-size:11pt"><b>From:</b><span> </span>Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>><br>
<b>Sent:</b><span> </span>Saturday, April 25, 2020 2:40 PM<br>
<b>To:</b><span> </span>Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>><br>
<b>Cc:</b><span> </span>Jose E. Roman <<a href="mailto:jroman@dsic.upv.es" target="_blank">jroman@dsic.upv.es</a>>; Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>>; petsc-dev
<<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>>; Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>><br>
<b>Subject:</b><span> </span>Re: [petsc-dev] MATOP_MAT_MULT</font>
<div> </div>
</div>
<div dir="ltr" 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 style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="color:rgb(50,49,48);background-color:rgb(255,255,255);display:inline">Pierre,</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="color:rgb(50,49,48);background-color:rgb(255,255,255);display:inline">When we do </span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="color:rgb(50,49,48);background-color:rgb(255,255,255);display:inline">MatProductCreate: C = A*B; //C owns A and B, thus B-><span style="background-color:rgb(255,255,255);display:inline">refct =2</span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="color:rgb(50,49,48);background-color:rgb(255,255,255);display:inline">MatProductCreateWithMats: B = A*C; //If I let B own A and C, then C->refct=2</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
Then</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
MatDestroy(&B) and <span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">MatDestroy(&C) only reduce their refct from 2 to 1, thus memory leak. </span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">My solution is adding </span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">{</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline"> matreference; /* do not add refct when using MatProductCreateWithMat() to void recursive references */<br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">} Mat_Product </span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif;background-color:rgb(255,255,255);display:inline">This flg prevents <span style="color:rgb(50,49,48);background-color:rgb(255,255,255);display:inline">MatProductCreateWithMats()
to increase reference counts, i.e., B does not own A and C to avoid reverse ownership. </span></span><span style="color:rgb(50,49,48)">I am not sure this is a reasonable solution. Let me know if you have better solution.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="color:rgb(50,49,48)">See ex109.c and ex195.c for tests.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="color:rgb(50,49,48)">Hong</span></div>
<hr style="display:inline-block;width:735.969px">
<div id="gmail-m_-7763001458059488600x_x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span> </span>Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>><br>
<b>Sent:</b><span> </span>Saturday, April 25, 2020 11:45 AM<br>
<b>To:</b><span> </span>Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>><br>
<b>Cc:</b><span> </span>Jose E. Roman <<a href="mailto:jroman@dsic.upv.es" target="_blank">jroman@dsic.upv.es</a>>; Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>>; petsc-dev
<<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>>; Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>><br>
<b>Subject:</b><span> </span>Re: [petsc-dev] MATOP_MAT_MULT</font>
<div> </div>
</div>
<div style="overflow-wrap: break-word;">Hong,
<div>José didn’t report this, though he may have run into the same issue, I did.</div>
<div>I’ll try the branch and get back at you on GitLab MR.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Pierre<br>
<div><br>
<blockquote type="cite">
<div>On 25 Apr 2020, at 6:17 PM, Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:</div>
<br>
<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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
Jose,</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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div 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 size="2"><span style="font-size:11pt">
<div>>> I also now just tested some previously PETSC_VERSION_LT(3,13,0) running code with C=A*B, Dense=Nest*Dense, all previously allocated prior to a call to MatMatMult and scall = MAT_REUSE_MATRIX.<br>
>> Sadly, it’s now broken. It is my fault for not having a test for this in<span> </span><a href="https://gitlab.com/petsc/petsc/-/merge_requests/2069" target="_blank">https://gitlab.com/petsc/petsc/-/merge_requests/2069</a>, sorry
about that.<br>
>> [0]PETSC ERROR: Call MatProductSymbolic() first<br>
>> [0]PETSC ERROR: #1 MatProductNumeric() line 730 in /ccc/work/cont003/rndm/rndm/petsc/src/mat/interface/matproduct.c<br>
>> [0]PETSC ERROR: #2 MatMatMult() line 9335 in /ccc/work/cont003/rndm/rndm/petsc/src/mat/interface/matrix.c<br>
>><span> </span><br>
>> Here is a reproducer (that will work OK with 3.12.4).<br>
>> diff --git a/src/mat/tests/ex195.c b/src/mat/tests/ex195.c<br>
>> index c72662bc3c..811de669c5 100644<br>
>> --- a/src/mat/tests/ex195.c<br>
>> +++ b/src/mat/tests/ex195.c<br>
>> @@ -73,2 +73,3 @@ int main(int argc,char **args)<br>
>> ierr = MatMatMult(nest,B,MAT_REUSE_MATRIX,PETSC_DEFAULT,&C);CHKERRQ(ierr);<br>
>> + ierr = MatMatMult(nest,C,MAT_REUSE_MATRIX,PETSC_DEFAULT,&B);CHKERRQ(ierr);<br>
>> ierr = MatMatMultEqual(nest,B,C,10,&equal);CHKERRQ(ierr);<br>
>><span> </span><br>
>> $ make -f gmakefile test searchin=mat_tests-ex195<br>
>><span> </span><br>
>> I believe this is very close to the topic at hand and issue #608, so maybe you could fix this as well in the same upcoming MR? Just let me know, I can have a crack it otherwise.</div>
<div><br>
</div>
<div>This is a bug. I fixed it in the branch hzhang/fix-matproduct-reuse/maint. Can you test it?</div>
<div>Hong</div>
</span></font></div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Stefano</div></div>