Dynamic allocation of Non zeros?

Zhifeng Sheng z.sheng at ewi.tudelft.nl
Fri Nov 2 07:23:40 CDT 2007


Barry Smith wrote:

>
>
> Zhifeng,
>
> We already do this; it helps with the time, but still results in very 
> inefficient runs if your preallocation is zero entries.
>
> Perhaps you could describe how your matrix entries are generated and 
> we can suggest a
> preallocation scheme?
>
> Barry
>
>
> On Nov 1, 2007, at 7:52 AM, 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?
>>
>> Could please tell what happens if I assign the nozero number in rows 
>> to be zeros and let the programme fills in the nonzeros ?
>>
>> Best regards
>> Zhifeng Sheng
>>
>
In that case I'd better do some preallocation. I am working on 3D FEM 
code with unstructured tetrahedron mesh, and on each node, we can have 3 
to arround 12 unknowns, at this moment I assigned 50 nonzeros to each 
rows, and it is sufficient... just half of the memory assigned went 
wasted. Then I tried 25 nonzeros in a row, but this is not enough and 
the performance is terrible.

So... do I really need to compute the nonzero pattern?

Ps. my matrix is SeqSBAIJ with block size 1, so I am wondering when I 
specify the nonzeros in a row, does it mean the actually nonzeros 
numbers or the memory that is needed? (for instance, for SeqSBAIJ, the 
actual nonzeros in a row would twice as much as memory needed)

Thank you
Best regards
Zhifeng






More information about the petsc-users mailing list