Hi All<br /><br />I thing the problem could be the&nbsp; convergence
&quot;loop&quot; test and the criation of threads<br />
<pre>10 converged = 1<br />!$OMP PARALLEL<br />!$OMP DO<br />.....<br
/>!$OMP ENDDO<br />!$OMP END PARALLEL<br />if(converged.eq.0) then<br />  
     goto 10<br />endif<br /><br />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<br /><br /><br />&gt; Hi All,<br
/>&gt; <br />&gt; I'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'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'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 />&gt; _______________________________________________<br
/>&gt; Beowulf mailing list, Beowulf@beowulf.org<br />&gt; To change your
subscription (digest mode or unsubscribe) visit<br />&gt;
http://www.beowulf.org/mailman/listinfo/beowulf<br />&gt;<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.