openmp help on subroutine

  • Follow


This is a part of my code

!$OMP  PARALLEL DO DEFAULT(NONE) &
!$OMP  PRIVATE(il,ie,iie,ienrp,iend) &
!$OMP  PRIVATE(temp,spec,xa,ya) &
!$OMP  SHARED(ap1,ap2,ap3,ap4,ap6,ap7) &
!$OMP  SHARED(ap8,ap9,ap10,ap11,ap12,ap13) &
!$OMP  SHARED(MAP,SRL,seed,de,xxa,yya,e,istart)
         do iend=9,63,lorbit
        e=e+de
        iie=0

           ienrp=ienrp+1
           call hop(il,e,ienrp,map,srl,ap1,    &
          ap6,ap7,ap8,ap9,ap10,ap11,  &
          ap12,ap13,ap2,ap3,ap4,xa,ya)

        istart=iend+1
      write(*,'(".",$)')
         end do
!$OMP END PARALLEL DO

the subroutine HOP has many other variable other then the arguments.
should i declare them as private/shared as well? if yes, when where
should i declare it? in the main code or in the HOP itself?
0
Reply bnrj.rudra (343) 1/11/2009 2:14:33 PM

rudra wrote:
> This is a part of my code
> 
> !$OMP  PARALLEL DO DEFAULT(NONE) &
> !$OMP  PRIVATE(il,ie,iie,ienrp,iend) &
> !$OMP  PRIVATE(temp,spec,xa,ya) &
> !$OMP  SHARED(ap1,ap2,ap3,ap4,ap6,ap7) &
> !$OMP  SHARED(ap8,ap9,ap10,ap11,ap12,ap13) &
> !$OMP  SHARED(MAP,SRL,seed,de,xxa,yya,e,istart)
>          do iend=9,63,lorbit
>         e=e+de
>         iie=0
> 
>            ienrp=ienrp+1
>            call hop(il,e,ienrp,map,srl,ap1,    &
>           ap6,ap7,ap8,ap9,ap10,ap11,  &
>           ap12,ap13,ap2,ap3,ap4,xa,ya)
> 
>         istart=iend+1
>       write(*,'(".",$)')
>          end do
> !$OMP END PARALLEL DO
> 
> the subroutine HOP has many other variable other then the arguments.
> should i declare them as private/shared as well? if yes, when where
> should i declare it? in the main code or in the HOP itself?

There are a number of things questionable here; although a lot of
code is missing (including initializations), so that I am probably
missing some things.  As a start:

Certainly, e should not be SHARED, nor are the formulas for e, ienrp,
and istart safe; probably you should find the formulas for them in terms 
of IEND and make them PRIVATE.

I've no clue what's going on with iie, nor what's happening inside
hop() to all those arguments -- are any of them INTENT(OUT)?  If so,
the whole enterprise is questionable.
0
Reply carlie (79) 1/12/2009 1:16:53 PM


On Jan 12, 8:16=A0am, "Carlie J. Coats" <car...@jyarborough.com> wrote:
> rudra wrote:
> > This is a part of my code
>
> > !$OMP =A0PARALLEL DO DEFAULT(NONE) &
> > !$OMP =A0PRIVATE(il,ie,iie,ienrp,iend) &
> > !$OMP =A0PRIVATE(temp,spec,xa,ya) &
> > !$OMP =A0SHARED(ap1,ap2,ap3,ap4,ap6,ap7) &
> > !$OMP =A0SHARED(ap8,ap9,ap10,ap11,ap12,ap13) &
> > !$OMP =A0SHARED(MAP,SRL,seed,de,xxa,yya,e,istart)
> > =A0 =A0 =A0 =A0 =A0do iend=3D9,63,lorbit
> > =A0 =A0 =A0 =A0 e=3De+de
> > =A0 =A0 =A0 =A0 iie=3D0
>
> > =A0 =A0 =A0 =A0 =A0 =A0ienrp=3Dienrp+1
> > =A0 =A0 =A0 =A0 =A0 =A0call hop(il,e,ienrp,map,srl,ap1, =A0 =A0&
> > =A0 =A0 =A0 =A0 =A0 ap6,ap7,ap8,ap9,ap10,ap11, =A0&
> > =A0 =A0 =A0 =A0 =A0 ap12,ap13,ap2,ap3,ap4,xa,ya)
>
> > =A0 =A0 =A0 =A0 istart=3Diend+1
> > =A0 =A0 =A0 write(*,'(".",$)')
> > =A0 =A0 =A0 =A0 =A0end do
> > !$OMP END PARALLEL DO
>
> > the subroutine HOP has many other variable other then the arguments.
> > should i declare them as private/shared as well? if yes, when where
> > should i declare it? in the main code or in the HOP itself?
>
> There are a number of things questionable here; although a lot of
> code is missing (including initializations), so that I am probably
> missing some things. =A0As a start:
>
> Certainly, e should not be SHARED, nor are the formulas for e, ienrp,
> and istart safe; probably you should find the formulas for them in terms
> of IEND and make them PRIVATE.
>
> I've no clue what's going on with iie, nor what's happening inside
> hop() to all those arguments -- are any of them INTENT(OUT)? =A0If so,
> the whole enterprise is questionable.

Besides the points made by Carlie, you need to compile the subroutine
as re-entrant and make it recursive you run the risk of all threads
using the same stack. They way I do that is to add a line to the
subroutine before the "subroutine statement" as:

!$omp recursive &
     subroutine sub1(...

Notice that all variables that are internal to the recursive sub1 are
private.

HTH

Jomar
0
Reply jomarbueyes (182) 1/12/2009 8:32:44 PM

2 Replies
56 Views

(page loaded in 0.108 seconds)

Similiar Articles:













7/26/2012 8:18:54 PM


Reply: