[flang] OpenMP default private clause does not work as expected
consider the following program
PROGRAM main INTEGER:: NEL !$OMP PARALLEL DO DEFAULT(PRIVATE) !PRIVATE(NEL) DO I=1, 4 NEL=I PRINT *, I, NEL ENDDO !$OMP END PARALLEL DO END PROGRAM
$flang-new -fopenmp test.f90 $a.out 2 4 4 4 3 4 1 4
NEL variable is expected to be private, but it is not considered so. uncommenting PRIVATE(NEL) clause makes the program work.
The handling of DEFAULT isn't really fully implemented yet: https://github.com/llvm/llvm-project/blob/main/flang/lib/Lower/OpenMP.cpp#L1356-L1376
Thanks for the reply. The testcase is extracted from 362.fma3d omp2012 benchmark suite.
if I comment the following line, the testcase passes. Should the function defaultPrivatize need to handle this case better?
https://github.com/llvm/llvm-project/blob/main/flang/lib/Lower/OpenMP.cpp#L517
@shivaramaarao This check was added in https://github.com/llvm/llvm-project/pull/71922, to fix https://github.com/llvm/llvm-project/issues/65569. I will do some analysis and get back with more details by EOD on this, on why this check is causing the current issue.
@llvm/issue-subscribers-flang-ir
Author: None (shivaramaarao)
PROGRAM main INTEGER:: NEL !$OMP PARALLEL DO DEFAULT(PRIVATE) !PRIVATE(NEL) DO I=1, 4 NEL=I PRINT *, I, NEL ENDDO !$OMP END PARALLEL DO END PROGRAM
$flang-new -fopenmp test.f90 $a.out 2 4 4 4 3 4 1 4
NEL variable is expected to be private, but it is not considered so. uncommenting PRIVATE(NEL) clause makes the program work.
Hello @shivaramaarao,
I re-looked at the issue with rebased llvm flang. The issue is no longer existent with https://github.com/llvm/llvm-project/pull/72510 applied atop https://github.com/llvm/llvm-project/commit/4235e44d4c37ca738c74def05da8caf124d2464e. Could you check once? I get the following IR, which seems to be correct:
omp.parallel {
%4 = fir.alloca i32 {adapt.valuebyref, pinned}
%5 = fir.declare %4 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> !fir.ref<i32>
%6 = fir.alloca i32 {bindc_name = "nel", pinned, uniq_name = "_QFEnel"}
%7 = fir.declare %6 {uniq_name = "_QFEnel"} : (!fir.ref<i32>) -> !fir.ref<i32>
omp.wsloop for (%arg0) : i32 = (%c1_i32) to (%c4_i32) inclusive step (%c1_i32) {
fir.store %arg0 to %5 : !fir.ref<i32>
%8 = fir.load %5 : !fir.ref<i32>
fir.store %8 to %7 : !fir.ref<i32>
omp.yield
}
omp.terminator
}
@NimishMishra if this works now, can you close the issue?
Validated the application from which this reproducer arose, and it is working fine. Closing this hence.