-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][Semantics][OpenMP] don't reduce variables in namelist (#110671)
This is allowed by the OpenMP and F23 standards. But variables in a namelist are not allowed in OpenMP privatisation. I suspect this was an oversight. If we allow this we run into problems masking the original symbol with the symbol for the reduction variable when the variable is accessed via a namelist initialised as a global variable. See #101907. One solution for this would be to force the namelist to always be initilized inside of the block in which it is used (therefore using the correct mapping for the reduction variable), but this could make some production applications slow. I tentatively think it is probably better to disallow a (perhaps mistaken) edge case of the standards with (I think) little practical use, than to make real applications slow in order to make this work. If reviewers would rather keep to the letter of the standard, see #109303 which implements the alternative solution. I'm open to either path forward. Fixes #101907
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! This is not actually disallowed by the OpenMP standard, but it is not allowed | ||
! for privatisation - this seems like an oversight. | ||
|
||
module test | ||
integer :: a, b, c | ||
namelist /nlist1/ a, b | ||
end module | ||
|
||
program omp_reduction | ||
use test | ||
|
||
integer :: p(10) ,q(10) | ||
namelist /nlist2/ c, d | ||
|
||
a = 5 | ||
b = 10 | ||
c = 100 | ||
|
||
!ERROR: Variable 'd' in NAMELIST cannot be in a REDUCTION clause | ||
!ERROR: Variable 'a' in NAMELIST cannot be in a REDUCTION clause | ||
!$omp parallel reduction(+:d) reduction(+:a) | ||
d = a + b | ||
a = d | ||
!$omp end parallel | ||
|
||
call sb() | ||
|
||
contains | ||
subroutine sb() | ||
namelist /nlist3/ p, q | ||
|
||
!ERROR: Variable 'p' in NAMELIST cannot be in a REDUCTION clause | ||
!ERROR: Variable 'q' in NAMELIST cannot be in a REDUCTION clause | ||
!$omp parallel reduction(+:p) reduction(+:q) | ||
p = c * b | ||
q = p * d | ||
!$omp end parallel | ||
|
||
write(*, nlist1) | ||
write(*, nlist2) | ||
write(*, nlist3) | ||
|
||
end subroutine | ||
|
||
end program omp_reduction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters