<div dir="ltr"><div dir="ltr">On Wed, Jun 10, 2020 at 12:07 PM Eda Oktay <<a href="mailto:eda.oktay@metu.edu.tr">eda.oktay@metu.edu.tr</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Der Matt,<br>
<br>
When I looked at the results, I found that there are some problems I<br>
couldn't understand.<br>
<br>
First of all, I am working on a 72*4 matrix and as I said before, I<br>
want to have 72 different vectors having size 4 each, whose elements<br>
consist of the elements in the same row. And of course, all vectors<br>
should be in all processors (currently I am using 4 processors).<br>
<br>
When I use your scatter code, the output vector is divided into 4<br>
parts for 4 processors and each vector consists of 18 row vectors<br>
whose elements are arranged in a way that if I want to find zeroth row<br>
vector, its elements are located in 0th,18th,36th,54th elements.<br></blockquote><div><br></div><div>Was the global size of the vector you wrapped around the dense matrix 72*4?</div><div><br></div><div>If you use CreateToAll(), it will make a vector on each process which has the global size of the original vector.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
So, isn't scatter's goal is to scatter all values to all processors?<br>
<br>
Furthermore, I am trying to use my vectors in that way but isn't there<br>
any possible way that I can reach my goal entirely?<br>
<br>
Thanks so much for your help,<br>
<br>
Eda<br>
<br>
Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>, 10 Haz 2020 Çar, 18:11 tarihinde<br>
şunu yazdı:<br>
><br>
> On Wed, Jun 10, 2020 at 10:09 AM Eda Oktay <<a href="mailto:eda.oktay@metu.edu.tr" target="_blank">eda.oktay@metu.edu.tr</a>> wrote:<br>
>><br>
>> Dear Matt,<br>
>><br>
>> I have one last question I believe. Up to creating a dense matrix I<br>
>> did what you've suggested. Thank you so much for that.<br>
>><br>
>> I created a new dense matrix. Now, how should I wrap each vector in a<br>
>> MatDense again? I mean, what is wrapping vectors in a matrix? To put<br>
>> each of them again as rows?<br>
><br>
><br>
> I thought you need a dense matrix for something, since you started with one. If you<br>
> do not, just do VecGetArray() on the vector from CreateToAll and use the values.<br>
><br>
> Thanks,<br>
><br>
> Matt<br>
><br>
>><br>
>> Thanks!<br>
>><br>
>> Eda<br>
>><br>
>> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>, 10 Haz 2020 Çar, 16:16 tarihinde<br>
>> şunu yazdı:<br>
>> ><br>
>> > On Wed, Jun 10, 2020 at 9:08 AM Eda Oktay <<a href="mailto:eda.oktay@metu.edu.tr" target="_blank">eda.oktay@metu.edu.tr</a>> wrote:<br>
>> >><br>
>> >> Dear Matt,<br>
>> >><br>
>> >> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>, 10 Haz 2020 Çar, 16:03 tarihinde<br>
>> >> şunu yazdı:<br>
>> >> ><br>
>> >> > On Wed, Jun 10, 2020 at 8:56 AM Eda Oktay <<a href="mailto:eda.oktay@metu.edu.tr" target="_blank">eda.oktay@metu.edu.tr</a>> wrote:<br>
>> >> >><br>
>> >> >> Hi all,<br>
>> >> >><br>
>> >> >> I am trying to get all the rows of a parallel matrix as individual<br>
>> >> >> vectors. For instance, if I have 72*4 matrix, I want to get 72<br>
>> >> >> different vectors having size 4.<br>
>> >> >><br>
>> >> >> As far as I understood, MatGetRow is only for local rows, so<br>
>> >> >> MatGetOwnershipRange is used, however, when I tried this one, I<br>
>> >> >> couldn't get the whole and desired row vectors.<br>
>> >> >><br>
>> >> >> In MatGetRow explanation, it is written that I should use<br>
>> >> >> MatCreateSubMatrices first, then use MatGetRow. But I couldn't<br>
>> >> >> understand to which extent I should create submatrices. I just need to<br>
>> >> >> have all 72 rows as 72 different vectors each having 4 elements.<br>
>> >> ><br>
>> >> ><br>
>> >> > 1) For sparse matrices, the storage is always divided by row, so that values can only be retrieved for local rows with MatGetRow()<br>
>> >> ><br>
>> >> > 2) Is this matrix sparse? It sounds like it is dense.<br>
>> >><br>
>> >> Matrix is dense.<br>
>> >><br>
>> >> ><br>
>> >> > 3) Are you asking to get all matrix values on all processes? If so, I think the easiest thing to do is first wrap a Vec around the<br>
>> >> > values, then use VecScatterToAll(), then wrap each one in a MatDense again.<br>
>> >><br>
>> >> Yes, I want all row vectors on all processes. In a dense matrix,<br>
>> >> should I still wrap a Vec around the values? I know I should use<br>
>> >> scatter but I couldn't even wrap a Vec around them.<br>
>> ><br>
>> ><br>
>> > I would do<br>
>> ><br>
>> > MatGetSize(&N);<br>
>> > MatGetLocalSize(&m);<br>
>> > <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDenseGetArray.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDenseGetArray.html</a><br>
>> > <create vector of local size m*N><br>
>> > <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecPlaceArray.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecPlaceArray.html</a><br>
>> > <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreateToAll.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreateToAll.html</a><br>
>> > <do scatter><br>
>> > <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecResetArray.html#VecResetArray" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecResetArray.html#VecResetArray</a><br>
>> > <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateDense.html" rel="noreferrer" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateDense.html</a><br>
>> > <use it><br>
>> > <destroy matrix><br>
>> > <destroy vector from CreateToAll><br>
>> ><br>
>> > Thanks,<br>
>> ><br>
>> > Matt<br>
>> ><br>
>> >><br>
>> >> Thanks so much!<br>
>> >><br>
>> >> Eda<br>
>> >><br>
>> >> ><br>
>> >> > Thanks,<br>
>> >> ><br>
>> >> > Matt<br>
>> >> ><br>
>> >> >><br>
>> >> >> Thanks!<br>
>> >> >><br>
>> >> >> Eda<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > --<br>
>> >> > What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
>> >> > -- Norbert Wiener<br>
>> >> ><br>
>> >> > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
>> > -- Norbert Wiener<br>
>> ><br>
>> > <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
><br>
><br>
><br>
> --<br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
><br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>