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] complains about incorrect OpenMP reduction if variable is used before parallel block #70828

Closed
aitap opened this issue Oct 31, 2023 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir flang:openmp

Comments

@aitap
Copy link

aitap commented Oct 31, 2023

Originally reported at R-package-devel for 092b6c5, here's the compilation log and the full source code. Can also be reproduced for e107c94 (main at the time of writing).

I was able to reduce this to the following example:

program main
    implicit none

    real :: sum = 0
    integer :: i, n = 10

    sum = sum + 1. ! <-- error here if followed by OpenMP reduction

    !$OMP PARALLEL DO default(none) PRIVATE(i) SHARED(n) REDUCTION(+:sum) SCHEDULE(Dynamic,1)
    do i=1,n
        sum = sum + real(i)
    end do
    !$OMP END PARALLEL DO

    print *, sum
end
% flang-new -c -o /dev/null src.f90 -fopenmp
error: loc("src.f90":7:5): 'omp.reduction' op must be used within an operation supporting reduction clause interface
error: verification of lowering to FIR failed
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Oct 31, 2023
@EugeneZelenko EugeneZelenko added flang:ir and removed flang Flang issues not falling into any other category labels Oct 31, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 31, 2023

@llvm/issue-subscribers-flang-ir

Author: None (aitap)

Originally reported at [R-package-devel](https://stat.ethz.ch/pipermail/r-package-devel/2023q4/009787.html) for 092b6c5, here's [the compilation log](http://web.archive.org/web/20231031154710/https://www.stats.ox.ac.uk/pub/bdr/clang17/frailtypack.log) and [the full source code](https://cran.r-project.org/src/contrib/Archive/frailtypack/frailtypack_3.5.0.tar.gz). Can also be reproduced for e107c94 (`main` at the time of writing).

I was able to reduce this to the following example:

program main
    implicit none

    real :: sum = 0
    integer :: i, n = 10

    sum = sum + 1. ! &lt;-- error here if followed by OpenMP reduction

    !$OMP PARALLEL DO default(none) PRIVATE(i) SHARED(n) REDUCTION(+:sum) SCHEDULE(Dynamic,1)
    do i=1,n
        sum = sum + real(i)
    end do
    !$OMP END PARALLEL DO

    print *, sum
end
% flang-new -c -o /dev/null src.f90 -fopenmp
error: loc("src.f90":7:5): 'omp.reduction' op must be used within an operation supporting reduction clause interface
error: verification of lowering to FIR failed

@kiranchandramohan
Copy link
Contributor

Thank you. We are working on reduction handling and will come to this soon.

@kiranchandramohan kiranchandramohan added bug Indicates an unexpected problem or unintended behavior flang:openmp labels Oct 31, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 31, 2023

@llvm/issue-subscribers-bug

Author: None (aitap)

Originally reported at [R-package-devel](https://stat.ethz.ch/pipermail/r-package-devel/2023q4/009787.html) for 092b6c5, here's [the compilation log](http://web.archive.org/web/20231031154710/https://www.stats.ox.ac.uk/pub/bdr/clang17/frailtypack.log) and [the full source code](https://cran.r-project.org/src/contrib/Archive/frailtypack/frailtypack_3.5.0.tar.gz). Can also be reproduced for e107c94 (`main` at the time of writing).

I was able to reduce this to the following example:

program main
    implicit none

    real :: sum = 0
    integer :: i, n = 10

    sum = sum + 1. ! &lt;-- error here if followed by OpenMP reduction

    !$OMP PARALLEL DO default(none) PRIVATE(i) SHARED(n) REDUCTION(+:sum) SCHEDULE(Dynamic,1)
    do i=1,n
        sum = sum + real(i)
    end do
    !$OMP END PARALLEL DO

    print *, sum
end
% flang-new -c -o /dev/null src.f90 -fopenmp
error: loc("src.f90":7:5): 'omp.reduction' op must be used within an operation supporting reduction clause interface
error: verification of lowering to FIR failed

@clementval clementval changed the title flang complains about incorrect OpenMP reduction if variable is used before parallel block [flang][openmp] complains about incorrect OpenMP reduction if variable is used before parallel block Nov 3, 2023
@kiranchandramohan
Copy link
Contributor

This works now with #80019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior flang:ir flang:openmp
Projects
None yet
Development

No branches or pull requests

4 participants