[petsc-users] Loading only upper + MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);

Smith, Barry F. bsmith at mcs.anl.gov
Tue Mar 5 19:21:24 CST 2019



> On Mar 4, 2019, at 7:03 AM, Klaus Burkart via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Hello,
> 
> I want to solve many symmetric linear systems one after another in parallel using boomerAMG + KSPCG  and need to make the matrix transfer more efficient. Matrices are symmetric in structure and values. boomerAMG + KSPCG work fine.
> 
> So far I have been loading the entire matrices but I read in a paper, that it's sufficient to load the upper part only and tell petsc that the matrix is symmetric using MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE); Unfortunately all computations fail if I load only the upper values and use MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);

   Unfortunately it doesn't work that way. The MatSetOption() is just a marker that indicates that the user states the matrix is symmetric. It doesn't change the format or values.

    You could write a custom MatLoad() that reads in just the symmetric part and builds the entire MPIAIJ (since BoomerAMG requires the full MPIAIJ) but that is good amount of work because you have to do the careful communication needed to "fill in" the "transpose" part of the matrix. Basically read in the matrix and do a parallel transpose on the fly (also requires care in getting the matrix preallocation correct).

   Barry


    
> 
> The idea is:
> 
>     if (matrix_.symmetric())
>     {
>         MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);
>        //load only upper part of the matrix MatSetValues(...)
> 
>    }else //asymmetric matrix
>            {
>                //load the entire matrix MatSetValues(...)
>            }
> 
> Is it possible at all? 
> 
> Klaus



More information about the petsc-users mailing list