Data-sharing attribute rules for host association

Discuss the OpenMP 3.1 API Specifications with the OpenMP Arch. Review Board. (Read Only)

Data-sharing attribute rules for host association

Postby nathanweeks » Tue Aug 21, 2012 5:32 am

The Fortran-specific part of Section 2.9.1.2 (Data-sharing Attribute Rules for Variables Referenced in a Region but not in a Construct) of the OpenMP 3.1 spec doesn't explicitly address variables declared in a main program and accessed by host association in an internal subprogram.

Two questions:

1. Are such variables shared unless appearing in a threadprivate directive?
2. Assuming the answer to #1 is "yes", consider the following program:

Code: Select all
program host_association
   implicit none
   integer :: x = 0

!$omp parallel firstprivate(x)
!$omp master
   x = x + 1
   call printvar()
!$omp end master
!$omp end parallel

   write (*,*) 'Outside of parallel region:', x

contains

   subroutine printvar()
      x = x + 2
      write (*,*) 'In parallel region:', x
   end subroutine printvar

end program host_association


The "x" within the parallel construct is private copy initialized to 0; however, I would expect the "x" in internal subroutine "printvar" to be shared, referencing the "x" declared in the main program and accessible to printvar via host association. In this case, the expected output (which I did not get with all the implementations I tested) would be:

    In parallel region: 2
    Outside of parallel region: 2
Is this assessment correct?
--
Nathan Weeks
Iowa State University HPC Group
http://weeks.public.iastate.edu/
nathanweeks
 
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University

Re: Data-sharing attribute rules for host association

Postby MarkB » Tue Aug 21, 2012 9:04 am

Hi Nathan,

I think this is covered by the description of the private clause starting at page 96 line 14 of the 3.1 spec.

"Inside the construct, all references to the original list item are replaced by references to the new list item. In the rest of the region, it is unspecified whether references are to the new list item or the original list item."

In your example the reference to x in printvar is outside the construct but inside the rest of the region, so results in unspecified behaviour (and different implementations are entitled to give different results!).

Hope that helps,
Mark.
MarkB
 
Posts: 486
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Data-sharing attribute rules for host association

Postby nathanweeks » Wed Aug 22, 2012 3:15 am

That explains it. Thanks, Mark!
--
Nathan Weeks
Iowa State University HPC Group
http://weeks.public.iastate.edu/
nathanweeks
 
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University


Return to OpenMP 3.1 API Specifications

Who is online

Users browsing this forum: No registered users and 1 guest