[petsc-users] Question about preallocation on MPIAIJ

Barry Smith bsmith at mcs.anl.gov
Thu Nov 24 12:25:15 CST 2011


  If you can call MatMPIAIJSetPreallocation() with the correct preallocation amounts then your approach of storing ALL the element stiffnesses before putting them into the PETSc matrices will require MUCH MUCH more memory then simply calling MatSetValuesLocal() as soon as each element stiffness is computed and your approach will not run faster. 


   Barry

On Nov 24, 2011, at 11:59 AM, Kyungjoo Kim wrote:

> Dear Petsc experts
> 
> 
> I have a elemental matrices that are not assembled yet, but those matrices have bijection map from local to global.
> So far I preallocate memory large enough to cache those unassembled matrices with expecting that Petsc manages the assembly efficiently.
> 
> There are two cases: 
> 
> 1) Preallocation is large enough for the assembled matrices for each processor
> 2) More memory space needs for the additional member elements from assembly procedure.
> 
> This problem is easy to manage by sharing assembly information only. 
> 
> But I am wondering how efficient Petsc assembly procedure is made. 
> Even though I can assembly the matrices by scattering necessary parts to others without using Petsc API, I am not very sure that I am doing correctly with respect to communication cost. And possibly Petsc assembly does same way as I do. ( So far both cases take more time than I expect ).
> 
> 
> FYI: 
> Unlike the example in the Petsc, the node index in the unstructured grid is highly irregular. And the partition of mesh is already defined. 
> 
> Any suggestion or example or reference ? 
> 
> 
> 
> Thank you.
> 
> 
> 
> 
> Kyungjoo



More information about the petsc-users mailing list