[petsc-users] Question-Memory of matsetvalue
Matthew Knepley
knepley at gmail.com
Fri Dec 30 08:27:26 CST 2022
On Fri, Dec 30, 2022 at 4:36 AM 김성익 <ksi2443 at gmail.com> wrote:
> Hello,
>
>
>
> I have a question about memory of matsetvalue.
>
> When I assembly the local matrix to global matrix, I’m just using
> matsetvalue.
> Because the connectivity is so complex I can’t use matsetvalues.
>
> I asked this question because I was curious about how ram memory is
> allocated differently for the two simtuations below.
>
>
>
> First situation.
>
> The local matrix size is 24 by 24. And the number of local matrix is
> 125,000.
>
> When assembly procedure by using matsetvalue, memory allocation does not
> increase.
> So I just put Matassemblybegin and matassemblyend after all matsetvalue.
>
>
>
> Second situation.
>
> The local matrix size is 60 by 60. And the number of local matrix is
> 27,000.
>
> When assembly procedure by using matsetvalue, memory allocation does
> increase.
>
> So I just put Matassemblybegin and matassemblyend after each local matrix
> assembly.
> This did not increase the memory further..
>
>
>
> Why this situation is happen?
>
> And is there any way to prevent the memory allocation from increasing?
>
Matrix assembly has two stages. First you insert entries into the local
portion of your parallel matrix
using MatSetValue(s). If all values you try to insert are local, this is
the end.
However, if you try to insert values that are local to another process, we
store those values. When you
call MatAssemblyBegin/End(), we communicate them to the correct process and
insert.
For a scalable code, you should insert most values on the correct process.
If not, significant memory
can be consumed storing these values. Anywhere in the assembly process you
can call
MatAssemblyBegin(A, MAT_ASSEMBLY_FLUSH);
MatAssemblyEnd(A, MAT_ASSEMBLY_FLUSH);
This will communicate the cache of values, but not end the assembly.
Thanks,
Matt
> Thanks,
>
> Hyung Kim
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221230/3515bb13/attachment-0001.html>
More information about the petsc-users
mailing list