<div dir="ltr"><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Sat, Apr 21, 2018 at 6:21 AM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Apr 20, 2018 at 5:02 PM, Junchao Zhang <span dir="ltr"><<a href="mailto:jczhang@mcs.anl.gov" target="_blank">jczhang@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">VecScatter is too heavy (in both coding and runtime) for this simple task. I just want to pad a vector loaded from a PetscViewer to match an MPIBAIJ matrix. Thus the majority is memcpy, with few neighborhood off-processor puts.</div></blockquote><div><br></div></span><div>Now this makes no sense. You want to "pad" a Vec? What does this mean?</div><div><br></div><div>1) You want to extend its length, which none of these can do. You have to VecCreate another vector.</div><div><br></div><div>2) You want some elements to be zero. Just VecSet(v, 0) before setting any elements.</div><div><br></div><div>If its not those, want is the operation?</div></div></div></div></blockquote><div>I don't know why no one reply my post to petsc-users. It has background of this question. The word "pad" is also from comments of this example.</div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Subject: How to adapt vectors to matrices loaded from a viewer</span></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">To: PETSc users list <</span><a href="mailto:petsc-users@mcs.anl.gov" target="_blank" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">petsc-users@mcs.anl.gov</a><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">></span></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div> In a PETSc example (<a href="http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex10.c.html" style="color:rgb(17,85,204)" target="_blank">ex10.c</a>) one MatLoad A and then VecLoad b from a viewer. Since one can change mat block size through option -matload_block_size, the code tries to pad b if A and b's sizes mismatch, using the following test</div></div></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><blockquote style="margin:0 0 0 40px;border:none;padding:0px">186: MatGetSize(A,&M,NULL);</blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">187: VecGetSize(b,&m);</blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">188: if (M != m) { /* Create a new vector b by padding the old one */</blockquote></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div> I think the code is wrong. One has to compare local column size of A and local size of b, and if there is a mismatch on ANY processor, then one has to create a new b.</div></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div> My questions are: Are users supposed to take this complexity? Does PETSc provide a neat way to do that, for example, MatVecLoad(A,b,viewer)</div></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div> </div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div> Matt</div><div><div class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div><div class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349m_-6188412870571003516m_1234420196349846916gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div>
<br><div class="gmail_quote">On Fri, Apr 20, 2018 at 3:57 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Junchao, If you need to access off-process values and put them into a<br>
new vector, you should use VecScatter.<br>
<span class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349m_-6188412870571003516m_1234420196349846916im m_5454446576134974513m_-6041200926101123626m_-6452974991684252349m_-6188412870571003516m_1234420196349846916HOEnZb"><br>
"Smith, Barry F." <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> writes:<br>
<br>
> Setting large contiguous blocks of values is not a common use case. In finite elements the values are not contiguous.<br>
><br>
>> On Apr 20, 2018, at 3:45 PM, Zhang, Junchao <<a href="mailto:jczhang@mcs.anl.gov" target="_blank">jczhang@mcs.anl.gov</a>> wrote:<br>
>> <br>
</span><div class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349m_-6188412870571003516m_1234420196349846916HOEnZb"><div class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349m_-6188412870571003516m_1234420196349846916h5">>> I agree the extra overhead can be small, but users are forced to write a loop where one single line gives the best.<br>
>> <br>
>> --Junchao Zhang<br>
>> <br>
>> On Fri, Apr 20, 2018 at 3:36 PM, Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br>
>> <br>
>> When setting values into matrices and vectors we consider the "extra" overhead of needing to pass in the indices for all the values (instead of being able to set an arbitrary block of values without using indices for each one) to be a minimal overhead that we can live with. <br>
>> <br>
>> Barry<br>
>> <br>
>> <br>
>> > On Apr 20, 2018, at 3:33 PM, Junchao Zhang <<a href="mailto:jczhang@mcs.anl.gov" target="_blank">jczhang@mcs.anl.gov</a>> wrote:<br>
>> > <br>
>> > <br>
>> > On Fri, Apr 20, 2018 at 3:18 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
>> > On Fri, Apr 20, 2018 at 4:10 PM, Junchao Zhang <<a href="mailto:jczhang@mcs.anl.gov" target="_blank">jczhang@mcs.anl.gov</a>> wrote:<br>
>> > To pad a vector, i.e., copy a vector to a new one, I have to call VecSetValue(newb,1,&idx,...) for each element. But to be efficient, what I really needs is to set a block of values in one call. It looks PETSc does not have a routine for that(?). I looked at VecSetValuesBlocked, but it looks it is not for that purpose.<br>
>> > Should we have something like VecSetValuesBlock(Vec v,PetscInt i,PetscInt cnt,PetscScalar *value, InsertMode mode) to set cnt values starting at index i?<br>
>> > <br>
>> > Use VecGetArray().<br>
>> > Did you mean VecGetArray b and newb, do a memcpy from b to new and then restore them? If yes, it does not work since some of the values I want to set might be remote.<br>
>> > E.g, I have 4 processors. b's size is 181 and is distributed as 46, 45,45,45, newb is distributed as 48,45,45,45 to match a matrix of block size 3.<br>
>> > <br>
>> > <br>
>> > Matt<br>
>> > <br>
>> > --Junchao Zhang<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/~k<wbr>nepley/</a><br>
>> > <br>
>> <br>
>> <br>
</div></div></blockquote></div><br></div>
</blockquote></div></div></div><div><div class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349h5"><br><br clear="all"><div><br></div>-- <br><div class="m_5454446576134974513m_-6041200926101123626m_-6452974991684252349m_-6188412870571003516gmail_signature" data-smartmail="gmail_signature"><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.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~k<wbr>nepley/</a><br></div></div></div></div></div>
</div></div></div></div>
</blockquote></div><br></div></div>