[petsc-users] parallelize matrix assembly process

Matthew Knepley knepley at gmail.com
Mon Dec 12 23:43:14 CST 2022


On Mon, Dec 12, 2022 at 11:54 PM 김성익 <ksi2443 at gmail.com> wrote:

>
> With the following example
> https://gitlab.com/petsc/petsc/-/blob/main/src/mat/tests/ex230.c
>
> There are some questions about MatPreallocator.
>
> 1. In parallel run, all the MPI ranks should do the same preallocator
> procedure?
>

In parallel, each process adds its own entries, just as you would in the
matrix assembly.


> 2. In ex230.c, the difference between ex1 of ex230.c and ex2 of ex230.c is
> the block.
> Developers want  to show using block is more efficient method than just
> using matsetvalues?
>

It can be.

  Thanks,

    Matt


> Thanks,
> Hyung Kim
>
> 2022년 12월 13일 (화) 오전 1:43, Junchao Zhang <junchao.zhang at gmail.com>님이 작성:
>
>> Since you run with multiple ranks, you should use matrix type mpiaij and
>> MatMPIAIJSetPreallocation. If preallocation is difficult to estimate, you
>> can use MatPreallocator, see an example at
>> https://gitlab.com/petsc/petsc/-/blob/main/src/mat/tests/ex230.c
>>
>> --Junchao Zhang
>>
>>
>> On Mon, Dec 12, 2022 at 5:16 AM 김성익 <ksi2443 at gmail.com> wrote:
>>
>>> Hello,
>>>
>>>
>>> I need some keyword or some examples for parallelizing matrix assemble
>>> process.
>>>
>>> My current state is as below.
>>> - Finite element analysis code for Structural mechanics.
>>> - problem size : 3D solid hexa element (number of elements : 125,000),
>>> number of degree of freedom : 397,953
>>> - Matrix type : seqaij, matrix set preallocation by using
>>> MatSeqAIJSetPreallocation
>>> - Matrix assemble time by using 1 core : 120 sec
>>>    for (int i=0; i<125000; i++) {
>>>     ~~ element matrix calculation}
>>>    matassemblybegin
>>>    matassemblyend
>>> - Matrix assemble time by using 8 core : 70,234sec
>>>   int start, end;
>>>   VecGetOwnershipRange( element_vec, &start, &end);
>>>   for (int i=start; i<end; i++){
>>>    ~~ element matrix calculation
>>>    matassemblybegin
>>>    matassemblyend
>>>
>>>
>>> As you see the state, the parallel case spent a lot of time than
>>> sequential case..
>>> How can I speed up in this case?
>>> Can I get some keyword or examples for parallelizing assembly of matrix
>>> in finite element analysis ?
>>>
>>> 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/20221213/86cfa75e/attachment-0001.html>


More information about the petsc-users mailing list