-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 a variable in critical construct in parallel construct with default(firstprivate) clause #75767
Comments
@llvm/issue-subscribers-openmp Author: None (ohno-fj)
```
Version of flang-new : 18.0.0(76bbbcb)
```
The execution result of a variable in
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result. snf_ng_01_1.f90: program main
INTEGER :: j
j=2
!$OMP PARALLEL default(firstprivate)
!$OMP critical
j=200
!$OMP END critical
!$OMP END PARALLEL
if (j.ne.2) print *,'err var j=',j
print *,'pass'
end program main
|
@NimishMishra Does your fix for default cover this? |
@kiranchandramohan I took an initial look at the ticket, and it seems like the issue isn't default lowering. To be able to lower default clause, in semantics phase, we add relevant symbols to I am observing that Changing this directive to |
The various OpenMPConstructs are the following. Does the same issue affect
|
@kiranchandramohan This issue affects OpenMPSectionsConstruct too. I think we should be targeting fixing default lowering? |
#90671 doesn't fix this issue, but it's a step forward, as it allows the symbol to be correctly processed in semantics phase.
After:
Lowering probably needs some tweaks as well. |
When a critical construct is present inside another construct where privatizations may occur, such as a parallel construct, some privatizations are skipped if the corresponding symbols are defined inside the critical section only (see the example below). This happens because, while critical constructs have a "body", they don't have a separate scope (which makes sense, since no privatizations can occur in them). Because of this, in semantics phase, it's not possible to insert a new host association symbol, but instead the symbol from the enclosing context is used directly. This makes symbol collection in DataSharingProcessor consider the new symbol to be defined by the critical construct, instead of by the enclosing one, which causes the privatization to be skipped. Example: ``` !$omp parallel default(firstprivate) !$omp critical i = 200 !$omp end critical !$omp end parallel ``` This patch fixes this by identifying constructs where privatizations may not happen and skipping them during the collection of nested symbols. Currently, this seems to happen only with critical constructs, but others can be easily added to the skip list, if needed. Fixes llvm#75767
When a critical construct is present inside another construct where privatizations may occur, such as a parallel construct, some privatizations are skipped if the corresponding symbols are defined inside the critical section only (see the example below). This happens because, while critical constructs have a "body", they don't have a separate scope (which makes sense, since no privatizations can occur in them). Because of this, in semantics phase, it's not possible to insert a new host association symbol, but instead the symbol from the enclosing context is used directly. This makes symbol collection in DataSharingProcessor consider the new symbol to be defined by the critical construct, instead of by the enclosing one, which causes the privatization to be skipped. Example: ``` !$omp parallel default(firstprivate) !$omp critical i = 200 !$omp end critical !$omp end parallel ``` This patch fixes this by identifying constructs where privatizations may not happen and skipping them during the collection of nested symbols. Currently, this seems to happen only with critical constructs, but others can be easily added to the skip list, if needed. Fixes #75767
@llvm/issue-subscribers-flang-ir Author: None (ohno-fj)
```
Version of flang-new : 18.0.0(76bbbcb)
```
The execution result of a variable in
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result. snf_ng_01_1.f90: program main
INTEGER :: j
j=2
!$OMP PARALLEL default(firstprivate)
!$OMP critical
j=200
!$OMP END critical
!$OMP END PARALLEL
if (j.ne.2) print *,'err var j=',j
print *,'pass'
end program main
|
The execution result of a variable in
critical
construct inparallel
construct withdefault(firstprivate)
clause is incorrect.The execution result is correct if:
critical
construct, ordefault(firstprivate)
tofirstprivate(j)
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
snf_ng_01_1.f90:
The text was updated successfully, but these errors were encountered: