Skip to content

lastprivate behavior of SIMD clause #906

Description

@ivan-pi

Directive and clause it applies to

The omp simd directive should have lastprivate behavior by default.

Specification details

The 5.2 spec says under 5.1.1

The loop iteration variables in the associated loops of a simd construct with multiple associated loops are lastprivate.
...
The loop iteration variables in any associated loop of a loop-associates construct is otherwise private.

The OpenMP 6.0 spec says under 7.1.1

The loop-iteration variable in any affected loop of a loop or simd construct is lastprivate.

Pseudocode

The test could be an example similar to this one:

program foo
   implicit none
   integer(kind=4) :: i, j, me1, me2

   me1 = 1
   me2 = 1

   i = me1
   j = 42 !...dummy flag to test IV after loop exit

   !$omp simd
   do j=i+1, me2
     me1 = me1+1
   enddo

   print *, 'me1 ', me1
   print *, 'IV j should be 2, is: ', j

end program foo

Ideally the test should cover loops with both positive and non-positive trip count.

Any other comments

Related discussions:

Metadata

Metadata

Labels

new testPR that adds new tests

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions