further about MatGetSubMatrix() Re: distribution of submatrix and subvector Re: how to extract a subvector?

Matthew Knepley knepley at gmail.com
Sat Jan 3 12:57:12 CST 2009


On Sat, Jan 3, 2009 at 12:52 PM, Yujie <recrusader at gmail.com> wrote:

> Dear Matthew:
>
> I have checked the description of MatGetSubMatrix() and ISAllGather(). I am
> wondering if isrow is created by MPI_COMM, does it work when iscol is
> obtained based on PETSC_COMM_SELF? thanks.
>
> MatGetSubMatrix(Mat mat,IS isrow,IS iscol,PetscInt csize,MatReuse cll,Mat
> *newmat)
>

1) We do not check the comm of IS in this function

2) If we did we would issue an error code which would be checked by CHKERRQ
and report the mismatch. This
    allows experimentation with the code to uncover these answers.

   Matt


>
> Regards,
>
> Yujie
>
> On Fri, Jan 2, 2009 at 6:20 PM, Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Fri, Jan 2, 2009 at 7:58 PM, Yujie <recrusader at gmail.com> wrote:
>>
>>> Dear Barry:
>>>
>>> When using MatGetSubmatrix() to get a submatrix in parallel mode, to my
>>> knowledge, this function will exact the rows and cols for submatrix. This
>>> submatrix is not redistributed. For example, if there is zero row and zero
>>> col in a process, the row and col of this submatrix in this process are
>>> zero, right?
>>> However, to get a subvector using Vec scatter, the user needs to create
>>> the subvector using MPI_COMM, that is new distribution for subvector is
>>> generated. Just regarding only rows or cols of the submatrix and the
>>> subvector, their distribution should be different even if using the same
>>> index to get them, right? thanks a lot.
>>
>>
>> No. They work exactly the same way.
>>
>>   Matt
>>
>>
>>>
>>> Regards,
>>> Yujie
>>>
>>> On Fri, Jan 2, 2009 at 5:15 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>>
>>>>
>>>>   The ix and iy are always global indices based on where the vector
>>>> lives.
>>>>
>>>>   If you are going from a parallel to parallel vector then both indices
>>>> are "global"
>>>>
>>>>  Barry
>>>>
>>>> On Jan 2, 2009, at 2:21 PM, Yujie wrote:
>>>>
>>>>  Dear Barry:
>>>>>
>>>>> I have a new question about the parameter "iy"(new index set of
>>>>> subvector). To parallel vector, how to provide "ix" and "iy"?
>>>>>
>>>>> Just providing the local index subset for "ix" and "iy"? if it is, it
>>>>> is a little difficult to let the local vector know its global position in
>>>>> the new subvector? If the user needs to provide the global position of local
>>>>> vector for "iy". some MPI communication should be needed, it looks like not
>>>>> a good method. In exacting submatrix, the function hides this problem. could
>>>>> you give me any comments? thanks a lot.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Yujie
>>>>>
>>>>>
>>>>> On Fri, Jan 2, 2009 at 11:46 AM, Barry Smith <bsmith at mcs.anl.gov>
>>>>> wrote:
>>>>>
>>>>>  VecScatter is for this purpose.
>>>>>
>>>>>  Rational: extracting subparts of vectors for ghost points etc takes
>>>>> place many times in a simulation; maybe millions.
>>>>> Thus separating it into a set-up followed by many uses is a  worthwhile
>>>>> optimization. Extracting submatrices occur
>>>>> much less often in a simulation, maybe tens, hundreds or thousands of
>>>>> times so it is not worth the extra complexity
>>>>> of having separate set-up followed by many uses. One could argue that
>>>>> uniformity of design means we should have
>>>>> handled matrices with a MatScatter concept to parallel the Vec
>>>>> approach, but it is too late now :-).
>>>>>
>>>>>  Barry
>>>>>
>>>>>
>>>>> On Jan 2, 2009, at 1:41 PM, Yujie wrote:
>>>>>
>>>>> Like MatGetSubMatrix(), whether is there a function to get a subvector
>>>>> in parallel mode? I have checked some scatter functios, they don't likely
>>>>> work. thanks a lot.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Yujie
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> 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/20090103/aa28af7a/attachment.htm>


More information about the petsc-users mailing list