This Message Is From an External Sender
This message came from outside your organization.
On Fri, 01 Mar 2024 10:09:17 -0600, Junchao Zhang wrote: >No. MatMPIBAIJSetPreallocationCSR() copies the data, but >VecCreateMPIWithArray() does not copy (only use pointers user provided).
OK, my understanding was that MatMPIBAIJSetPreallocationCSR DOES NOT copy since it has direct access to matrix entries in the required PETSc layout -> thank you >I think your intention is to avoid memory copies. Yes. (not only copies but also avoid unnecessary increase of memory footprint) >If it is MATMPIAIJ, we can do > MatMPIAIJSetPreallocationCSR(A, i, j, v); // let petsc copy i, j v > > // To quickly update A when you have an updated v[] > > MatUpdateMPIAIJWithArray(A, v); // copy v[], but faster than MatSetValues() Thanks for this input! >But it seems we currently do not have a MatUpdateMPIBAIJWithArray() :( So when my v[] changed during iterations (only the v[] used during the MatMPIBAIJSetPreallocationCSR call, the matrix structure/connectivity has NOT changed), it is not sufficient to just call KSPSetOperators() before calling KSPSolve()? I must copy the updated values in v[] explicitly into the PETSc matrix, then call KSPSetOperators() followed by KSPSolve()? (for every iteration in my application) The preferred method then is to use MatSetValues() for the copies (or possibly MatSetValuesRow() or MatSetValuesBlocked())? The term "Preallocation" is confusing to me. For example, MatCreateMPIBAIJWithArrays clearly states in the doc that arrays are copied (https://urldefense.us/v3/__https://petsc.org/release/manualpages/Mat/MatCreateMPIBAIJWithArrays/__;!!G_uCfscf7eWS!a-UBfuP3o9tlDwzsoQk96J7OEVPKPRJONV_Ewy4C4o-hTcNCvl1nz1zV1BOPmUPBV8Ut1KzogHxpgV7VG46E46g$), I would then assume PETSc maintains internal storage for it. If something is preallocated, I would not make that assumption. Thank you for your time, I appreciate the inputs! All best, -- fabs
