-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[flang][OpenMP] Enable delayed privatization for omp parallel
by default
#90945
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
Conversation
13edc47
to
e2bd438
Compare
omp parallel
by default
ca83608
to
03e9921
Compare
03e9921
to
33c2f9c
Compare
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-flang-openmp Author: Kareem Ergawy (ergawy) ChangesFlips the delayed privatization switch to be on by default. After the recent fixes related to delayed privatization, the gfortran test suite runs successfully with delayed privatization turned on by defuault for Full diff: https://github.com/llvm/llvm-project/pull/90945.diff 15 Files Affected:
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index 36d96f37ff36a..d4513311553cc 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -34,7 +34,7 @@ llvm::cl::opt<bool> enableDelayedPrivatization(
"openmp-enable-delayed-privatization",
llvm::cl::desc(
"Emit `[first]private` variables as clauses on the MLIR ops."),
- llvm::cl::init(false));
+ llvm::cl::init(true));
llvm::cl::opt<bool> enableDelayedPrivatizationStaging(
"openmp-enable-delayed-privatization-staging",
diff --git a/flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90 b/flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90
index 773452206993f..c59c10d1c7b76 100644
--- a/flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90
+++ b/flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90
@@ -1,7 +1,12 @@
! This test checks the lowering of parallel do
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
-! RUN: bbc -fopenmp -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
+
+! RUN: bbc -fopenmp -emit-fir -hlfir=false \
+! RUN: --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
! The string "EXPECTED" denotes the expected FIR
diff --git a/flang/test/Lower/OpenMP/copyprivate.f90 b/flang/test/Lower/OpenMP/copyprivate.f90
index 9b76a996ef3e1..d1efb14de027f 100644
--- a/flang/test/Lower/OpenMP/copyprivate.f90
+++ b/flang/test/Lower/OpenMP/copyprivate.f90
@@ -1,5 +1,7 @@
! Test COPYPRIVATE.
-! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false -o - %s 2>&1 \
+! RUN: | FileCheck %s
!CHECK-DAG: func private @_copy_i64(%{{.*}}: !fir.ref<i64>, %{{.*}}: !fir.ref<i64>)
!CHECK-DAG: func private @_copy_f32(%{{.*}}: !fir.ref<f32>, %{{.*}}: !fir.ref<f32>)
diff --git a/flang/test/Lower/OpenMP/default-clause-byref.f90 b/flang/test/Lower/OpenMP/default-clause-byref.f90
index 7893c4d7d5732..b69142626ad95 100644
--- a/flang/test/Lower/OpenMP/default-clause-byref.f90
+++ b/flang/test/Lower/OpenMP/default-clause-byref.f90
@@ -1,8 +1,13 @@
! This test checks lowering of OpenMP parallel directive
! with `DEFAULT` clause present.
-! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --force-byref-reduction %s -o - | FileCheck %s
-! RUN: bbc -fopenmp -emit-hlfir --force-byref-reduction %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --force-byref-reduction \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
+
+! RUN: bbc -fopenmp -emit-hlfir --force-byref-reduction \
+! RUN: --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
!CHECK: func @_QQmain() attributes {fir.bindc_name = "default_clause_lowering"} {
diff --git a/flang/test/Lower/OpenMP/default-clause.f90 b/flang/test/Lower/OpenMP/default-clause.f90
index 60a9c5efbb2a1..7a642e871198d 100644
--- a/flang/test/Lower/OpenMP/default-clause.f90
+++ b/flang/test/Lower/OpenMP/default-clause.f90
@@ -1,8 +1,13 @@
! This test checks lowering of OpenMP parallel directive
! with `DEFAULT` clause present.
-! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
-! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
+
+! RUN: bbc -fopenmp -emit-hlfir \
+! RUN: --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
!CHECK: func @_QQmain() attributes {fir.bindc_name = "default_clause_lowering"} {
diff --git a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
index d0fcdac76ad79..9b30492a91ba4 100644
--- a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
+++ b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
@@ -1,4 +1,6 @@
-! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false -o - %s 2>&1 \
+! RUN: | FileCheck %s
!CHECK: func.func @_QPfirstprivate_common() {
!CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<8xi8>>
diff --git a/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90 b/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
index 271b97819e606..084f2de6360a3 100644
--- a/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
+++ b/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
@@ -1,8 +1,13 @@
! This test checks lowering of sequential loops in OpenMP parallel.
! The loop indices of these loops should be privatised.
-! RUN: bbc -hlfir -fopenmp -emit-hlfir %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-hlfir -flang-experimental-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir \
+! RUN: --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
+
+! RUN: %flang_fc1 -emit-hlfir -flang-experimental-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
subroutine sb1
diff --git a/flang/test/Lower/OpenMP/implicit-dsa.f90 b/flang/test/Lower/OpenMP/implicit-dsa.f90
index 0f67d5bfd194f..e9472f1351e75 100644
--- a/flang/test/Lower/OpenMP/implicit-dsa.f90
+++ b/flang/test/Lower/OpenMP/implicit-dsa.f90
@@ -1,4 +1,6 @@
-!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false -o - %s 2>&1 \
+! RUN: | FileCheck %s
! Checks lowering of OpenMP variables with implicitly determined DSAs.
diff --git a/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90 b/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
index 93dcd4b74b004..50c36bdccbd5a 100644
--- a/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
+++ b/flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
@@ -1,7 +1,8 @@
! This test checks lowering of `FIRSTPRIVATE` clause for scalar types.
! REQUIRES: shell
-! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s --check-prefix=CHECK
+! RUN: bbc -fopenmp -emit-hlfir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s --check-prefix=CHECK
!CHECK-DAG: func @_QPfirstprivate_complex(%[[ARG1:.*]]: !fir.ref<!fir.complex<4>>{{.*}}, %[[ARG2:.*]]: !fir.ref<!fir.complex<8>>{{.*}}) {
!CHECK: %[[ARG1_DECL:.*]]:2 = hlfir.declare %[[ARG1]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFfirstprivate_complexEarg1"} : (!fir.ref<!fir.complex<4>>, !fir.dscope) -> (!fir.ref<!fir.complex<4>>, !fir.ref<!fir.complex<4>>)
diff --git a/flang/test/Lower/OpenMP/parallel-private-clause-fixes.f90 b/flang/test/Lower/OpenMP/parallel-private-clause-fixes.f90
index 19c7b78298eab..eb32201512a5f 100644
--- a/flang/test/Lower/OpenMP/parallel-private-clause-fixes.f90
+++ b/flang/test/Lower/OpenMP/parallel-private-clause-fixes.f90
@@ -1,6 +1,9 @@
! This test checks a few bug fixes in the PRIVATE clause lowering
-! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
+
+
! CHECK-LABEL: multiple_private_fix
! CHECK-SAME: %[[GAMA:.*]]: !fir.ref<i32> {fir.bindc_name = "gama"}
diff --git a/flang/test/Lower/OpenMP/parallel-private-clause-str.f90 b/flang/test/Lower/OpenMP/parallel-private-clause-str.f90
index 19ea37c5339b5..840f898e5dd67 100644
--- a/flang/test/Lower/OpenMP/parallel-private-clause-str.f90
+++ b/flang/test/Lower/OpenMP/parallel-private-clause-str.f90
@@ -2,8 +2,12 @@
! `PRIVATE` clause present for strings
! REQUIRES: shell
-! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
-!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
+
+! RUN: %flang_fc1 -emit-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false -o - %s 2>&1 \
+! RUN: | FileCheck %s
!CHECK: func.func @_QPtest_allocatable_string(%{{.*}}: !fir.ref<i32> {fir.bindc_name = "n"}) {
!CHECK: %[[C_BOX_REF:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {bindc_name = "c", uniq_name = "_QFtest_allocatable_stringEc"}
diff --git a/flang/test/Lower/OpenMP/parallel-private-clause.f90 b/flang/test/Lower/OpenMP/parallel-private-clause.f90
index 7f5bc2565e679..b2c38f22caf75 100644
--- a/flang/test/Lower/OpenMP/parallel-private-clause.f90
+++ b/flang/test/Lower/OpenMP/parallel-private-clause.f90
@@ -2,7 +2,8 @@
! `PRIVATE` clause present.
! REQUIRES: shell
-! RUN: bbc --use-desc-for-alloc=false -fopenmp -emit-hlfir %s -o - | \
+! RUN: bbc --use-desc-for-alloc=false -fopenmp -emit-hlfir \
+! RUN: --openmp-enable-delayed-privatization=false %s -o - | \
! RUN: FileCheck %s --check-prefix=FIRDialect
!FIRDialect: func @_QPprivate_clause(%[[ARG1:.*]]: !fir.ref<i32> {fir.bindc_name = "arg1"}, %[[ARG2:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "arg2"}, %[[ARG3:.*]]: !fir.boxchar<1> {fir.bindc_name = "arg3"}, %[[ARG4:.*]]: !fir.boxchar<1> {fir.bindc_name = "arg4"}) {
diff --git a/flang/test/Lower/OpenMP/parallel-wsloop.f90 b/flang/test/Lower/OpenMP/parallel-wsloop.f90
index e5c303d7bb2ed..0288d6d6fa73e 100644
--- a/flang/test/Lower/OpenMP/parallel-wsloop.f90
+++ b/flang/test/Lower/OpenMP/parallel-wsloop.f90
@@ -1,6 +1,7 @@
! This test checks lowering of OpenMP DO Directive (Worksharing).
-! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir --openmp-enable-delayed-privatization=false %s -o - \
+! RUN: | FileCheck %s
! CHECK-LABEL: func @_QPsimple_parallel_do()
subroutine simple_parallel_do
diff --git a/flang/test/Lower/OpenMP/private-commonblock.f90 b/flang/test/Lower/OpenMP/private-commonblock.f90
index ee580594f7c3f..b8f459bac201e 100644
--- a/flang/test/Lower/OpenMP/private-commonblock.f90
+++ b/flang/test/Lower/OpenMP/private-commonblock.f90
@@ -1,4 +1,6 @@
-! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp \
+! RUN: -mmlir --openmp-enable-delayed-privatization=false -o - %s 2>&1 \
+! RUN: | FileCheck %s
!CHECK: func.func @_QPprivate_common() {
!CHECK: omp.parallel {
diff --git a/flang/test/Lower/OpenMP/unstructured.f90 b/flang/test/Lower/OpenMP/unstructured.f90
index b36e4f37a7458..1c33d32a31e62 100644
--- a/flang/test/Lower/OpenMP/unstructured.f90
+++ b/flang/test/Lower/OpenMP/unstructured.f90
@@ -1,6 +1,7 @@
! Test unstructured code adjacent to and inside OpenMP constructs.
-! RUN: bbc %s -fopenmp -emit-hlfir -o "-" | FileCheck %s
+! RUN: bbc %s -fopenmp -emit-hlfir --openmp-enable-delayed-privatization=false -o "-" \
+! RUN: | FileCheck %s
! CHECK-LABEL: func @_QPss1{{.*}} {
! CHECK: br ^bb1
|
@luporl Is it possible to do a quick run with the Fujitsu test? |
I have not been running Fujitsu testsuite as a whole, but I can give it a try. |
@kiranchandramohan @luporl if the test suite you guys are refering to is the same as this: https://github.com/fujitsu/compiler-test-suite, I can give it a try on my side. Or is it something that is not open source? |
It is that test suite indeed. Not every Fortran test was added to https://github.com/fujitsu/compiler-test-suite yet, but not breaking any new test from the already published ones should be enough. I'm having some trouble running it. For some reason cmake is not detecting the test cases. I'll try to investigate it, but maybe you have better luck with it. |
After that I got several
With that it was possible to build the tests, that are now running. |
|
Fujitsu testsuite results: Before:
After:
2 tests now pass:
But several failures became "executable missing", which means the compilation failed. This is one of them:
|
I'm also seeing 2 failures on gfortran testsuite (tested on AArch64):
|
Thanks a lot @luporl for the testing.
I think some changes in |
I will take a look 👀 ... |
I think these were intermittently broken indeed. But merging with the latest main seems to fix them:
|
Thanks @luporl for running the suite and the results.
Are these issues fixed by #92430? |
Unfortunately not. So far I found 3 issues from Fujitsu tests. Cloning
|
Sorry for the delay here. I am working through the Fujistu failures but also busy with a few AMD-specific work items downstream. I opened: #96024 to handle one of the uncovered issues. |
33c2f9c
to
3c23d1f
Compare
fb85891
to
d9fd566
Compare
This is now handled in #100531. Still have to verify it using Fujitsu tests. |
4d037f0
to
f27e10e
Compare
With the recently merged delayed privatization PRs, I now get the same results for both the gfortan and Fujitsu test suites with and without delayed privatization. Also, in this PR, I updated all It would be great if someone else can also run gfortran and/or Fujitsu test suites to double check my results. |
the gfortran testsuite and our internal tests all pass for me 🚀 |
I ran Fujitsu testsuite with and without this PR applied and the results were the same:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG. Great work @ergawy.
Awesome, thanks for the approval and verification folks. |
…fault Flips the delayed privatization switch to be on by default. After the recent fixes related to delayed privatization, the gfortran test suite runs successfully with delayed privatization turned on by defuault for `omp parallel`.
f27e10e
to
6b6c8ae
Compare
Flips the delayed privatization switch to be on by default. After the recent fixes related to delayed privatization, the gfortran test suite runs successfully with delayed privatization turned on by defuault for
omp parallel
.