<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 25, 2014 at 2:43 AM, Filippo Leonardi <span dir="ltr"><<a href="mailto:filippo.leonardi@sam.math.ethz.ch" target="_blank">filippo.leonardi@sam.math.ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Let's say I have some independent DMDAs, created as follows:<br>
<br>
MPI_Comm_split(MPI_COMM_WORLD, comm_rank % 2, 0, &newcomm);<br>
<br>
DM da;<br>
DMDACreate2d(newcomm, DM_BOUNDARY_PERIODIC, DM_BOUNDARY_NONE,<br>
DMDA_STENCIL_BOX ,50, 50, PETSC_DECIDE, PETSC_DECIDE,<br>
1, 1, NULL, NULL,&da);<br>
<br>
For instance for 4 processors I get 2 DMDA's. Now, I want to reduce (in the<br>
sense of MPI) the global/local DMDA vectors to only one of the MPI groups (say<br>
group 0). Is there an elegant way (e.g. with Scatters) to do that?<br>
<br>
My current implementation would be: get the local array on each process and<br>
reduce (with MPI_Reduce) to the root of each partition.<br>
<br>
DMDA for Group 1:<br>
+------+------+<br>
| 0 | 1 |<br>
| | |<br>
+------+------+<br>
| 2 | 3 |<br>
| | |<br>
+------+------+<br>
DMDA for Group 2:<br>
+------+------+<br>
| 4 | 5 |<br>
| | |<br>
+------+------+<br>
| 6 | 7 |<br>
| | |<br>
+------+------+<br>
<br>
Reduce rank 0 and 4 to rank 0.<br>
Reduce rank 1 and 5 to rank 1.<br>
Reduce rank 2 and 6 to rank 2.<br>
Reduce rank 3 and 7 to rank 3.<br>
<br>
Clearly this implementation is cumbersome. Any idea?<br></blockquote><div><br></div><div>I think that is the simplest way to do it, and its is 3 calls VecGet/RestoreArray()</div><div>and MPI_Reduce().</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">
Best,<br>
Filippo</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>