[petsc-users] Preallocation for regtangular matrix

Jed Brown jedbrown at mcs.anl.gov
Sat Apr 28 05:05:22 CDT 2012


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/208b1c4c/attachment.htm>


More information about the petsc-users mailing list