<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jose,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'll check and fix them. I have to do it in master, is ok?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hong</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Pierre Jolivet <pierre.jolivet@enseeiht.fr><br>
<b>Sent:</b> Wednesday, April 22, 2020 3:08 PM<br>
<b>To:</b> Zhang, Hong <hzhang@mcs.anl.gov><br>
<b>Cc:</b> Jose E. Roman <jroman@dsic.upv.es>; Stefano Zampini <stefano.zampini@gmail.com>; petsc-dev <petsc-dev@mcs.anl.gov>; Smith, Barry F. <bsmith@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-dev] MATOP_MAT_MULT</font>
<div> </div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">Hong,
<div class="">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.</div>
<div class="">Sadly, it’s now broken. It is my fault for not having a test for this in <a href="https://gitlab.com/petsc/petsc/-/merge_requests/2069" class="">https://gitlab.com/petsc/petsc/-/merge_requests/2069</a>, sorry about that.</div>
<div class="">[0]PETSC ERROR: Call MatProductSymbolic() first</div>
<div class="">
<div class="">[0]PETSC ERROR: #1 MatProductNumeric() line 730 in /ccc/work/cont003/rndm/rndm/petsc/src/mat/interface/matproduct.c</div>
<div class="">[0]PETSC ERROR: #2 MatMatMult() line 9335 in /ccc/work/cont003/rndm/rndm/petsc/src/mat/interface/matrix.c</div>
<div class=""><br class="">
</div>
<div class="">Here is a reproducer (that will work OK with 3.12.4).</div>
<div class="">
<div class="">diff --git a/src/mat/tests/ex195.c b/src/mat/tests/ex195.c</div>
<div class="">index c72662bc3c..811de669c5 100644</div>
<div class="">--- a/src/mat/tests/ex195.c</div>
<div class="">+++ b/src/mat/tests/ex195.c</div>
<div class="">@@ -73,2 +73,3 @@ int main(int argc,char **args)</div>
<div class="">   ierr = MatMatMult(nest,B,MAT_REUSE_MATRIX,PETSC_DEFAULT,&C);CHKERRQ(ierr);</div>
<div class="">+  ierr = MatMatMult(nest,C,MAT_REUSE_MATRIX,PETSC_DEFAULT,&B);CHKERRQ(ierr);</div>
<div class="">   ierr = MatMatMultEqual(nest,B,C,10,&equal);CHKERRQ(ierr);</div>
</div>
<div class=""><br class="">
</div>
<div class="">$ make -f gmakefile test searchin=mat_tests-ex195</div>
<div class=""><br class="">
</div>
<div class="">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 class="">Thanks,</div>
<div class="">Pierre</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 22 Apr 2020, at 5:38 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">
Jose, <span class="" style="color:rgb(50,49,48); font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">Pierre and Stefano,</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); font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">Now I understand the issue that Stefano raised. I plan to add</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); font-size:14.6667px; background-color:rgb(255,255,255); display:inline!important">MatProductIsSupported(Wmat,&supported,&matproductsetfromoptions)</span></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">
<span class="" style="font-size:14.6667px">the flag 'supported' tells if the product is supported/implemented or not,</span></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">
<span class="" style="font-size:14.6667px">and the function pointer '<span class="" style="background-color:rgb(255,255,255); display:inline!important">matproductsetfromoptions' gives the name of MatProductSetFromOptions_xxx, (including basic implementation)
 or NULL.</span></span></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">
<span class="" style="font-size:14.6667px"><span class="" style="background-color:rgb(255,255,255); display:inline!important"><br class="">
</span></span></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">
<span class="" style="font-size:14.6667px"><span class="" style="background-color:rgb(255,255,255); display:inline!important">Let me know your suggestions. I'll list all of you as reviewer.</span></span></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">
<span class="" style="font-size:14.6667px"><span class="" style="background-color:rgb(255,255,255); display:inline!important">Hong</span></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="" 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>
<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>Jose E. Roman <<a href="mailto:jroman@dsic.upv.es" class="">jroman@dsic.upv.es</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Wednesday, April 22, 2020 9:07 AM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" class="">stefano.zampini@gmail.com</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" class="">hzhang@mcs.anl.gov</a>>; Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</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="x_Apple-converted-space"> </span>Re: [petsc-dev] MATOP_MAT_MULT</font>
<div class=""> </div>
</div>
<div class="x_BodyFragment" 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" class=""><span class="" style="font-size:11pt">
<div class="x_PlainText">I agree with Pierre and Stefano.<br class="">
Hong: your proposed solution would be fine, but MATOP_MATPRODUCT does not exist yet, so I cannot try it.<br class="">
I would like a solution along the lines of what Stefano suggests. It is not too much trouble if it goes to master instead of maint.<br class="">
<br class="">
Thanks.<br class="">
Jose<br class="">
<br class="">
<br class="">
> El 22 abr 2020, a las 15:26, Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" class="">stefano.zampini@gmail.com</a>> escribió:<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
><span class="x_Apple-converted-space"> </span><br class="">
>><span class="x_Apple-converted-space"> </span><br class="">
>> MatProductCreateWithMat(A,Vmat,NULL,Wmat);<br class="">
>> MatProductSetType(Wmat,MATPRODUCT_AB);<br class="">
>> MatHasOperation(Wmat,MATOP_MATPRODUCT,&flg); //new support, it calls MatProductSetFromOptions(Wmat)<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
> Hong, this would go in the direction I was outlining here<span class="x_Apple-converted-space"> </span><a href="https://gitlab.com/petsc/petsc/-/issues/608" class="">https://gitlab.com/petsc/petsc/-/issues/608</a><br class="">
> How about also adding something like<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
> MatProductIsImplemented(Wmat,&flg)<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
> That returns true if a specific implementation is available? This way<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
> This way, if we use both queries, we can assess the presence of the basic fallbacks too, i.e.<br class="">
> <span class="x_Apple-converted-space"> </span><br class="">
> MatHasOperation(Wmat,MATOP_MATPRODUCT,&flg1)<br class="">
> MatProductIsImplemented(Wmat,&flg2)<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
> If flg1 is false, no support at all<br class="">
> If flg1 is true and flg2 is false -> Basic implementation (i.e, MatShell with products inside)<br class="">
> If flg1 and flg2 are both true -> Specific implementation available.<br class="">
><span class="x_Apple-converted-space"> </span><br class="">
>> if (V->vmm && flg) {<br class="">
>>   MatProductSymbolic(Wmat);<br class="">
>>   MatProductNumeric(Wmat);<br class="">
>> } else {<br class="">
>>   MatDestroy(Wmat);<br class="">
>>   ...<br class="">
>> }<br class="">
>> Hong<br class="">
>><span class="x_Apple-converted-space"> </span><br class="">
>><span class="x_Apple-converted-space"> </span><br class="">
>> From: Jose E. Roman <<a href="mailto:jroman@dsic.upv.es" class="">jroman@dsic.upv.es</a>><br class="">
>> Sent: Tuesday, April 21, 2020 11:21 AM<br class="">
>> To: Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" class="">pierre.jolivet@enseeiht.fr</a>><br class="">
>> Cc: 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="">
>> Subject: Re: [petsc-dev] MATOP_MAT_MULT<br class="">
>> <span class="x_Apple-converted-space"> </span><br class="">
>><span class="x_Apple-converted-space"> </span><br class="">
>><span class="x_Apple-converted-space"> </span><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="x_Apple-converted-space"> </span><br class="">
>> ><span class="x_Apple-converted-space"> </span><br class="">
>> ><span class="x_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="x_Apple-converted-space"> </span><br class="">
>> >> Pierre,<br class="">
>> >> MatMatMult_xxx() is removed from MatOps table.<br class="">
>> ><span class="x_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="x_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="">
>><span class="x_Apple-converted-space"> </span><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="">
>><span class="x_Apple-converted-space"> </span><br class="">
>> ><span class="x_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="x_Apple-converted-space"> </span><br class="">
>> >> Where/when do you need query a single matrix for its product operation?<br class="">
>> ><span class="x_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="x_Apple-converted-space"> </span><br class="">
>> > Thanks,<br class="">
>> > Pierre<br class="">
>> ><span class="x_Apple-converted-space"> </span><br class="">
>> >> Hong<br class="">
>> >><span class="x_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="x_Apple-converted-space"> </span><br class="">
>> >> Hello,<br class="">
>> >> Am I seeing this correctly?<br class="">
>> >> #include <petsc.h><br class="">
>> >><span class="x_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="x_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="x_Apple-converted-space"> </span><br class="">
>> >> => FALSE<br class="">
>> >><span class="x_Apple-converted-space"> </span><br 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><br class="">
>> >> I also believe Stefano raised a similar point there:<span class="x_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.,<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<span class="x_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="x_Apple-converted-space"> </span><br class="">
>> >> Thanks,<br class="">
>> >> Pierre<br class="">
>> ><span class="x_Apple-converted-space"> </span><br class="">
><span class="x_Apple-converted-space"> </span></div>
</span></font></div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>