Hi All<br /><br />I thing the problem could be the convergence
"loop" 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 "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<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 />> _______________________________________________<br
/>> Beowulf mailing list, Beowulf@beowulf.org<br />> To change your
subscription (digest mode or unsubscribe) visit<br />>
http://www.beowulf.org/mailman/listinfo/beowulf<br />>