Dynamic allocation of Non zeros?

Hong Zhang hzhang at mcs.anl.gov
Thu Nov 1 09:32:31 CDT 2007



On Thu, 1 Nov 2007, Zhifeng Sheng wrote:

> Dear all
>
> It is always not easy to determine the number of nonzeros in a row without 
> any cost.
>
> I wonder if I can make dynamic allocation, for instance, if one found the 
> nonzeros of a row overflow the pre-allocated space, then the space shall be 
> doubled.
>
> This may waste some memory but it may not be that bad. Or maybe this is 
> already done in Petsc?

This is implemented in petsc, and is the reasons that MatAssembly 
may become extremely slow when user does not preallocate memory.
>
> Could please tell what happens if I assign the nozero number in rows to be 
> zeros and let the programme fills in the nonzeros ?

It would be better that you assign a max nozero number than zero
to reduce memory malloc.

Hong

>
> Best regards
> Zhifeng Sheng
>
>




More information about the petsc-users mailing list