# [Beowulf] OpenMP on AMD dual core processors

Robert G. Brown rgb at phy.duke.edu
Fri Nov 21 11:53:29 EST 2008

```On Fri, 21 Nov 2008, Nathan Moore wrote:

> 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"

My friend, long before I whacked you for using a goto (or horrors,
teaching impressionable young minds about the command that is the
fundamental basis for some of the worst spaghetti code ever written) I'd
whack you about teaching them "fortran" at all, especially "classical"
fortran (which I interpret as being something around Fortran IV, which
is where I got off the Fortran choo-choo).

<shudder>

(rgb calmly strips nekkid in his office and puts on his handy-dandy
adiabatic suit, gulping the rest of his beer and mildly shocking the
undergraduates he was interacting with as he prepares for the incoming
missiles...:-)

>
> 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.
>
> Nathan
>
> On Fri, Nov 21, 2008 at 9:05 AM, <rssr at lncc.br> wrote:
>       Hi All
>
>       I thing the problem could be the  convergence "loop" test and
>       the criation of threads
>
> 10 converged = 1
> !\$OMP PARALLEL
> !\$OMP DO
> .....
> !\$OMP ENDDO
> !\$OMP END PARALLEL
> if(converged.eq.0) then
>
>      goto 10
> endif
> Each time you "goto 10"
> the compiler "create" and "initialize" the threads
> and this is time comsuming.
> try to change the convergence test to a
> reduce operation this will
> take time but not some much as !\$OMP
> PARALLEL
> I hope its help
>
> Renato Silva
>
>
>
> > 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
> > snippet.
> >
> > 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,
> > 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
> >
> > integer,parameter::Nx=1000
> > integer,parameter::Ny=1000
> > 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)
> > boundary(i,j)=0
> > v(i,j) = v_y
> > ! we need to ensure that the edges of the domain are held
> > as
> > boundary
> > if(i.eq.0 .or. i.eq.Nx .or. j.eq.0 .or. j.eq.Ny) then
> > boundary(i,j)=1
> > endif
> > end do
> > end do
> >
> > 10 converged = 1
> > !\$OMP PARALLEL
> > !\$OMP DO
> > do i=1,Nx
> > do j=1,Ny
> > if(boundary(i,j).eq.0) then
> > old_v = v(i,j)
> > v(i,j) =
> > 0.25*(v(i-1,j)+v(i+1,j)+v(i,j+1)+v(i,j-1))
> > dv = dabs(old_v-v(i,j))
> > if(dv.gt.convergence_v) then
> > converged = 0
> > endif
> > endif
> > end do
> > end do
> > !\$OMP ENDDO
> > !\$OMP END PARALLEL
> > if(converged.eq.0) then
> > goto 10
> > endif
> > _______________________________________________
> > Beowulf mailing list, Beowulf at beowulf.org
> > To change your subscription (digest mode or unsubscribe) visit
> > http://www.beowulf.org/mailman/listinfo/beowulf
> >
>
>
>
>
> --
> - - - - - - -   - - - - - - -   - - - - - - -
> Nathan Moore
> Assistant Professor, Physics
> Winona State University
> AIM: nmoorewsu
> - - - - - - -   - - - - - - -   - - - - - - -
>
>

Robert G. Brown                            Phone(cell): 1-919-280-8443
Duke University Physics Dept, Box 90305
Durham, N.C. 27708-0305
Web: http://www.phy.duke.edu/~rgb
Book of Lilith Website: http://www.phy.duke.edu/~rgb/Lilith/Lilith.php
Lulu Bookstore: http://stores.lulu.com/store.php?fAcctID=877977
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- 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
```