What a relief that no one castigated me for including a &quot;goto&quot;!&nbsp; I&#39;m teaching out of Kupferschmid&#39;s &quot;Classical Fortran&quot;, and he makes a rather compelling case that goto s actually more pedagogically sound (for beginners) than &quot;do while&quot;<br>
<br>Successive steps in the equilibration are time-dependant, so they&#39;re IMPOSSIBLE to parallelize.&nbsp; I suppose I could get around the re-initialization by including a &quot;SINGLE&quot; directive around the iteration control structure.<br>
<br>Nathan<br><br><div class="gmail_quote">On Fri, Nov 21, 2008 at 9:05 AM,  <span dir="ltr">&lt;<a href="mailto:rssr@lncc.br">rssr@lncc.br</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi All<br><br>I thing the problem could be the&nbsp; convergence
&quot;loop&quot; test and the criation of threads<br>
<pre><div class="Ih2E3d">10 converged = 1<br>!$OMP PARALLEL<br>!$OMP DO<br></div>.....<div class="Ih2E3d"><br>!$OMP ENDDO<br>!$OMP END PARALLEL<br>if(converged.eq.0) then<br>  
     goto 10<br>endif<br><br></div>Each time you &quot;goto 10&quot; <br>the compiler &quot;create&quot; and &quot;initialize&quot; the threads
and this is time comsuming.<br>try to change the convergence test to a
reduce operation this will <br>take time but not some much as !$OMP
PARALLEL </pre>
I hope its help<br><br>Renato Silva<div><div></div><div class="Wj3C7c"><br><br><br>&gt; Hi All,<br>&gt; <br>&gt; I&#39;m getting to the end of a semester of computational
physics at my<br>&gt; institution, and thought it would be fin to close
the semester with a<br>&gt; discussion of parallel programming. 
Initially, I was simply planning to<br>&gt; discuss MPI, but while
reading through the gfortran man page I realized<br>&gt; that<br>&gt;
gcc now supports OpenMP directives.<br>&gt; <br>&gt; Given that the
machines my students are using are all dual core, I started<br>&gt;
working on a simple example that I hoped would show a nice speedup from<br>&gt; the<br>&gt; &quot;easy&quot; library.<br>&gt; <br>&gt; The
specific problem I&#39;m working on is a 2-d solution to the laplace<br>&gt;
equation (electrostatics).  The bulk of the computation is a recursion<br>&gt; relation, applied to elements of a 2-d array, according to the
following<br>&gt; snippet.<br>&gt; <br>&gt; Of course, by now I
should know that &quot;simple&quot; never really is.  When I<br>&gt;
compile with gfortran and run with 1 or 2 cores (ie, OMP_NUM_THREADS=2,<br>&gt; export OMP_NUM_THREADS) there is basically no difference in
execution<br>&gt; time.<br>&gt; <br>&gt; <br>&gt; Any suggestions?
 I figured that this would be a simple example to<br>&gt; parallelize. 
Is there a better example for OpenMP parallelization?  Also,<br>&gt; is
there something obvious I&#39;m missing in the example below?<br>&gt; <br>&gt; Nathan Moore<br>&gt; <br>&gt; integer,parameter::Nx=1000<br>&gt; integer,parameter::Ny=1000<br>&gt; real*8 v(Nx,Ny)<br>&gt;
integer boundary(Nx,Ny)<br>&gt; <br>&gt; v_cloud = -1.0e-4<br>&gt;
v_ground = 0.d0<br>&gt; <br>&gt; convergence_v =
dabs(v_ground-v_cloud)/(1.d0*Ny*Ny)<br>&gt; <br>&gt; ! initialize the
the boundary conditions<br>&gt; do i=1,Nx<br>&gt;         do j=1,Ny<br>&gt;                 v_y = v_ground + (v_cloud-v_ground)*(j*dy/Ly)<br>&gt;                 boundary(i,j)=0<br>&gt;                 v(i,j) =
v_y<br>&gt;                 ! we need to ensure that the edges of the
domain are held<br>&gt; as<br>&gt; boundary<br>&gt;                
if(i.eq.0 .or. i.eq.Nx .or. j.eq.0 .or. j.eq.Ny) then<br>&gt;           
             boundary(i,j)=1<br>&gt;                 endif<br>&gt;    
    end do<br>&gt; end do<br>&gt; <br>&gt; 10 converged = 1<br>&gt; !$OMP PARALLEL<br>&gt; !$OMP DO<br>&gt;         do i=1,Nx<br>&gt;                 do j=1,Ny<br>&gt;                        
if(boundary(i,j).eq.0) then<br>&gt;                                
old_v = v(i,j)<br>&gt;                                 v(i,j) =<br>&gt; 0.25*(v(i-1,j)+v(i+1,j)+v(i,j+1)+v(i,j-1))<br>&gt;               
                 dv = dabs(old_v-v(i,j))<br>&gt;                        
        if(dv.gt.convergence_v) then<br>&gt;                            
            converged = 0<br>&gt;                                
endif<br>&gt;                         endif<br>&gt;                
end do<br>&gt;         end do<br>&gt; !$OMP ENDDO<br>&gt; !$OMP END
PARALLEL<br>&gt; if(converged.eq.0) then<br>&gt;         goto 10<br>&gt; endif<br></div></div><div><div></div><div class="Wj3C7c">&gt; _______________________________________________<br>&gt; Beowulf mailing list, <a href="mailto:Beowulf@beowulf.org" target="_blank">Beowulf@beowulf.org</a><br>
&gt; To change your
subscription (digest mode or unsubscribe) visit<br>&gt;
<a href="http://www.beowulf.org/mailman/listinfo/beowulf" target="_blank">http://www.beowulf.org/mailman/listinfo/beowulf</a><br>&gt;</div></div></blockquote></div><br><br clear="all"><br>-- <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - - <br>
Nathan Moore<br>Assistant Professor, Physics<br>Winona State University<br>AIM: nmoorewsu <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - -<br>
<br />-- 
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.