On Fri, Aug 10, 2012 at 7:57 AM, Koki Imada <span dir="ltr"><<a href="mailto:koki.imada@york.ac.uk" target="_blank">koki.imada@york.ac.uk</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I'm fairly new to PETSc/MPI programming, and I'm stuck with the use of barriers. I have a code of the following form:<br>
<br>
0. Initialise PETSc...<br>
1. Processor 1 (or the "root") reports to user (using "print" statement).<br>
2. "Root" does some work, while all other processors do nothing.<br>
3. "Root" allocates array "A".<br>
4. All processors does some work on array "A".<br>
5. "Root" deallocates array "A".<br>
6. PETSc is finalised.<br>
<br>
In order for this to work, I would like to put barriers between steps 3&4, and steps 4&5, and also between steps 2&3 (optional).<br>
<br>
Simply putting "call MPI_barrier(MPI_comm_world,<u></u>ierr)" between the steps doesn't do anything and I know this doesn't work due to the lack of communication between the processors (or otherwise), but I have never been able to find the "correct" way to implement the barrier...<br>
<br>
If somebody could show me how to correctly implement the barrier (either MPI or PETSc) between the steps as described above, I will be most grateful.<br></blockquote><div><br></div><div>You really need to read <a href="http://www.mcs.anl.gov/research/projects/mpi/usingmpi/">http://www.mcs.anl.gov/research/projects/mpi/usingmpi/</a>. Different processes</div>
<div>do not have access to the same memory.</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 Regards,<br>
<br>
Koki<br>
<br>
<br>
</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<br>