[petsc-users] MatMPIAIJSetPreallocation question

Gideon Simpson gideon.simpson at gmail.com
Sun Feb 15 20:22:34 CST 2015


I’m trying to get a handle on the different ways of constructing matrices.  Currently, I have:

MatCreate(...)
MatSetSizes(...)
MatSetFromOptions(...)
MatSetUp(…)

but I gather from reading the manual that, by not preallocating, I’m losing out in performance.  If I assume that my matrix will either by SeqAIJ or MPIAIJ, depending on the number of processors available, how would I go about doing this.  I see some of the example codes with:

MatSeqAIJSetPreallocation(…)
MatMPIAIJSetPreallocation(…)

as successive commands.  Should I interpret this as saying that PETSc will just ignore the one that is not the active one in the current instance? 

-gideon



More information about the petsc-users mailing list