[petsc-users] MatCreateMPIAIJWithArrays
Matthew Knepley
knepley at gmail.com
Mon Jul 23 03:37:50 CDT 2018
On Mon, Jul 23, 2018 at 4:26 AM 金degang <328937290 at qq.com> wrote:
> Hello,
> I am a beginner user. I meet a problem. I have a very big matrix.
> In shaping the matrix, every nodes produce some rows of it. So it is very
> easy to store it with files at every node. In the solve Ax=b, I hope every
> node to read the file and construct the big matrix in parallel. Every
> file's is a sub matrix which is row block. So I
> use MatCreateMPIAIJWithArrays to Create the matrix.
>
1) Just give PETSC_DETERMINE for the number of local columns
2) I would caution you about this design. I do not think it will accomplish
what you want:
a) Modern machines are not scalable with respect to file I/O. Thus
reading for a bunch of files
onto a bunch of processes will not scale well. You just want to put
it in a single file and
distribute from proc 0. If you use PETSc binary or HDF5, it will do
this.
b) Using separate files prescribes the parallelism, which is inflexible.
Done the other way, you
can launch on any number of processes.
Thanks,
Matt
> For example:
> -1 2 -1 0 0 0 0 0 0 0
> 0 -1 2 -1 0 0 0 0 0 0
> ---------------------------------------------------------------
> 0 0 -1 2 -1 0 0 0 0 0
> 0 0 0 -1 0 0 0 0 0 0
> ---------------------------------------------------------------
> 0 0 0 0 -1 2 -1 0 0 0
> 0 0 0 0 0 -1 2 -1 0 0
> ---------------------------------------------------------------
> 0 0 0 0 0 0 -1 2 -1 0
> 0 0 0 0 0 0 0 -1 2 -1
> ---------------------------------------------------------------
> 0 0 0 0 0 0 0 0 -1 2
> 0 0 0 0 0 0 0 0 0 -1
>
> Node 1 0-1 row block
> Node 2 2-3 row block
> Node 3 4-5 row block
> Node 4 6-7 row block
> Node 5 8-9 row block
>
> use
>
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node1
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node2
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node3
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node4
> MatCreateMPIAIJWithArrays(PETSC_COMM_SELF, 2, 10, 10,10, i,j,a); for node5
>
> but there are error . sum of cols of five nodes is not equal 10 (global
> column).
>
> How to solve this problem, Hope to get your help!
>
> thanks
>
> Degang Jin
>
--
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.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180723/76515213/attachment.html>
More information about the petsc-users
mailing list