matrix memory allocation

Barry Smith bsmith at mcs.anl.gov
Sat Mar 29 21:20:34 CDT 2008


    Matt,

    I do not see any specific dis-advantage in your looping over the  
boxes and determining
the preallocation and then looping again to set the values? Surely  
there is no performance
issue?

    Having support for this in PETSc would be a very dramatic change,  
perhaps if we
understand better the problem perhaps we can come up with an  
alternative solution
to your problem.

    Barry

On Mar 26, 2008, at 3:31 PM, Matt Funk wrote:
> Hi,
>
> in order to create a sparse MPIMatrix (with preallocated memory) it is
> necessary to give it the number of nonzero entries per row for the  
> local and
> off-diagonal submatrix.
>
> The way i do things right now is that i need to allocate the entire  
> matrix.
> However, my domain is decomposed into boxes where one or more boxes  
> reside on
> the current processor.
>
> So, i was wondering if it is possible to allocate the matrix memory  
> per box.
> Right now what i do is this:
> 1) iterate over the whole domain (every single box) and extract the  
> info i
> need from each box for memory allocation.
> 2) call MatCreateMPIAIJ to create the matrix/allocate memory.
> 3) iterate over the whole domain again to get the info to insert the  
> values
> into the matrix.
>
> Is it possible to instead do something like:
> 1) get info for values and memory allocation needed per box
> 2) allocate memory for x number of rows in global matrix and insert  
> values for
> them (via MatSetValues)
> 3) start at 1) till every box in the domain is covered.
>
> The problem in 2) is that i can insert the values, but there is no  
> memory
> preallocated for it, so it would be slow. If i could allocate it, i  
> think it
> would solve my problem.
>
> I hope i am making sense. By the way, i cannot use the DA construct  
> because i
> have overlapping values.
>
> thanks
> mat
>




More information about the petsc-users mailing list