[Beowulf] OpenMP on AMD dual core processors

Nathan Moore ntmoore at gmail.com
Thu Nov 20 22:52:47 EST 2008

Hi All,

I'm getting to the end of a semester of computational physics at my
institution, and thought it would be fin to close the semester with a
discussion of parallel programming.  Initially, I was simply planning to
discuss MPI, but while reading through the gfortran man page I realized that
gcc now supports OpenMP directives.

Given that the machines my students are using are all dual core, I started
working on a simple example that I hoped would show a nice speedup from the
"easy" library.

The specific problem I'm working on is a 2-d solution to the laplace
equation (electrostatics).  The bulk of the computation is a recursion
relation, applied to elements of a 2-d array, according to the following

Of course, by now I should know that "simple" never really is.  When I
compile with gfortran and run with 1 or 2 cores (ie, OMP_NUM_THREADS=2,
export OMP_NUM_THREADS) there is basically no difference in execution time.

Any suggestions?  I figured that this would be a simple example to
parallelize.  Is there a better example for OpenMP parallelization?  Also,
is there something obvious I'm missing in the example below?

Nathan Moore

real*8 v(Nx,Ny)
integer boundary(Nx,Ny)

v_cloud = -1.0e-4
v_ground = 0.d0

convergence_v = dabs(v_ground-v_cloud)/(1.d0*Ny*Ny)

! initialize the the boundary conditions
do i=1,Nx
        do j=1,Ny
                v_y = v_ground + (v_cloud-v_ground)*(j*dy/Ly)
                v(i,j) = v_y
                ! we need to ensure that the edges of the domain are held as
                if(i.eq.0 .or. i.eq.Nx .or. j.eq.0 .or. j.eq.Ny) then
        end do
end do

10 converged = 1
        do i=1,Nx
                do j=1,Ny
                        if(boundary(i,j).eq.0) then
                                old_v = v(i,j)
                                v(i,j) =
                                dv = dabs(old_v-v(i,j))
                                if(dv.gt.convergence_v) then
                                        converged = 0
                end do
        end do
if(converged.eq.0) then
        goto 10

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.clustermonkey.net/pipermail/beowulf/attachments/20081120/978f6317/attachment-0001.html>
-------------- next part --------------
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf

More information about the Beowulf mailing list