What a relief that no one castigated me for including a "goto"! I'm teaching out of Kupferschmid's "Classical Fortran", and he makes a rather compelling case that goto s actually more pedagogically sound (for beginners) than "do while"<br>
<br>Successive steps in the equilibration are time-dependant, so they're IMPOSSIBLE to parallelize. I suppose I could get around the re-initialization by including a "SINGLE" 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"><<a href="mailto:rssr@lncc.br">rssr@lncc.br</a>></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 convergence
"loop" 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 "goto 10" <br>the compiler "create" and "initialize" 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>> Hi All,<br>> <br>> I'm getting to the end of a semester of computational
physics at my<br>> institution, and thought it would be fin to close
the semester with a<br>> discussion of parallel programming.
Initially, I was simply planning to<br>> discuss MPI, but while
reading through the gfortran man page I realized<br>> that<br>>
gcc now supports OpenMP directives.<br>> <br>> Given that the
machines my students are using are all dual core, I started<br>>
working on a simple example that I hoped would show a nice speedup from<br>> the<br>> "easy" library.<br>> <br>> The
specific problem I'm working on is a 2-d solution to the laplace<br>>
equation (electrostatics). The bulk of the computation is a recursion<br>> relation, applied to elements of a 2-d array, according to the
following<br>> snippet.<br>> <br>> Of course, by now I
should know that "simple" never really is. When I<br>>
compile with gfortran and run with 1 or 2 cores (ie, OMP_NUM_THREADS=2,<br>> export OMP_NUM_THREADS) there is basically no difference in
execution<br>> time.<br>> <br>> <br>> Any suggestions?
I figured that this would be a simple example to<br>> parallelize.
Is there a better example for OpenMP parallelization? Also,<br>> is
there something obvious I'm missing in the example below?<br>> <br>> Nathan Moore<br>> <br>> integer,parameter::Nx=1000<br>> integer,parameter::Ny=1000<br>> real*8 v(Nx,Ny)<br>>
integer boundary(Nx,Ny)<br>> <br>> v_cloud = -1.0e-4<br>>
v_ground = 0.d0<br>> <br>> convergence_v =
dabs(v_ground-v_cloud)/(1.d0*Ny*Ny)<br>> <br>> ! initialize the
the boundary conditions<br>> do i=1,Nx<br>> do j=1,Ny<br>> v_y = v_ground + (v_cloud-v_ground)*(j*dy/Ly)<br>> boundary(i,j)=0<br>> v(i,j) =
v_y<br>> ! we need to ensure that the edges of the
domain are held<br>> as<br>> boundary<br>>
if(i.eq.0 .or. i.eq.Nx .or. j.eq.0 .or. j.eq.Ny) then<br>>
boundary(i,j)=1<br>> endif<br>>
end do<br>> end do<br>> <br>> 10 converged = 1<br>> !$OMP PARALLEL<br>> !$OMP DO<br>> do i=1,Nx<br>> do j=1,Ny<br>>
if(boundary(i,j).eq.0) then<br>>
old_v = v(i,j)<br>> v(i,j) =<br>> 0.25*(v(i-1,j)+v(i+1,j)+v(i,j+1)+v(i,j-1))<br>>
dv = dabs(old_v-v(i,j))<br>>
if(dv.gt.convergence_v) then<br>>
converged = 0<br>>
endif<br>> endif<br>>
end do<br>> end do<br>> !$OMP ENDDO<br>> !$OMP END
PARALLEL<br>> if(converged.eq.0) then<br>> goto 10<br>> endif<br></div></div><div><div></div><div class="Wj3C7c">> _______________________________________________<br>> Beowulf mailing list, <a href="mailto:Beowulf@beowulf.org" target="_blank">Beowulf@beowulf.org</a><br>
> To change your
subscription (digest mode or unsubscribe) visit<br>>
<a href="http://www.beowulf.org/mailman/listinfo/beowulf" target="_blank">http://www.beowulf.org/mailman/listinfo/beowulf</a><br>></div></div></blockquote></div><br><br clear="all"><br>-- <br>- - - - - - - - - - - - - - - - - - - - - <br>
Nathan Moore<br>Assistant Professor, Physics<br>Winona State University<br>AIM: nmoorewsu <br>- - - - - - - - - - - - - - - - - - - - -<br>