[petsc-users] Initializing a large sparse matrix

Jose E. Roman jroman at dsic.upv.es
Mon Oct 17 03:17:07 CDT 2022


There are examples in the manpages, see for instance

https://petsc.org/release/docs/manualpages/Mat/MatCreateAIJ/
https://petsc.org/release/docs/manualpages/Mat/MatMPIAIJSetPreallocation/

Jose


> El 17 oct 2022, a las 10:12, fujisan <fujisan43 at gmail.com> escribió:
> 
> Can I preallocate space for a rectangular matrix using MatCreateAIJ() in parallel?
> It is not clear to me how I have to define d_nnz when the matrix is rectangular?
> 
> X * * * *
> * X * * *
> * * X * *
> * * * X *
> * * * * X
> * * * * *
> * * * * *
> 
> The example shown is for an 8x8 matrix on 3 cpu
> X * *
> * X *
> * * X
> 
> On Mon, Oct 17, 2022 at 9:02 AM Jose E. Roman <jroman at dsic.upv.es> wrote:
> You have to preallocate, see https://petsc.org/release/docs/manual/mat/#sec-matsparse
> 
> > El 17 oct 2022, a las 8:37, fujisan <fujisan43 at gmail.com> escribió:
> > 
> > Hi everyone,
> > 
> > I initialize a large sparse matrix (50000x20000) using MatCreate() and then filling it with MatSetValues() line by line 
> > but it takes a bit more than an hour on 80 cores to fill in the matrix.
> > 
> > Is there a way to optimize this initialization?
> > 
> > Fuji
> 



More information about the petsc-users mailing list