[petsc-users] more flexible MatSetValues?

Matthew Knepley knepley at gmail.com
Sat Feb 19 10:24:09 CST 2011


On Sat, Feb 19, 2011 at 7:43 AM, Gong Ding <gdiso at ustc.edu> wrote:

> So dynamic array is suitable for acting as a plus to the preallocation.
> Only a few extra matrix entries not considered in the preallocation are
> needed to be processed.
> For example, an integral boundary condition with dynamic integration range
> may have different nonzero entry in a row,
> which can be hold by the dynamic array.
>

I did benchmark of the STL dynamic data structures, and the memory overhead
is quite large. The problem
here is not necessarily what could be done, but what community expectations
are. People are not going to
ditch their old Fortran code for something that allocations 3-4 times the
memory.

As Barry points out, you could easily make a new subclass.

   Matt


>
>
>
> Values in each location are often set many times. Once per element in FEM,
> so about 20 times for P1 tets. That uses a lot more memory and you need to
> sort that beast to count correctly. Using a separate dynamic data structure
> for each row would be a lot more mallocs, but you could keep the rows sorted
> and avoid storing 20 copies, however insertion is still expensive. A heap is
> nice for insertion, but not for searching.
>
> So dynamic data structures could help, but they still cost quite a bit. The
> preallocation problem is trivial for finite difference methods so any useful
> solution needs to handle many insertions to the same location.
>
> On Feb 19, 2011 9:35 AM, "Gong Ding" <gdiso at ustc.edu> wrote:
>
> Hi,
> After reading the source code of aij.c, I think the MatSetValues function
> can be more flexible when preallocation is not correct.
>
> Why not use a dynamic array such as c++ vector of triple(a, i, j) to buffer
> the operation?
> And flush the buffer to real a,i,j array when MatAssemblyEnd is called?
>
> Gong Ding
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110219/168268a5/attachment.htm>


More information about the petsc-users mailing list