[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need to scatter from a few of the processors only to the zero processor



Well, I can think of one way right away:

 1) Define global vector, which may have size 0 on some procs

 2) Put your local calculations in this vector. You may need a few vectors for
     handling coordinates, and then values, but I will describe just one.

 3) Use VecScatterCreateToZero() to send it to proc 0:
    http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecScatterCreateToZero.html

There is sample code on that webpage for using it.

  Matt

On 12/13/06, Randall Mackie <randy@xxxxxxxxxxxx> wrote:
At the end of my large 3D computation, I compute the results at, say, 20 locations
in the entire 3D volume. This calculation doesn't happen on every processor, but
only those processors that own that part of the 3D volume.

I want to get those results to the zero processor for output, but I'm unsure
about the best way to do this. My question is can I define a parallel vector
that is smaller than the number of processors, or does that even make sense?

Right now, I'm doing the following, and I'm wondering how to do this with
VecCreateMPI and scattering the results to the zero processor:

!
! See if computation point is owned by this processor:
!
         IF (ii >= xs .and. ii <= xs+xm-1 .and.
      .      jj >= ys .and. jj <= ys+ym-1 .and.
      .      kk >= zs .and. kk <= zs+zm-1 ) THEN

           flg=.true.

           hyijk=xh(idx+3*row+2)
           hyijf=xh(idx+3*(row+gxm*gym)+2)
           hzijk=xh(idx+3*row+3)
           hziek=xh(idx+3*(row+gxm)+3)

etc, do some computations

        END IF

         IF (flg .and. rank /= 0) THEN

           call MPI_Send(esxInterp(iTx,1), 1, MPI_DOUBLE_COMPLEX, 0, 1,
      .                  MPI_COMM_WORLD, ierr)

         ELSE IF (.not. flg .and. rank == 0) THEN

           call MPI_Recv(esxInterp(iTx,1), 1, MPI_DOUBLE_COMPLEX,
      .         MPI_ANY_SOURCE, 1, PETSC_COMM_WORLD, mpi_status, ierr)

         END IF


-- Randall Mackie GSY-USA, Inc. PMB# 643 2261 Market St., San Francisco, CA 94114-1600 Tel (415) 469-8649 Fax (415) 469-5044

California Registered Geophysicist
License No. GP 1034




--
One trouble is that despite this system, anyone who reads journals widely
and critically is forced to realize that there are scarcely any bars to eventual
publication. There seems to be no study too fragmented, no hypothesis too
trivial, no literature citation too biased or too egotistical, no design too
warped, no methodology too bungled, no presentation of results too
inaccurate, too obscure, and too contradictory, no analysis too self-serving,
no argument too circular, no conclusions too trifling or too unjustified, and
no grammar and syntax too offensive for a paper to end up in print. --
Drummond Rennie