[petsc-users] Preallocation for regtangular matrix

Pham Van pham_ha at yahoo.com
Sat Apr 28 12:17:48 CDT 2012


Dear Jed Brown,

I had found a better way: treat the matrix as a square matrix. Since it is spare anyway, so there should be no memory burden by doing so. I also extended the vector size to avoid conformable problem. I guess the size of a vector does not matter that much.

This little trick does a great job.


Nevertheless it would be great if you guy (developers) could consider putting some comments on creation of rectangular matrix.

Thank you for your very quick response.


Kind regards,
Pham Van Ha



________________________________
 From: Jed Brown <jedbrown at mcs.anl.gov>
To: Pham Van <pham_ha at yahoo.com>; PETSc users list <petsc-users at mcs.anl.gov> 
Sent: Saturday, April 28, 2012 5:05 PM
Subject: Re: [petsc-users] Preallocation for regtangular matrix
 

On Sat, Apr 28, 2012 at 03:32, Pham Van <pham_ha at yahoo.com> wrote:

I am trying to create matrices for a rectangular matrix with number of rows is much bigger than number of columns.
>
>I create 2 matrices together one square and one rectangular with the same number of rows. To my surprise the smaller matrix (rectangular) creation take much more time than the bigger one (rectangular). I did preallocate for both matrices with predefine number of diagonal and off-diagonal entries. But then again I did not know how to define diagonal part of a rectangular matrix. Only a very small top part of the matrix is "diagonal".
>
>I have try both method: the first one to set diagonal and off-diagonal part as it was a square matrix; and second to set only a small top part of the matrix diagonal. Both method does not work.
>
>Does anyone know how to preallocate a rectangular
 matrix.
>
>By the way, the same code run pretty fast when I run with single process and painfully slow when 2 processes employed.

The matrix has row and column ownership ranges. The "diagonal" part is any entry that lies in both the row and column ownership range. The "off-diagonal" part is in the row ownership range, but not in the column ownership range.

Run with -mat_new_nonzero_allocation_err or

ierr = MatSetOption(B,MAT_NEW_NONZERO_ALLOCATION_ERR,flg);CHKERRQ(ierr);

to find which entries start going outside your preallocation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120428/30e9f9ee/attachment.htm>


More information about the petsc-users mailing list