[petsc-users] MatMPIAIJSetPreallocationCSR

Barry Smith bsmith at mcs.anl.gov
Fri May 16 07:12:25 CDT 2014


   No, process zero calls with 
> i = [0, 1, 3
> j = [0, 0, 2]
> v = [1,2,3]

and process one calls with 

> i = [0, 3]
> j = [ 0 , 1 , 2]
> v = [4,5,6]

this is how MPI works, each process figures out its own information and calls appropriate routines with its own values.

   Barry

On May 16, 2014, at 3:39 AM, Oliver Browne <oliver.browne at upm.es> wrote:

> 
>>> On 14-05-2014 17:34, Barry Smith wrote:
>>>> 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?
>>> I am not entirely sure about this and what it means. Each processor has a portion of the 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.
>>> So this MatMPIAIJSetPreallocationCSR call should be in some sort of loop;
>>> Do counter =  1, No of Processors
>>> calculate local numbering for i and isolate parts of j and v needed
>>> Call MatMPIAIJSetPreallocationCSR(A,i,j,v)
>>> END DO
>>> Is this correct?
>>   Oh boy, oh boy.  No absolutely not. Each process is calling
>> MatMPIAIJSetPreallocationCSR() once with its part of the data.
>>  Barry
> 
> 
> so using the above example
> 
> I should
> 
> CALL MatMPIAIJSetPreallocationCSR(A,i,j,v)
> 
> where
> 
> i = [0, 1, 3, 6]
> j = [0, 0, 2, 0 , 1 , 2]
> v = [1,2,3,4,5,6]
> 
> Ollie
> 
> 
>>> Ollie
>>>>  Barry
>>>> On May 14, 2014, at 8:36 AM, Oliver Browne <oliver.browne at upm.es> wrote:
>>>>> On 14-05-2014 15:27, Barry Smith wrote:
>>>>>> On May 14, 2014, at 7:42 AM, Oliver Browne <oliver.browne at upm.es> 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



More information about the petsc-users mailing list