Data sharing attribute rules under Fortran host association

General OpenMP discussion

Data sharing attribute rules under Fortran host association

Postby IanH » Sun Feb 03, 2013 6:39 pm

(Raised previously in feedback on 3.1 here)

Apologies if this is just terminology confusion on my part... For a variable that is referenced in a region, what data sharing attribute applies if a variable other than a module variable is "host associated" under Fortran?

Code: Select all
! Could also be an external procedure or a module procedure.
PROGRAM main_program
  IMPLICIT NONE
  INTEGER :: i
  INTEGER :: host_associated
  host_associated = 2
  !$OMP PARALLEL DO
  DO i = 1, 10
    CALL internal_procedure
  END DO
  !$OMP END PARALLEL DO
CONTAINS
  SUBROUTINE internal_procedure
    ! Is host_associated private or shared?
    PRINT *, host_associated
  END SUBROUTINE internal_procedure
END PROGRAM main_program


My reading of the spec:

- Local variables declared in called routines in the region and that have the save attribute or that are data initialised: host_associated does not have the save attribute.
- Variables belonging to common blocks or declared in modules: host_associated is neither.
- Dummy arguments of called routines that are passed by reference: host_associated is not a dummy argument.
- Cray pointees: n/a.
- Implied-do indices, forall indices and other local variables declared in called routines in the region: host_associated is not a local variable declared in a called routine (it is declared in the host).

(I assume "variables declared... in modules" refers to "variables declared in module specification parts", otherwise it would seem a little too inclusive.)

Thanks for any advice.
IanH
 
Posts: 1
Joined: Thu Jan 31, 2013 8:44 pm

Re: Data sharing attribute rules under Fortran host associat

Postby ftinetti » Wed Feb 06, 2013 7:41 am

Hi,

I think there is something missing for host associated variables referenced in a region but not in a construct... but maybe I've lost something. I tend to think those variables inherit the data-sharing attribute...

Fernando.
Last edited by ftinetti on Mon Feb 11, 2013 7:08 am, edited 1 time in total.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm

Re: Data sharing attribute rules under Fortran host associat

Postby MarkB » Mon Feb 11, 2013 4:26 am

I agree that the spec is a bit vague here, but I'm sure the intention is that host_associated be shared in this case, and would be very surprised if any implementations do otherwise.
MarkB
 
Posts: 487
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Data sharing attribute rules under Fortran host associat

Postby ftinetti » Mon Feb 11, 2013 8:12 am

Hi again,

I've changed a little bit the code to
$ cat hostassoc.f90
Code: Select all
! Could also be an external procedure or a module procedure.
PROGRAM main_program
  IMPLICIT NONE

  INTEGER :: i
  INTEGER :: host_associated

  host_associated = 0

  !$OMP PARALLEL DO PRIVATE(host_associated)
  DO i = 1, 10
    CALL internal_procedure
  END DO
  !$OMP END PARALLEL DO

  IF (host_associated .EQ. 1) THEN
    PRINT *, "Seems to be shared"
  ELSE
    PRINT *, "Seems to be private"
  END IF

CONTAINS
  SUBROUTINE internal_procedure
    ! Is host_associated private or shared?
    PRINT *, host_associated

    host_associated = 1
    !$OMP FLUSH(host_associated)
  END SUBROUTINE internal_procedure

END PROGRAM main_program

$ gfortran -fopenmp hostassoc.f90

which results in

$ a.out
0
1
1
1
1
1
1
1
1
1
Seems to be shared

And now I'm a little bit confused... it's like if the compiler does not reject the PRIVATE but the data is still shared...
Checked with gfortran - gcc version 4.6.3 20111216, which is exactly the same for ifort version 13.0.1

Fernando.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm

Re: Data sharing attribute rules under Fortran host associat

Postby MarkB » Mon Feb 11, 2013 10:05 am

Hi Fernando,

If you declare host_associated as private, then you have the case pointed to by Ian in this thread: viewtopic.php?f=10&t=1471 where the behaviour is specified as undefined.

Mark.
MarkB
 
Posts: 487
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Data sharing attribute rules under Fortran host associat

Postby ftinetti » Mon Feb 11, 2013 11:12 am

Hi Mark,

If you declare host_associated as private, then you have the case pointed to by Ian in this thread: viewtopic.php?f=10&t=1471 where the behaviour is specified as undefined.

You are right, I forgot that one...

Fernando.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 8 guests