<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, <span 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; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important">Pierre
 and Stefano,</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span 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; 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 style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span 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; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important">MatProductIsSupported(Wmat,&supported,&matproductsetfromoptions)</span></div>
<div style=""><span style="font-size: 14.6667px;">the flag 'supported' tells if the product is supported/implemented or not,</span></div>
<div style=""><span style="font-size: 14.6667px;">and the function pointer '<span style="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); display: inline !important">matproductsetfromoptions'
 gives the name of MatProductSetFromOptions_xxx, (including basic implementation) or NULL.</span></span></div>
<div style=""><span style="font-size: 14.6667px;"><span style="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); display: inline !important"><br>
</span></span></div>
<div style=""><span style="font-size: 14.6667px;"><span style="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); display: inline !important">Let
 me know your suggestions. I'll list all of you as reviewer.</span></span></div>
<div style=""><span style="font-size: 14.6667px;"><span style="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); display: inline !important">Hong</span></span></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> Jose E. Roman <jroman@dsic.upv.es><br>
<b>Sent:</b> Wednesday, April 22, 2020 9:07 AM<br>
<b>To:</b> Stefano Zampini <stefano.zampini@gmail.com><br>
<b>Cc:</b> Zhang, Hong <hzhang@mcs.anl.gov>; Pierre Jolivet <pierre.jolivet@enseeiht.fr>; petsc-dev <petsc-dev@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-dev] MATOP_MAT_MULT</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">I agree with Pierre and Stefano.<br>
Hong: your proposed solution would be fine, but MATOP_MATPRODUCT does not exist yet, so I cannot try it.<br>
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>
<br>
Thanks.<br>
Jose<br>
<br>
<br>
> El 22 abr 2020, a las 15:26, Stefano Zampini <stefano.zampini@gmail.com> escribió:<br>
> <br>
> <br>
>> <br>
>> MatProductCreateWithMat(A,Vmat,NULL,Wmat);<br>
>> MatProductSetType(Wmat,MATPRODUCT_AB);<br>
>> MatHasOperation(Wmat,MATOP_MATPRODUCT,&flg); //new support, it calls MatProductSetFromOptions(Wmat)<br>
> <br>
> Hong, this would go in the direction I was outlining here <a href="https://gitlab.com/petsc/petsc/-/issues/608">
https://gitlab.com/petsc/petsc/-/issues/608</a><br>
> How about also adding something like<br>
> <br>
> MatProductIsImplemented(Wmat,&flg)<br>
> <br>
> That returns true if a specific implementation is available? This way<br>
> <br>
> This way, if we use both queries, we can assess the presence of the basic fallbacks too, i.e.<br>
>  <br>
> MatHasOperation(Wmat,MATOP_MATPRODUCT,&flg1)<br>
> MatProductIsImplemented(Wmat,&flg2)<br>
> <br>
> If flg1 is false, no support at all<br>
> If flg1 is true and flg2 is false -> Basic implementation (i.e, MatShell with products inside)<br>
> If flg1 and flg2 are both true -> Specific implementation available.<br>
> <br>
>> if (V->vmm && flg) {<br>
>>   MatProductSymbolic(Wmat);<br>
>>   MatProductNumeric(Wmat);<br>
>> } else {<br>
>>   MatDestroy(Wmat);<br>
>>   ...<br>
>> }<br>
>> Hong<br>
>> <br>
>> <br>
>> From: Jose E. Roman <jroman@dsic.upv.es><br>
>> Sent: Tuesday, April 21, 2020 11:21 AM<br>
>> To: Pierre Jolivet <pierre.jolivet@enseeiht.fr><br>
>> Cc: Zhang, Hong <hzhang@mcs.anl.gov>; petsc-dev <petsc-dev@mcs.anl.gov><br>
>> Subject: Re: [petsc-dev] MATOP_MAT_MULT<br>
>>  <br>
>> <br>
>> <br>
>> > El 21 abr 2020, a las 17:53, Pierre Jolivet <pierre.jolivet@enseeiht.fr> escribió:<br>
>> > <br>
>> > <br>
>> > <br>
>> >> On 21 Apr 2020, at 5:22 PM, Zhang, Hong <hzhang@mcs.anl.gov> wrote:<br>
>> >> <br>
>> >> Pierre,<br>
>> >> MatMatMult_xxx() is removed from MatOps table.<br>
>> > <br>
>> > Shouldn’t there be a deprecation notice somewhere?<br>
>> > There is nothing about MATOP_MAT_MULT in the 3.13 changelog <a href="https://www.mcs.anl.gov/petsc/documentation/changes/313.html">
https://www.mcs.anl.gov/petsc/documentation/changes/313.html</a><br>
>> > For example, I see that in SLEPc, José is currently making these checks, which are in practice useless as they always return PETSC_FALSE?https://gitlab.com/slepc/slepc/-/blob/master/src/sys/classes/bv/impls/contiguous/contig.c#L191<br>
>> > (Maybe José is aware of this and this is just for testing)<br>
>> <br>
>> 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>
>> <br>
>> > <br>
>> >> MatMatMult() is replaced by<br>
>> >> MatProductCreate()<br>
>> >> MatProductSetType(,MATPRODUCT_AB)<br>
>> >> MatProductSetFromOptions()<br>
>> >> MatProductSymbolic()<br>
>> >> MatProductNumeric()<br>
>> >> <br>
>> >> Where/when do you need query a single matrix for its product operation?<br>
>> > <br>
>> > 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>
>> > 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>
>> > 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>
>> > <br>
>> > Thanks,<br>
>> > Pierre<br>
>> > <br>
>> >> Hong<br>
>> >> <br>
>> >> From: petsc-dev <petsc-dev-bounces@mcs.anl.gov> on behalf of Pierre Jolivet <pierre.jolivet@enseeiht.fr><br>
>> >> Sent: Tuesday, April 21, 2020 7:50 AM<br>
>> >> To: petsc-dev <petsc-dev@mcs.anl.gov><br>
>> >> Subject: [petsc-dev] MATOP_MAT_MULT<br>
>> >>  <br>
>> >> Hello,<br>
>> >> Am I seeing this correctly?<br>
>> >> #include <petsc.h><br>
>> >> <br>
>> >> int main(int argc,char **args)<br>
>> >> {<br>
>> >>   Mat               A;<br>
>> >>   PetscBool         hasMatMult;<br>
>> >>   PetscErrorCode    ierr;<br>
>> >> <br>
>> >>   ierr = PetscInitialize(&argc,&args,NULL,NULL);if (ierr) return ierr;<br>
>> >>   ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);<br>
>> >>   ierr = MatSetType(A,MATMPIAIJ);CHKERRQ(ierr);<br>
>> >>   ierr = MatHasOperation(A,MATOP_MAT_MULT,&hasMatMult);CHKERRQ(ierr);<br>
>> >>   printf("%s\n", PetscBools[hasMatMult]);<br>
>> >>   ierr = PetscFinalize();<br>
>> >>   return ierr;<br>
>> >> }<br>
>> >> <br>
>> >> => FALSE<br>
>> >> <br>
>> >> I believe this is a regression (or at least an undocumented change) introduced here:
<a href="https://gitlab.com/petsc/petsc/-/merge_requests/2524/">https://gitlab.com/petsc/petsc/-/merge_requests/2524/</a><br>
>> >> I also believe Stefano raised a similar point there: <a href="https://gitlab.com/petsc/petsc/-/issues/608">
https://gitlab.com/petsc/petsc/-/issues/608</a><br>
>> >> 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>
>> >> 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">
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">
https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/nest/matnest.c.html#line2105</a><br>
>> >> Is this being addressed/documented?<br>
>> >> <br>
>> >> Thanks,<br>
>> >> Pierre<br>
>> > <br>
> <br>
<br>
</div>
</span></font></div>
</body>
</html>