<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 12, 2014 at 11:55 AM, Mari Pecha <span dir="ltr"><<a href="mailto:pecha.mari@gmail.com" target="_blank">pecha.mari@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 bgcolor="#FFFFFF" text="#000000">
    Heurekaaaa, it works!!!!! Thank you so much! :)<br></div></blockquote><div><br></div><div>Cool.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">

    My final code I've add to attachements for checking.<br>
    <br>
    So, can I ask now how can I create my own scatter?<br></div></blockquote><div><br></div><div>I would not worry about that until after you have profiled your code to see what takes</div><div>the most time, using -log_summary.</div>
<div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">

    <br>
    Thank you for your time<br>
    Mari<br>
    <br>
    <div>On 12.8.2014 18:40, Matthew Knepley
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Tue, Aug 12, 2014 at 11:30 AM,
            Mari Pecha <span dir="ltr"><<a href="mailto:pecha.mari@gmail.com" target="_blank">pecha.mari@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 bgcolor="#FFFFFF" text="#000000"> So, I've tried
                options with VecScatterCreateToZero but I got error
                message <br>
                <br>
                [0]PETSC ERROR: Nonconforming object sizes<br>
                [0]PETSC ERROR: Vector wrong size 10 for scatter 2
                (scatter reverse and vector to != ctx from size)<br>
                <br>
                I'm not sure what is wrong. Could you help me? My code
                I've add to attachements.<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Your vector arguments for the scatter are reversed. You
              are scattering from the local vector with pixel data</div>
            <div>to the global vector.</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"> Thank you for your
                time<br>
                Mari<br>
                <br>
                P.S: I use PETSc 3.5 and SCATTER_BACKWARD is changed to
                SCATTER_REVERSE.<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Yes, that is right.</div>
            <div><br>
            </div>
            <div>    Matt</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000">
                <div>On 12.8.2014 17:53, Matthew Knepley wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div class="gmail_extra">
                      <div class="gmail_quote">On Tue, Aug 12, 2014 at
                        9:22 AM, Mari Pecha <span dir="ltr"><<a href="mailto:pecha.mari@gmail.com" target="_blank">pecha.mari@gmail.com</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000"> Okay. I
                            understand my explanation it sees to be
                            chaotic. I try to describe my problem on
                            simple simple.<br>
                            <br>
                            Process with rank zero loads grayscale image
                            from OpenCV library then I'd like to
                            distribute values of pixels to grid (DMDA).
                            And I can't find any solution for this
                            problem.<br>
                          </div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>The right thing to do is to create a custom
                          scatter for this case. However, you can do
                          this in two parts. First,</div>
                        <div>read it in on proc 0, and then scatter to
                          all procs using</div>
                        <div><br>
                        </div>
                        <div>  <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreateToZero.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreateToZero.html</a></div>

                        <div><br>
                        </div>
                        <div>where you SCATTER_BACKWARD. Then use</div>
                        <div><br>
                        </div>
                        <div>  <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMDANaturalToGlobalBegin.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMDANaturalToGlobalBegin.html</a></div>

                        <div><br>
                        </div>
                        <div>to permute from the natural ordering that
                          you read in to the PETSc ordering. You could
                          do this in one</div>
                        <div>step if you allow each process to read its
                          piece of the vector independently.</div>
                        <div><br>
                        </div>
                        <div>   Thanks,</div>
                        <div><br>
                        </div>
                        <div>      Matt</div>
                        <div> <br>
                        </div>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000"> <br>
                            Thank you<br>
                            Mari<br>
                            <br>
                            <div>On 12.8.2014 16:12, Matthew Knepley
                              wrote:<br>
                            </div>
                            <blockquote type="cite">
                              <div dir="ltr">
                                <div class="gmail_extra">
                                  <div class="gmail_quote">On Tue, Aug
                                    12, 2014 at 8:53 AM, Mari Pecha <span dir="ltr"><<a href="mailto:pecha.mari@gmail.com" target="_blank">pecha.mari@gmail.com</a>></span>
                                    wrote:<br>
                                    <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Good


                                      morning,<br>
                                      <br>
                                      I'm Mari and I'm beginner PETSc
                                      user and I'd like to ask about
                                      tough problem, especially for me.<br>
                                      I solve problem of data-set
                                      distribution, which are saved only
                                      on zero-rank process, to DMDA
                                      global vector. It means that every
                                      process stores a appropriate
                                       subset of data-set. I used
                                      DMDAGlobalToNaturalAllCreate and
                                      DMDANaturalAllToGlobalCreate
                                      function, and then VecScatterBegin
                                      and VecScatterEnd functions ...
                                      see please code below<br>
                                    </blockquote>
                                    <div><br>
                                    </div>
                                    <div>I have no idea what you really
                                      want to do. How about describing
                                      your problem with</div>
                                    <div>2 procs and 3 values per proc.</div>
                                    <div> </div>
                                    <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                                          ...<br>
                                      <br>
                                          ierr =
                                      DMDAGlobalToNaturalAllCreate( da,
                                      &tolocalall   );
                                      CHKERRQ(ierr);<br>
                                          ierr =
                                      DMDANaturalAllToGlobalCreate( da,
                                      &fromlocalall );
                                      CHKERRQ(ierr);<br>
                                      <br>
                                          if( rank == 0  )<br>
                                          {<br>
                                      <br>
                                              ierr = VecCreateSeq(
                                      PETSC_COMM_SELF, SIZE,
                                      &localall );<br>
                                      <br>
                                              ierr = VecScatterBegin(
                                      tolocalall, x, localall,
                                      ADD_VALUES, SCATTER_FORWARD_LOCAL
                                      ); CHKERRQ(ierr);<br>
                                              ierr = VecScatterEnd(  
                                      tolocalall, x, localall,
                                      ADD_VALUES, SCATTER_FORWARD_LOCAL
                                      ); CHKERRQ(ierr);<br>
                                    </blockquote>
                                    <div><br>
                                    </div>
                                    <div>This will not work since you
                                      have a collective call
                                      (VecScatterBegin) inside if(!rank)</div>
                                    <div><br>
                                    </div>
                                    <div>   Matt</div>
                                    <div> </div>
                                    <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                                              ierr = VecGetArray( x,
                                      &vlocal ); CHKERRQ(ierr);<br>
                                      <br>
                                              PetscInt s;<br>
                                              VecGetSize( localall,
                                      &s );<br>
                                      <br>
                                              ierr = VecView( localall,
                                      PETSC_VIEWER_STDOUT_SELF );
                                      CHKERRQ( ierr );<br>
                                      <br>
                                              //create data on zero rank
                                      process<br>
                                              for ( int i = 0; i < s;
                                      i++) *vlocal++ = i;<br>
                                      <br>
                                              ierr = VecRestoreArray(
                                      localall, &vlocal );
                                      CHKERRQ(ierr);<br>
                                      <br>
                                              ierr =
                                      VecScatterBegin(fromlocalall,
                                      localall, x, ADD_VALUES,
                                      SCATTER_FORWARD_LOCAL );
                                      CHKERRQ(ierr);<br>
                                              ierr = VecScatterEnd(
                                       fromlocalall, localall, x,
                                      ADD_VALUES, SCATTER_FORWARD_LOCAL
                                      ); CHKERRQ(ierr);<br>
                                          }<br>
                                      <br>
                                          ....<br>
                                      <br>
                                      But the piece of code gets and
                                      distributes only vector-values
                                      belong to zero-rank process. So, I
                                      haven't any idea how can I solve
                                      my problem only with PETSc
                                      functions. I'd like to get all
                                      values from global vector to
                                      zero-rank process and put back all
                                      data-set only from zero-rank to
                                      global vector. Can you help me,
                                      please?<br>
                                      <br>
                                      Thanks for your response<span><font color="#888888"><br>
                                          Mari<br>
                                        </font></span></blockquote>
                                  </div>
                                  <br>
                                  <br clear="all">
                                  <span><font color="#888888"> <span><font color="#888888">
                                          <div><br>
                                          </div>
                                          -- <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 </font></span></font></span></div>
                                <span><font color="#888888"> </font></span></div>
                              <span><font color="#888888">
                                </font></span></blockquote>
                            <span><font color="#888888">
                                <br>
                              </font></span></div>
                          <span><font color="#888888"> </font></span></blockquote>
                        <span><font color="#888888"> </font></span></div>
                      <span><font color="#888888"> <br>
                          <br clear="all"><span class="HOEnZb"><font color="#888888">
                          <div><br>
                          </div>
                          -- <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 </font></span></font></span></div><span class="HOEnZb"><font color="#888888">
                  </font></span></div><span class="HOEnZb"><font color="#888888">
                </font></span></blockquote><span class="HOEnZb"><font color="#888888">
                <br>
              </font></span></div><span class="HOEnZb"><font color="#888888">
            </font></span></blockquote><span class="HOEnZb"><font color="#888888">
          </font></span></div><span class="HOEnZb"><font color="#888888">
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <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
        </font></span></div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div><br><br clear="all"><div><br></div>-- <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
</div></div>