<div dir="ltr"><div dir="ltr">On Mon, Jan 27, 2025 at 8:42 AM Pierre Jolivet <<a href="mailto:pierre@joliv.et">pierre@joliv.et</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> On 27 Jan 2025, at 2:23 PM, <a href="mailto:medane.tchakorom@univ-fcomte.fr" target="_blank">medane.tchakorom@univ-fcomte.fr</a> wrote:<br>
> <br>
> Dear PETSc users,<br>
> <br>
> I hope this message finds you well. I don’t know If my question is relevant, but I’am currently working with DENSE type matrix, and would like to copy one matrix R_part [ n/2 x m] (resulted from a MatMatMult operation) into another dense matrix R_full [n x m]. <br>
> Both matrices being on the same communicator, I would like to efficiently copy R_part in the first half of R_full. <br>
> I have being using MatSetValues, but for large matrices, the subsequent assembling operation is costly.<br>
<br>
Could you please share the output of -log_view as well as a single file that will be generated with -info dump (e.g., dump.0, the file associated to process #0)?<br>
This shouldn’t be that costly, so there may be an option missing, like MAT_NO_OFF_PROC_ENTRIES.<br>
Anyway, if you want to optimize this, the fastest way would be to call MatDenseGetArray[Read,Write]() and then do the necessary PetscArraycpy().<br></blockquote><div><br></div><div>The other alternative (which I think makes cleaner code) is to use</div><div><br></div><div> <a href="https://urldefense.us/v3/__https://petsc.org/main/manualpages/Mat/MatDenseGetSubMatrix/__;!!G_uCfscf7eWS!ZOoOupB2xSO9fOY1fdeyPQU6bNVEuctFDItgqZzhKerRBnX3177w7U4_2rlep0tcSVOrNgKt75z9xd8BvjI9$">https://petsc.org/main/manualpages/Mat/MatDenseGetSubMatrix/</a></div><div><br></div><div>to create your R_part matrix. Then you are directly acting on the memory you want when assemble the smaller matrix.</div><div><br></div><div> THanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks,<br>
Pierre<br>
<br>
> Please could you suggest me some strategies or functions to do this efficiently. <br>
> <br>
> Thank you for your time and assistance.<br>
> <br>
> Best regards,<br>
> Tchakorom Medane<br>
> <br>
<br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZOoOupB2xSO9fOY1fdeyPQU6bNVEuctFDItgqZzhKerRBnX3177w7U4_2rlep0tcSVOrNgKt75z9xasPQhF0$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>