r274352 - [OpenMP] Issue warning if a simd construct nested inside another simd
Kelvin Li via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 1 07:30:26 PDT 2016
Author: kli
Date: Fri Jul 1 09:30:25 2016
New Revision: 274352
URL: http://llvm.org/viewvc/llvm-project?rev=274352&view=rev
Log:
[OpenMP] Issue warning if a simd construct nested inside another simd
construct
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=274352&r1=274351&r2=274352&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 1 09:30:25 2016
@@ -8318,6 +8318,9 @@ def err_omp_expected_int_param : Error<
"expected a reference to an integer-typed parameter">;
def err_omp_at_least_one_motion_clause_required : Error<
"expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'">;
+def warn_omp_nesting_simd : Warning<
+ "OpenMP only allows an ordered construct with the simd clause nested in a simd construct">,
+ InGroup<SourceUsesOpenMP>;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=274352&r1=274351&r2=274352&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jul 1 09:30:25 2016
@@ -2940,15 +2940,19 @@ static bool CheckNestingOfRegions(Sema &
ShouldBeInTargetRegion,
ShouldBeInTeamsRegion
} Recommend = NoRecommend;
- if (isOpenMPSimdDirective(ParentRegion) && CurrentRegion != OMPD_ordered &&
- CurrentRegion != OMPD_simd) {
+ if (isOpenMPSimdDirective(ParentRegion) && CurrentRegion != OMPD_ordered) {
// OpenMP [2.16, Nesting of Regions]
// OpenMP constructs may not be nested inside a simd region.
// OpenMP [2.8.1,simd Construct, Restrictions]
- // An ordered construct with the simd clause is the only OpenMP construct
- // that can appear in the simd region.
- SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_simd);
- return true;
+ // An ordered construct with the simd clause is the only OpenMP
+ // construct that can appear in the simd region.
+ // Allowing a SIMD consruct nested in another SIMD construct is an
+ // extension. The OpenMP 4.5 spec does not allow it. Issue a warning
+ // message.
+ SemaRef.Diag(StartLoc, (CurrentRegion != OMPD_simd)
+ ? diag::err_omp_prohibited_region_simd
+ : diag::warn_omp_nesting_simd);
+ return CurrentRegion != OMPD_simd;
}
if (ParentRegion == OMPD_atomic) {
// OpenMP [2.16, Nesting of Regions]
Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=274352&r1=274351&r2=274352&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Fri Jul 1 09:30:25 2016
@@ -153,7 +153,7 @@ void foo() {
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}}
for (int i = 0; i < 10; ++i)
;
}
@@ -257,6 +257,16 @@ void foo() {
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
+#pragma omp ordered simd // OK
+ bar();
+ }
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ bar();
+ }
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
@@ -516,7 +526,7 @@ void foo() {
}
#pragma omp for simd
for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}}
for (int i = 0; i < 10; ++i)
;
}
@@ -620,6 +630,16 @@ void foo() {
}
#pragma omp for simd
for (int i = 0; i < 10; ++i) {
+#pragma omp ordered simd // OK
+ bar();
+ }
+#pragma omp for simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ bar();
+ }
+#pragma omp for simd
+ for (int i = 0; i < 10; ++i) {
#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
++a;
}
@@ -1902,7 +1922,7 @@ void foo() {
}
#pragma omp parallel for simd
for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}}
for (int i = 0; i < 10; ++i)
;
}
@@ -4314,7 +4334,7 @@ void foo() {
}
#pragma omp simd
for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}}
for (int i = 0; i < 10; ++i)
;
}
@@ -4662,7 +4682,7 @@ void foo() {
}
#pragma omp for simd
for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}}
for (int i = 0; i < 10; ++i)
;
}
@@ -6022,7 +6042,7 @@ void foo() {
}
#pragma omp parallel for simd
for (int i = 0; i < 10; ++i) {
-#pragma omp simd
+#pragma omp simd // expected-warning {{OpenMP only allows an ordered construct with the simd clause nested in a simd construct}}
for (int i = 0; i < 10; ++i)
;
}
More information about the cfe-commits
mailing list