See the manual page for MatMPIAIJSetPreallocationCSR() it gives an explicit
simple example
The format which is used for the sparse matrix input, is equivalent to a
row-major ordering.. i.e for the following matrix, the input data expected
is
as shown:
1 0 0
2 0 3 P0
-------
4 5 6 P1
Process0 [P0]: rows_owned=[0,1]
i = {0,1,3} [size = nrow+1 = 2+1]
j = {0,0,2} [size = nz = 6]
v = {1,2,3} [size = nz = 6]
Process1 [P1]: rows_owned=[2]
i = {0,3} [size = nrow+1 = 1+1]
j = {0,1,2} [size = nz = 6]
v = {4,5,6} [size = nz = 6]
The column indices are global, the numerical values are just numerical
values and do not need to be adjusted. On each process the i indices start with
0 because they just point into the local part of the j indices.
Are you saying each process of yours HAS the entire matrix? If so you just
need to adjust the local portion of the i vales and pass that plus the
appropriate location in j and v to the routine as in the example above.
Barry
On May 14, 2014, at 8:36 AM, Oliver Browne <[email protected]> wrote:
>
>
>
> On 14-05-2014 15:27, Barry Smith wrote:
>> On May 14, 2014, at 7:42 AM, Oliver Browne <[email protected]> wrote:
>>> Hi,
>>> I am using MatMPIAIJSetPreallocationCSR to preallocate the rows, columns
>>> and values for my matrix (efficiency). I have my 3 vectors in CSR format.
>>> If I run on a single processor, with my test case, everything works fine. I
>>> also worked without MatMPIAIJSetPreallocationCSR, and individually input
>>> each value with the call MatSetValues in MPI and this also works fine.
>>> If I want to use MatMPIAIJSetPreallocationCSR, do I need to separate the
>>> vectors for each processor as they have done here;
>> What do you mean by “separate” the vectors? Each processor
>> needs to provide ITS rows to the function call. You cannot have
>> processor zero deliver all the rows.
>
> I mean split them so they change from global numbering to local numbering.
>
> At the moment I just have
>
> CALL MatMPIAIJSetPreallocationCSR(A,NVPN,NNVI,CONT,ierr) - 3 vectors have
> global numbering
>
> How can submit this to a specific processor?
>
> Ollie
>
>
>> Barry
>>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocationCSR.html#MatMPIAIJSetPreallocationCSR
>>> Thanks in advance,
>>> Ollie