Copy dense matrix into half part of another dense matrix
Dear PETSc users, 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]. Both matrices being on the same communicator, I would like to efficiently copy R_part in the first half of R_full. I have being using MatSetValues, but for large matrices, the subsequent assembling operation is costly. Please could you suggest me some strategies or functions to do this efficiently. Thank you for your time and assistance. Best regards, Tchakorom Medane
On 27 Jan 2025, at 2:23 PM, [email protected] wrote:
Dear PETSc users,
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]. Both matrices being on the same communicator, I would like to efficiently copy R_part in the first half of R_full. I have being using MatSetValues, but for large matrices, the subsequent assembling operation is costly.
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)? This shouldn’t be that costly, so there may be an option missing, like MAT_NO_OFF_PROC_ENTRIES. Anyway, if you want to optimize this, the fastest way would be to call MatDenseGetArray[Read,Write]() and then do the necessary PetscArraycpy(). Thanks, Pierre
Please could you suggest me some strategies or functions to do this efficiently.
Thank you for your time and assistance.
Best regards, Tchakorom Medane
On Mon, Jan 27, 2025 at 8:42 AM Pierre Jolivet <[email protected]> wrote:
On 27 Jan 2025, at 2:23 PM, [email protected] wrote:
Dear PETSc users,
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]. Both matrices being on the same communicator, I would like to efficiently copy R_part in the first half of R_full. I have being using MatSetValues, but for large matrices, the subsequent assembling operation is costly.
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)? This shouldn’t be that costly, so there may be an option missing, like MAT_NO_OFF_PROC_ENTRIES. Anyway, if you want to optimize this, the fastest way would be to call MatDenseGetArray[Read,Write]() and then do the necessary PetscArraycpy().
The other alternative (which I think makes cleaner code) is to use https://urldefense.us/v3/__https://petsc.org/main/manualpages/Mat/MatDenseGe... to create your R_part matrix. Then you are directly acting on the memory you want when assemble the smaller matrix. THanks, Matt
Thanks, Pierre
Please could you suggest me some strategies or functions to do this efficiently.
Thank you for your time and assistance.
Best regards, Tchakorom Medane
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCf... <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfs... >
participants (3)
-
Matthew Knepley -
medane.tchakorom@univ-fcomte.fr -
Pierre Jolivet