Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flang][OpenMP]Incorrect execution result of LASTPRIVATE clause specified in DO construct #64055

Closed
ohno-fj opened this issue Jul 24, 2023 · 7 comments · Fixed by #69773
Closed
Assignees

Comments

@ohno-fj
Copy link

ohno-fj commented Jul 24, 2023

Version of flang-new : 17.0.0(3ff080b53b0a7f5bccfabd11254e255669892a67)

LASTPRIVATE clause specified in DO construct does not seem to be valid.

omp_PARALLELDO_005i_2.f:

      program main
      integer*4 ia, ib(50), ier
      integer*4 :: loop=50
      ia = 0
      ib = 0
!$omp parallel do lastprivate(ia)
      do ia=1,loop
         ib(ia) = ia
      enddo
!$omp end parallel do
      write(*,*) "     ia=",ia,"  It must be ",loop+1
      end
$ export OMP_NUM_THREADS=2; flang-new -fopenmp omp_PARALLELDO_005i_2.f; ./a.out
      ia= 50   It must be  51
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp omp_PARALLELDO_005i_2.f; ./a.out
      ia=          51   It must be           51
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp omp_PARALLELDO_005i_2.f; ./a.out
      ia=          51   It must be           51
$
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 24, 2023

@llvm/issue-subscribers-flang-frontend

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 24, 2023

@llvm/issue-subscribers-openmp

@kiranchandramohan
Copy link
Contributor

kiranchandramohan commented Jul 24, 2023

The current implementation does not handle the special case of lastprivate of iteration variable.

When the conditional modifier appears on the clause or the list item is an iteration variable of one of the associated loops, if sequential execution of the loop nest would assign a value to the list item then the original list item is assigned the value that the list item would have after sequential execution of the loop nest.

@ohno-fj
Copy link
Author

ohno-fj commented Jul 25, 2023

Thank you for your comment.

I understood the current implementation.
I close this issue.

@ohno-fj ohno-fj closed this as completed Jul 25, 2023
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Jul 25, 2023
@kiranchandramohan
Copy link
Contributor

Sorry, please keep it open since there is an issue here.

@EugeneZelenko EugeneZelenko removed the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Jul 25, 2023
@luporl luporl self-assigned this Oct 18, 2023
luporl added a commit to luporl/llvm-project that referenced this issue Oct 20, 2023
Iteration variables behave slightly different with LASTPRIVATE,
as they must be assigned the value that the copy would have after
sequential execution of the loop. This case is now handled.

This patch also fixes LASTPRIVATE for loops where the step is
different from 1.

Fixes llvm#64055
@luporl
Copy link
Contributor

luporl commented Oct 20, 2023

#69773

luporl added a commit that referenced this issue Oct 24, 2023
Iteration variables behave slightly different with LASTPRIVATE,
as they must be assigned the value that the copy would have after
sequential execution of the loop. This case is now handled.

This patch also fixes LASTPRIVATE for loops where the step is
different from 1.

Fixes #64055
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 24, 2023

@llvm/issue-subscribers-flang-ir

Author: None (ohno-fj)

``` Version of flang-new : 17.0.0(3ff080b) ```

LASTPRIVATE clause specified in DO construct does not seem to be valid.

omp_PARALLELDO_005i_2.f:

      program main
      integer*4 ia, ib(50), ier
      integer*4 :: loop=50
      ia = 0
      ib = 0
!$omp parallel do lastprivate(ia)
      do ia=1,loop
         ib(ia) = ia
      enddo
!$omp end parallel do
      write(*,*) "     ia=",ia,"  It must be ",loop+1
      end
$ export OMP_NUM_THREADS=2; flang-new -fopenmp omp_PARALLELDO_005i_2.f; ./a.out
      ia= 50   It must be  51
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp omp_PARALLELDO_005i_2.f; ./a.out
      ia=          51   It must be           51
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp omp_PARALLELDO_005i_2.f; ./a.out
      ia=          51   It must be           51
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants