[petsc-users] Doubt in MPIPreallocation

John Albequerque johncfdcfd at gmail.com
Fri Feb 19 08:01:26 CST 2016


I am really sorry Matthew but I am not able to get your point. It would be
very kind of you if you could show me the changes in the code.

Thanks

----
John Albequerque.
Materials Science Lab,
UIUC

On Fri, Feb 19, 2016 at 5:15 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Fri, Feb 19, 2016 at 5:09 AM, John Albequerque <johncfdcfd at gmail.com>
> wrote:
>
>> Dear Matt,
>>
>> Sorry, I am not able to get you, as if I do not provide i>=j then the
>> matrix mentioned in the earlier mail won't be generated. For the code I
>> mentioned earlier, the output obtained is as follows -
>>
>>
>>
>>
>>
>>
>>
>>
>> *Mat Object: 1 MPI processes  type: mpiaijrow 0: (0, 1)  (1, 1)  (2, 1)
>> (3, 1)  (4, 0)  (5, 0)  (6, 0)  (7, 0) row 1: (0, 0)  (1, 1)  (2, 1)  (3,
>> 1)  (4, 1)  (5, 0)  (6, 0)  (7, 0) row 2: (0, 0)  (1, 0)  (2, 1)  (3, 1)
>> (4, 1)  (5, 1)  (6, 0)  (7, 0) row 3: (0, 0)  (1, 0)  (2, 0)  (3, 1)  (4,
>> 1)  (5, 1)  (6, 1)  (7, 0) row 4: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 1)
>> (5, 1)  (6, 1)  (7, 1)*
>> which is satisfactory, but once I use *MatMPIAIJSetPreallocation(A,0,d_nnz,0,o_nnz);
>> *the code encounters a runtime error. And throws a malloc error as -
>>
>>
>> *[0]PETSC ERROR: New nonzero at (0,4) caused a mallocUse MatSetOption(A,
>> MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check*
>>
>
> Print out your dnz and onz. You can clearly see they are wrong. The error
> is your condition which I pointed out above.
>
>    Matt
>
>
>> Thanks
>>
>> ----
>> John Albequerque.
>>
>>
>> On Fri, Feb 19, 2016 at 4:17 PM, Matthew Knepley <knepley at gmail.com>
>> wrote:
>>
>>> On Fri, Feb 19, 2016 at 4:34 AM, John Albequerque <johncfdcfd at gmail.com>
>>> wrote:
>>>
>>>> Currently I have used single processor. And without the Preallocation
>>>> it works fine. And gives me the correct output as well. I have posted the
>>>> full code for reference.
>>>> *Here:* http://pastebin.com/kWUGHqSM
>>>>
>>>
>>> Look at the last row. Your condition 'j >= i' will produce no
>>> off-diagonal rows here, but
>>> clearly you have them, and this is the error you are getting.
>>>
>>>    Matt
>>>
>>>
>>>> On Fri, Feb 19, 2016 at 3:01 PM, Matthew Knepley <knepley at gmail.com>
>>>> wrote:
>>>>
>>>>> On Fri, Feb 19, 2016 at 3:27 AM, John Albequerque <
>>>>> johncfdcfd at gmail.com> wrote:
>>>>>
>>>>>> I came up with this could you please have a look at it as I am not
>>>>>> getting it. I am getting an error
>>>>>>
>>>>>>
>>>>>>
>>>>>> *New nonzero at (0,4) caused a malloc*http://pastebin.com/ZxT7SWtc
>>>>>>
>>>>>> Could you please have a look at it.
>>>>>>
>>>>>
>>>>> It looks like you are only allocating the upper triangle:
>>>>>
>>>>> if((j-i<=3) && (j>=i))
>>>>>             values[(i-low)*nc+j]=1;
>>>>> else
>>>>> values[(i-low)*nc+j]=0;
>>>>>
>>>>>    Matt
>>>>>
>>>>>
>>>>>> ---------------
>>>>>> Thanks,
>>>>>> John Albequerque
>>>>>>
>>>>>>
>>>>>> On Fri, Feb 19, 2016 at 1:25 PM, Matthew Knepley <knepley at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> On Fri, Feb 19, 2016 at 1:50 AM, John Albequerque <
>>>>>>> johncfdcfd at gmail.com> wrote:
>>>>>>>
>>>>>>>> Could someone help me setting up this matrix i.e from preallocation
>>>>>>>> to Set Values for an MPIAIJ matrix which has its entries.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> *1  1  1  1  0  0  0  00  1  1  1  1  0  0  00  0  1  1  1  1  0
>>>>>>>> 00  0  0  1  1  1  1  00  0  0  0  1  1  1  1*
>>>>>>>>
>>>>>>>> I am trying to do it from 3 days now but not able to figure it out.
>>>>>>>> Could someone please help me do this.
>>>>>>>>
>>>>>>>
>>>>>>> It will be enough to say that each row has 3 off-diagonal values, so
>>>>>>> you can use the simplified preallocation rather
>>>>>>> than giving a value for each row individually.
>>>>>>>
>>>>>>>    Matt
>>>>>>>
>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> ----
>>>>>>>> John Albequerque.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> 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
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> 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
>>>
>>
>>
>
>
> --
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160219/5400f534/attachment.html>


More information about the petsc-users mailing list