<div dir="ltr">Hi, I have a follow up question on this. <div><br></div><div>Now, I'm trying to do a scatter and permutation of the vector. Under the same setup as the original example, here are the new Start and Finish states I want to achieve:</div><div><div> Start Finish</div><div>Proc | Entries Proc | Entries</div><div> 0 | 0,...,8 0 | 0, 12, 24</div><div> 1 | 9,...,17 1 | 1, 13, 25<br></div><div> 2 | 18,...,26 2 | 2, 14, 26<br></div><div> 3 | 27,...,35 3 | 3, 15, 27<br></div><div> 4 | None 4 | 4, 16, 28<br></div><div> 5 | None 5 | 5, 17, 29<br></div><div> 6 | None 6 | 6, 18, 30<br></div><div> 7 | None 7 | 7, 19, 31<br></div><div> 8 | None 8 | 8, 20, 32<br></div><div> 9 | None 9 | 9, 21, 33<br></div><div> 10 | None 10 | 10, 22, 34<br></div><div> 11 | None 11 | 11, 23, 35</div></div><div><br></div><div>So far, I've tried to use ISCreateGeneral(), with each process giving an idx array corresponding to the indices it wants (i.e. idx on P0 looks like [0,12,24] P1 -> [1,13, 25], and so on). </div><div>Then I use this to create the VecScatter with VecScatterCreate(x, is, y, NULL, &scatter).</div><div><br></div><div>However, when I try to do the scatter, I get some illegal memory access errors. </div><div><br></div><div>Is there something wrong with how I define the index sets?</div><div><br></div><div>Thanks,</div><div>Sreeram</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 5, 2023 at 12:57 PM Sreeram R Venkat <<a href="mailto:srvenkat@utexas.edu">srvenkat@utexas.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you. This works for me.<div><br></div><div>Sreeram</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 4, 2023 at 6:41 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="line-height:21px"><div><div style="line-height:21px">Hi, Sreeram,<br>You can try this code. Since x, y are both MPI vectors, we just need to say we want to scatter x[0:N] to y[0:N]. The 12 index sets with your example on the 12 processes would be [0..8], [9..17], [18..26], [27..35], [], ..., []. Actually, you can do it arbitrarily, say, with 12 index sets [0..17], [18..35], .., []. PETSc will figure out how to do the communication. <div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> PetscInt rstart, rend, N;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> IS ix;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecScatter vscat;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> Vec y;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> MPI_Comm comm;</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecType type;</div><br><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> PetscObjectGetComm((PetscObject)x, &comm);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecGetType(x, &type);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecGetSize(x, &N);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecGetOwnershipRange(x, &rstart, &rend);</div><br><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecCreate(comm, &y);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecSetSizes(y, <span style="color:rgb(0,0,255)">PETSC_DECIDE</span>, N);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecSetType(y, type);</div><br><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> ISCreateStride(PetscObjectComm((PetscObject)x), rend - rstart, rstart, <span style="color:rgb(9,134,88)">1</span>, &ix);</div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"> VecScatterCreate(x, ix, y, ix, &vscat);</div></div></div><div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><br></div></div><div><div dir="ltr" class="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 4, 2023 at 6:03 PM Sreeram R Venkat <<a href="mailto:srvenkat@utexas.edu" target="_blank">srvenkat@utexas.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr" class="gmail_signature"><div dir="ltr"><div style="color:rgb(34,34,34)">Suppose I am running on 12 processors, and I have a vector "v" of size 36 partitioned over the first 4. v still uses the PETSC_COMM_WORLD, so it has a layout of (9, 9, 9, 9, 0, 0, ..., 0). Now, I would like to repartition it over all 12 processors, so that the layout becomes (3, 3, 3, ..., 3). I've been trying to use VecScatter to do this, but I'm not sure what IndexSets to use for the sender and receiver.</div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">The result I am trying to achieve is this:</div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">Assume the vector is v = <0, 1, 2, ..., 35> </div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)"> Start Finish</div><div style="color:rgb(34,34,34)">Proc | Entries Proc | Entries</div><div style="color:rgb(34,34,34)"> 0 | 0,...,8 0 | 0, 1, 2</div><div style="color:rgb(34,34,34)"> 1 | 9,...,17 1 | 3, 4, 5<br></div><div style="color:rgb(34,34,34)"> 2 | 18,...,26 2 | 6, 7, 8<br></div><div style="color:rgb(34,34,34)"> 3 | 27,...,35 3 | 9, 10, 11<br></div><div style="color:rgb(34,34,34)"> 4 | None 4 | 12, 13, 14<br></div><div style="color:rgb(34,34,34)"> 5 | None 5 | 15, 16, 17<br></div><div style="color:rgb(34,34,34)"> 6 | None 6 | 18, 19, 20<br></div><div style="color:rgb(34,34,34)"> 7 | None 7 | 21, 22, 23<br></div><div style="color:rgb(34,34,34)"> 8 | None 8 | 24, 25, 26<br></div><div style="color:rgb(34,34,34)"> 9 | None 9 | 27, 28, 29<br></div><div style="color:rgb(34,34,34)"> 10 | None 10 | 30, 31, 32<br></div><div style="color:rgb(34,34,34)"> 11 | None 11 | 33, 34, 35<br></div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">Appreciate any help you can provide on this.</div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)">Thanks,</div><div style="color:rgb(34,34,34)">Sreeram</div></div></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>