[flang-commits] [flang] [Flang][OpenMP] Add frontend support for directives involving master (PR #113893)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Mon Oct 28 04:41:20 PDT 2024
https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/113893
>From 3edc4594fa02c91e9e14c17a30a673834415e3cf Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Sun, 27 Oct 2024 14:20:34 +0000
Subject: [PATCH 1/2] [Flang][OpenMP] Use uppercase names for directives in
deprecation message
Change the way the deprecation message is emitted to make it easier for
supporting deprecation of multiple directives.
---
flang/lib/Semantics/resolve-directives.cpp | 16 ++++++++-----
.../Semantics/OpenMP/clause-validity01.f90 | 4 ++--
flang/test/Semantics/OpenMP/flush02.f90 | 2 +-
.../test/Semantics/OpenMP/nested-barrier.f90 | 4 ++--
flang/test/Semantics/OpenMP/nested-master.f90 | 24 +++++++++----------
flang/test/Semantics/OpenMP/nested-teams.f90 | 2 +-
flang/test/Semantics/OpenMP/ordered-simd.f90 | 8 +++----
7 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 33936ba4c2b34f..e4c10cee94bcba 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2880,18 +2880,22 @@ void OmpAttributeVisitor::AddOmpRequiresToScope(Scope &scope,
void OmpAttributeVisitor::IssueNonConformanceWarning(
llvm::omp::Directive D, parser::CharBlock source) {
- std::string warnStr = "";
- std::string dirName = llvm::omp::getOpenMPDirectiveName(D).str();
+ std::string warnStr;
+ llvm::raw_string_ostream warnStrOS(warnStr);
+ warnStrOS << "OpenMP directive " << parser::ToUpperCaseLetters(llvm::omp::getOpenMPDirectiveName(D).str()) << " has been deprecated";
+
+ auto setAlternativeStr = [&warnStrOS](llvm::StringRef alt) {
+ warnStrOS << ", please use " << alt << " instead.";
+ };
switch (D) {
case llvm::omp::OMPD_master:
- warnStr = "OpenMP directive '" + dirName +
- "' has been deprecated, please use 'masked' instead.";
+ setAlternativeStr("MASKED");
+ break;
break;
case llvm::omp::OMPD_target_loop:
default:
- warnStr = "OpenMP directive '" + dirName + "' has been deprecated.";
}
context_.Warn(
- common::UsageWarning::OpenMPUsage, source, "%s"_warn_en_US, warnStr);
+ common::UsageWarning::OpenMPUsage, source, "%s"_warn_en_US, warnStrOS.str());
}
} // namespace Fortran::semantics
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 1a7a57b124e9bd..124f1a02d99fba 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -476,14 +476,14 @@
! 2.13.1 master
!$omp parallel
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
a=3.14
!$omp end master
!$omp end parallel
!$omp parallel
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: NUM_THREADS clause is not allowed on the MASTER directive
!$omp master num_threads(4)
a=3.14
diff --git a/flang/test/Semantics/OpenMP/flush02.f90 b/flang/test/Semantics/OpenMP/flush02.f90
index f06719f302fd7a..ed0cf6602d574a 100644
--- a/flang/test/Semantics/OpenMP/flush02.f90
+++ b/flang/test/Semantics/OpenMP/flush02.f90
@@ -80,7 +80,7 @@
!$omp parallel num_threads(4)
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
!$omp flush (array)
!$omp end master
diff --git a/flang/test/Semantics/OpenMP/nested-barrier.f90 b/flang/test/Semantics/OpenMP/nested-barrier.f90
index aae283229e330d..7c635d8e23cc0d 100644
--- a/flang/test/Semantics/OpenMP/nested-barrier.f90
+++ b/flang/test/Semantics/OpenMP/nested-barrier.f90
@@ -75,7 +75,7 @@ program omp_nest_barrier
end do
!$omp end critical
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
do i = 1, 10
k = k + 1
@@ -108,7 +108,7 @@ program omp_nest_barrier
end do
!$omp end ordered
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
do i = 1, 10
!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
diff --git a/flang/test/Semantics/OpenMP/nested-master.f90 b/flang/test/Semantics/OpenMP/nested-master.f90
index 069de67cafae28..b21ca5d1415931 100644
--- a/flang/test/Semantics/OpenMP/nested-master.f90
+++ b/flang/test/Semantics/OpenMP/nested-master.f90
@@ -9,7 +9,7 @@ program omp_nest_master
!$omp do
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -17,7 +17,7 @@ program omp_nest_master
end do
!$omp sections
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -27,7 +27,7 @@ program omp_nest_master
!$omp end sections
!$omp single
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -41,7 +41,7 @@ program omp_nest_master
!$omp task
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -52,7 +52,7 @@ program omp_nest_master
!$omp taskloop
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -63,7 +63,7 @@ program omp_nest_master
!$omp target parallel do simd
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
@@ -75,7 +75,7 @@ program omp_nest_master
!$omp critical
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
j = j -1
!$omp end master
@@ -85,7 +85,7 @@ program omp_nest_master
!$omp ordered
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
j = j -1
!$omp end master
@@ -99,7 +99,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
j = j -1
!$omp end master
@@ -116,7 +116,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
j = j -1
!$omp end master
@@ -133,7 +133,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -151,7 +151,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
diff --git a/flang/test/Semantics/OpenMP/nested-teams.f90 b/flang/test/Semantics/OpenMP/nested-teams.f90
index f3b96b0ab43903..06eea12aba5595 100644
--- a/flang/test/Semantics/OpenMP/nested-teams.f90
+++ b/flang/test/Semantics/OpenMP/nested-teams.f90
@@ -42,7 +42,7 @@ program main
!$omp end teams
end do
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$omp master
!ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
!$omp teams
diff --git a/flang/test/Semantics/OpenMP/ordered-simd.f90 b/flang/test/Semantics/OpenMP/ordered-simd.f90
index ed52b759491002..716dc42c28bb64 100644
--- a/flang/test/Semantics/OpenMP/ordered-simd.f90
+++ b/flang/test/Semantics/OpenMP/ordered-simd.f90
@@ -95,7 +95,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP CRITICAL
C = C - A * B
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -108,7 +108,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP ORDERED
C = C - A * B
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -121,7 +121,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASK
C = C - A * B
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
@@ -136,7 +136,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASKLOOP
DO J= 1,N
C = C - A * B
- !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
+ !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
>From 2fc4fd7293ee3b48307189472cb2011beb930815 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Sun, 27 Oct 2024 16:02:06 +0000
Subject: [PATCH 2/2] [Flang][OpenMP] Add frontend support for directives
involving master
Issue deprecation warning for these directives.
Lowering currently supports parallel master, for all other combined or
composite directives involving master, issue TODO errors.
---
.../flang/Semantics/openmp-directive-sets.h | 1 +
flang/lib/Parser/openmp-parsers.cpp | 8 ++
flang/lib/Parser/unparse.cpp | 15 ++++
flang/lib/Semantics/resolve-directives.cpp | 41 +++++++++--
flang/test/Lower/OpenMP/master_taskloop.f90 | 14 ++++
.../Lower/OpenMP/master_taskloop_simd.f90 | 14 ++++
.../OpenMP/parallel-master-taskloop-simd.f90 | 14 ++++
.../Lower/OpenMP/parallel-master-taskloop.f90 | 14 ++++
flang/test/Lower/OpenMP/parallel-master.f90 | 16 ++++
flang/test/Parser/OpenMP/master-unparse.f90 | 73 +++++++++++++++++++
flang/test/Semantics/OpenMP/deprecation.f90 | 59 +++++++++++++++
11 files changed, 263 insertions(+), 6 deletions(-)
create mode 100644 flang/test/Lower/OpenMP/master_taskloop.f90
create mode 100644 flang/test/Lower/OpenMP/master_taskloop_simd.f90
create mode 100644 flang/test/Lower/OpenMP/parallel-master-taskloop-simd.f90
create mode 100644 flang/test/Lower/OpenMP/parallel-master-taskloop.f90
create mode 100644 flang/test/Lower/OpenMP/parallel-master.f90
create mode 100644 flang/test/Parser/OpenMP/master-unparse.f90
create mode 100644 flang/test/Semantics/OpenMP/deprecation.f90
diff --git a/flang/include/flang/Semantics/openmp-directive-sets.h b/flang/include/flang/Semantics/openmp-directive-sets.h
index 8eb736bb098fe4..49bef95b1b96c7 100644
--- a/flang/include/flang/Semantics/openmp-directive-sets.h
+++ b/flang/include/flang/Semantics/openmp-directive-sets.h
@@ -210,6 +210,7 @@ static const OmpDirectiveSet blockConstructSet{
Directive::OMPD_ordered,
Directive::OMPD_parallel,
Directive::OMPD_parallel_masked,
+ Directive::OMPD_parallel_master,
Directive::OMPD_parallel_workshare,
Directive::OMPD_single,
Directive::OMPD_target,
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 59a8757e58e8cc..f5171502e8aad7 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -572,12 +572,19 @@ TYPE_PARSER(sourced(construct<OmpLoopDirective>(first(
"MASKED TASKLOOP SIMD" >>
pure(llvm::omp::Directive::OMPD_masked_taskloop_simd),
"MASKED TASKLOOP" >> pure(llvm::omp::Directive::OMPD_masked_taskloop),
+ "MASTER TASKLOOP SIMD" >>
+ pure(llvm::omp::Directive::OMPD_master_taskloop_simd),
+ "MASTER TASKLOOP" >> pure(llvm::omp::Directive::OMPD_master_taskloop),
"PARALLEL DO SIMD" >> pure(llvm::omp::Directive::OMPD_parallel_do_simd),
"PARALLEL DO" >> pure(llvm::omp::Directive::OMPD_parallel_do),
"PARALLEL MASKED TASKLOOP SIMD" >>
pure(llvm::omp::Directive::OMPD_parallel_masked_taskloop_simd),
"PARALLEL MASKED TASKLOOP" >>
pure(llvm::omp::Directive::OMPD_parallel_masked_taskloop),
+ "PARALLEL MASTER TASKLOOP SIMD" >>
+ pure(llvm::omp::Directive::OMPD_parallel_master_taskloop_simd),
+ "PARALLEL MASTER TASKLOOP" >>
+ pure(llvm::omp::Directive::OMPD_parallel_master_taskloop),
"SIMD" >> pure(llvm::omp::Directive::OMPD_simd),
"TARGET LOOP" >> pure(llvm::omp::Directive::OMPD_target_loop),
"TARGET PARALLEL DO SIMD" >>
@@ -695,6 +702,7 @@ TYPE_PARSER(construct<OmpBlockDirective>(first(
"MASTER" >> pure(llvm::omp::Directive::OMPD_master),
"ORDERED" >> pure(llvm::omp::Directive::OMPD_ordered),
"PARALLEL MASKED" >> pure(llvm::omp::Directive::OMPD_parallel_masked),
+ "PARALLEL MASTER" >> pure(llvm::omp::Directive::OMPD_parallel_master),
"PARALLEL WORKSHARE" >> pure(llvm::omp::Directive::OMPD_parallel_workshare),
"PARALLEL" >> pure(llvm::omp::Directive::OMPD_parallel),
"SINGLE" >> pure(llvm::omp::Directive::OMPD_single),
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 04df988223e8f8..729f5d2e24a618 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2264,6 +2264,12 @@ class UnparseVisitor {
case llvm::omp::Directive::OMPD_masked_taskloop:
Word("MASKED TASKLOOP");
break;
+ case llvm::omp::Directive::OMPD_master_taskloop_simd:
+ Word("MASTER TASKLOOP SIMD");
+ break;
+ case llvm::omp::Directive::OMPD_master_taskloop:
+ Word("MASTER TASKLOOP");
+ break;
case llvm::omp::Directive::OMPD_parallel_do:
Word("PARALLEL DO ");
break;
@@ -2276,6 +2282,12 @@ class UnparseVisitor {
case llvm::omp::Directive::OMPD_parallel_masked_taskloop:
Word("PARALLEL MASKED TASKLOOP");
break;
+ case llvm::omp::Directive::OMPD_parallel_master_taskloop_simd:
+ Word("PARALLEL MASTER TASKLOOP SIMD");
+ break;
+ case llvm::omp::Directive::OMPD_parallel_master_taskloop:
+ Word("PARALLEL MASTER TASKLOOP");
+ break;
case llvm::omp::Directive::OMPD_simd:
Word("SIMD ");
break;
@@ -2380,6 +2392,9 @@ class UnparseVisitor {
case llvm::omp::Directive::OMPD_parallel_masked:
Word("PARALLEL MASKED");
break;
+ case llvm::omp::Directive::OMPD_parallel_master:
+ Word("PARALLEL MASTER");
+ break;
case llvm::omp::Directive::OMPD_parallel_workshare:
Word("PARALLEL WORKSHARE ");
break;
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index e4c10cee94bcba..3059eb313711d9 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1524,6 +1524,7 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
case llvm::omp::Directive::OMPD_masked:
case llvm::omp::Directive::OMPD_parallel_masked:
case llvm::omp::Directive::OMPD_master:
+ case llvm::omp::Directive::OMPD_parallel_master:
case llvm::omp::Directive::OMPD_ordered:
case llvm::omp::Directive::OMPD_parallel:
case llvm::omp::Directive::OMPD_single:
@@ -1542,7 +1543,8 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
// TODO others
break;
}
- if (beginDir.v == llvm::omp::Directive::OMPD_master)
+ if (beginDir.v == llvm::omp::Directive::OMPD_master ||
+ beginDir.v == llvm::omp::Directive::OMPD_parallel_master)
IssueNonConformanceWarning(beginDir.v, beginDir.source);
ClearDataSharingAttributeObjects();
ClearPrivateDataSharingAttributeObjects();
@@ -1555,7 +1557,9 @@ void OmpAttributeVisitor::Post(const parser::OpenMPBlockConstruct &x) {
const auto &beginDir{std::get<parser::OmpBlockDirective>(beginBlockDir.t)};
switch (beginDir.v) {
case llvm::omp::Directive::OMPD_masked:
+ case llvm::omp::Directive::OMPD_master:
case llvm::omp::Directive::OMPD_parallel_masked:
+ case llvm::omp::Directive::OMPD_parallel_master:
case llvm::omp::Directive::OMPD_parallel:
case llvm::omp::Directive::OMPD_single:
case llvm::omp::Directive::OMPD_target:
@@ -1625,10 +1629,14 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
case llvm::omp::Directive::OMPD_loop:
case llvm::omp::Directive::OMPD_masked_taskloop_simd:
case llvm::omp::Directive::OMPD_masked_taskloop:
+ case llvm::omp::Directive::OMPD_master_taskloop_simd:
+ case llvm::omp::Directive::OMPD_master_taskloop:
case llvm::omp::Directive::OMPD_parallel_do:
case llvm::omp::Directive::OMPD_parallel_do_simd:
case llvm::omp::Directive::OMPD_parallel_masked_taskloop_simd:
case llvm::omp::Directive::OMPD_parallel_masked_taskloop:
+ case llvm::omp::Directive::OMPD_parallel_master_taskloop_simd:
+ case llvm::omp::Directive::OMPD_parallel_master_taskloop:
case llvm::omp::Directive::OMPD_simd:
case llvm::omp::Directive::OMPD_target_loop:
case llvm::omp::Directive::OMPD_target_parallel_do:
@@ -1653,7 +1661,11 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
default:
break;
}
- if (beginDir.v == llvm::omp::Directive::OMPD_target_loop)
+ if (beginDir.v == llvm::omp::OMPD_master_taskloop ||
+ beginDir.v == llvm::omp::OMPD_master_taskloop_simd ||
+ beginDir.v == llvm::omp::OMPD_parallel_master_taskloop ||
+ beginDir.v == llvm::omp::OMPD_parallel_master_taskloop_simd ||
+ beginDir.v == llvm::omp::Directive::OMPD_target_loop)
IssueNonConformanceWarning(beginDir.v, beginDir.source);
ClearDataSharingAttributeObjects();
SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList));
@@ -2882,7 +2894,10 @@ void OmpAttributeVisitor::IssueNonConformanceWarning(
llvm::omp::Directive D, parser::CharBlock source) {
std::string warnStr;
llvm::raw_string_ostream warnStrOS(warnStr);
- warnStrOS << "OpenMP directive " << parser::ToUpperCaseLetters(llvm::omp::getOpenMPDirectiveName(D).str()) << " has been deprecated";
+ warnStrOS << "OpenMP directive "
+ << parser::ToUpperCaseLetters(
+ llvm::omp::getOpenMPDirectiveName(D).str())
+ << " has been deprecated";
auto setAlternativeStr = [&warnStrOS](llvm::StringRef alt) {
warnStrOS << ", please use " << alt << " instead.";
@@ -2891,11 +2906,25 @@ void OmpAttributeVisitor::IssueNonConformanceWarning(
case llvm::omp::OMPD_master:
setAlternativeStr("MASKED");
break;
+ case llvm::omp::OMPD_master_taskloop:
+ setAlternativeStr("MASKED TASKLOOP");
+ break;
+ case llvm::omp::OMPD_master_taskloop_simd:
+ setAlternativeStr("MASKED TASKLOOP SIMD");
+ break;
+ case llvm::omp::OMPD_parallel_master:
+ setAlternativeStr("PARALLEL MASKED");
+ break;
+ case llvm::omp::OMPD_parallel_master_taskloop:
+ setAlternativeStr("PARALLEL MASKED TASKLOOP");
+ break;
+ case llvm::omp::OMPD_parallel_master_taskloop_simd:
+ setAlternativeStr("PARALLEL_MASKED TASKLOOP SIMD");
break;
case llvm::omp::OMPD_target_loop:
- default:
+ default:;
}
- context_.Warn(
- common::UsageWarning::OpenMPUsage, source, "%s"_warn_en_US, warnStrOS.str());
+ context_.Warn(common::UsageWarning::OpenMPUsage, source, "%s"_warn_en_US,
+ warnStrOS.str());
}
} // namespace Fortran::semantics
diff --git a/flang/test/Lower/OpenMP/master_taskloop.f90 b/flang/test/Lower/OpenMP/master_taskloop.f90
new file mode 100644
index 00000000000000..26f664b2662dcb
--- /dev/null
+++ b/flang/test/Lower/OpenMP/master_taskloop.f90
@@ -0,0 +1,14 @@
+! This test checks lowering of OpenMP master taskloop Directive.
+
+! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+
+subroutine test_master_taskloop
+ integer :: i, j = 1
+ !CHECK: not yet implemented: Taskloop construct
+ !$omp master taskloop
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end master taskloop
+end subroutine
diff --git a/flang/test/Lower/OpenMP/master_taskloop_simd.f90 b/flang/test/Lower/OpenMP/master_taskloop_simd.f90
new file mode 100644
index 00000000000000..e928afd65244a4
--- /dev/null
+++ b/flang/test/Lower/OpenMP/master_taskloop_simd.f90
@@ -0,0 +1,14 @@
+! This test checks lowering of OpenMP master taskloop simd Directive.
+
+! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+
+subroutine test_master_taskloop_simd()
+ integer :: i, j = 1
+ !CHECK: not yet implemented: Composite TASKLOOP SIMD
+ !$omp master taskloop simd
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end master taskloop simd
+end subroutine
diff --git a/flang/test/Lower/OpenMP/parallel-master-taskloop-simd.f90 b/flang/test/Lower/OpenMP/parallel-master-taskloop-simd.f90
new file mode 100644
index 00000000000000..086ed01d16d364
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-master-taskloop-simd.f90
@@ -0,0 +1,14 @@
+! This test checks lowering of OpenMP parallel master taskloop simd Directive.
+
+! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+
+subroutine test_parallel_master_taskloop_simd
+ integer :: i, j = 1
+ !CHECK: not yet implemented: Composite TASKLOOP SIMD
+ !$omp parallel master taskloop simd
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end parallel master taskloop simd
+end subroutine
diff --git a/flang/test/Lower/OpenMP/parallel-master-taskloop.f90 b/flang/test/Lower/OpenMP/parallel-master-taskloop.f90
new file mode 100644
index 00000000000000..17ceb9496c8d34
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-master-taskloop.f90
@@ -0,0 +1,14 @@
+! This test checks lowering of OpenMP parallel master taskloop Directive.
+
+! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
+
+subroutine test_parallel_master_taskloop
+ integer :: i, j = 1
+ !CHECK: not yet implemented: Taskloop construct
+ !$omp parallel master taskloop
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end parallel master taskloop
+end subroutine
diff --git a/flang/test/Lower/OpenMP/parallel-master.f90 b/flang/test/Lower/OpenMP/parallel-master.f90
new file mode 100644
index 00000000000000..8f3ee31b328537
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-master.f90
@@ -0,0 +1,16 @@
+! This test checks lowering of the parallel master combined construct.
+
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
+
+! CHECK-LABEL: func @_QPparallel_master
+subroutine parallel_master(x)
+ integer :: x
+ !CHECK: omp.parallel {
+ !CHECK: omp.master {
+ !$omp parallel master
+ x = 1
+ !$omp end parallel master
+ !CHECK: }
+ !CHECK: }
+end subroutine parallel_master
diff --git a/flang/test/Parser/OpenMP/master-unparse.f90 b/flang/test/Parser/OpenMP/master-unparse.f90
new file mode 100644
index 00000000000000..30c293a521b5d1
--- /dev/null
+++ b/flang/test/Parser/OpenMP/master-unparse.f90
@@ -0,0 +1,73 @@
+! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s
+! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+! Check for parsing of master directive
+
+
+subroutine test_master()
+ integer :: c = 1
+ !PARSE-TREE: OmpBeginBlockDirective
+ !PARSE-TREE-NEXT: OmpBlockDirective -> llvm::omp::Directive = master
+ !CHECK: !$omp master
+ !$omp master
+ c = c + 1
+ !$omp end master
+end subroutine
+
+subroutine test_master_taskloop_simd()
+ integer :: i, j = 1
+ !PARSE-TREE: OmpBeginLoopDirective
+ !PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = master taskloop simd
+ !CHECK: !$omp master taskloop simd
+ !$omp master taskloop simd
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end master taskloop simd
+end subroutine
+
+subroutine test_master_taskloop
+ integer :: i, j = 1
+ !PARSE-TREE: OmpBeginLoopDirective
+ !PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = master taskloop
+ !CHECK: !$omp master taskloop
+ !$omp master taskloop
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end master taskloop
+end subroutine
+
+subroutine test_parallel_master
+ integer :: c = 2
+ !PARSE-TREE: OmpBeginBlockDirective
+ !PARSE-TREE-NEXT: OmpBlockDirective -> llvm::omp::Directive = parallel master
+ !CHECK: !$omp parallel master
+ !$omp parallel master
+ c = c + 2
+ !$omp end parallel master
+end subroutine
+
+subroutine test_parallel_master_taskloop_simd
+ integer :: i, j = 1
+ !PARSE-TREE: OmpBeginLoopDirective
+ !PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = parallel master taskloop simd
+ !CHECK: !$omp parallel master taskloop simd
+ !$omp parallel master taskloop simd
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end parallel master taskloop simd
+end subroutine
+
+subroutine test_parallel_master_taskloop
+ integer :: i, j = 1
+ !PARSE-TREE: OmpBeginLoopDirective
+ !PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = parallel master taskloop
+ !CHECK: !$omp parallel master taskloop
+ !$omp parallel master taskloop
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end parallel master taskloop
+end subroutine
diff --git a/flang/test/Semantics/OpenMP/deprecation.f90 b/flang/test/Semantics/OpenMP/deprecation.f90
new file mode 100644
index 00000000000000..dc1b074b6b7ffd
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/deprecation.f90
@@ -0,0 +1,59 @@
+! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -Werror
+
+! Check for deprecation of master directive and its combined/composite variants
+
+subroutine test_master()
+ integer :: c = 1
+!WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
+ !$omp master
+ c = c + 1
+ !$omp end master
+end subroutine
+
+subroutine test_parallel_master
+ integer :: c = 2
+!WARNING: OpenMP directive PARALLEL MASTER has been deprecated, please use PARALLEL MASKED instead.
+ !$omp parallel master
+ c = c + 2
+ !$omp end parallel master
+end subroutine
+
+subroutine test_master_taskloop_simd()
+ integer :: i, j = 1
+!WARNING: OpenMP directive MASTER TASKLOOP SIMD has been deprecated, please use MASKED TASKLOOP SIMD instead.
+ !$omp master taskloop simd
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end master taskloop simd
+end subroutine
+
+subroutine test_master_taskloop
+ integer :: i, j = 1
+!WARNING: OpenMP directive MASTER TASKLOOP has been deprecated, please use MASKED TASKLOOP instead.
+ !$omp master taskloop
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end master taskloop
+end subroutine
+
+subroutine test_parallel_master_taskloop_simd
+ integer :: i, j = 1
+!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP SIMD has been deprecated, please use PARALLEL_MASKED TASKLOOP SIMD instead.
+ !$omp parallel master taskloop simd
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end parallel master taskloop simd
+end subroutine
+
+subroutine test_parallel_master_taskloop
+ integer :: i, j = 1
+!WARNING: OpenMP directive PARALLEL MASTER TASKLOOP has been deprecated, please use PARALLEL MASKED TASKLOOP instead.
+ !$omp parallel master taskloop
+ do i=1,10
+ j = j + 1
+ end do
+ !$omp end parallel master taskloop
+end subroutine
More information about the flang-commits
mailing list