r256639 - [OPENMP 4.5] Allow 'ordered' clause on 'loop simd' constructs.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 30 04:06:28 PST 2015
Author: abataev
Date: Wed Dec 30 06:06:23 2015
New Revision: 256639
URL: http://llvm.org/viewvc/llvm-project?rev=256639&view=rev
Log:
[OPENMP 4.5] Allow 'ordered' clause on 'loop simd' constructs.
OpenMP 4.5 allows to use 'ordered' clause without parameter on 'loop simd' constructs.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 30 06:06:23 2015
@@ -7969,6 +7969,8 @@ def err_omp_schedule_nonmonotonic_static
"'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind">;
def err_omp_schedule_nonmonotonic_ordered : Error<
"'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 'ordered' clause is specified">;
+def err_omp_ordered_simd : Error<
+ "'ordered' clause with a parameter can not be specified in '#pragma omp %0' directive">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Dec 30 06:06:23 2015
@@ -220,6 +220,7 @@ OPENMP_FOR_SIMD_CLAUSE(safelen)
OPENMP_FOR_SIMD_CLAUSE(simdlen)
OPENMP_FOR_SIMD_CLAUSE(linear)
OPENMP_FOR_SIMD_CLAUSE(aligned)
+OPENMP_FOR_SIMD_CLAUSE(ordered)
// Clauses allowed for OpenMP directive 'omp sections'.
OPENMP_SECTIONS_CLAUSE(private)
@@ -303,6 +304,7 @@ OPENMP_PARALLEL_FOR_SIMD_CLAUSE(safelen)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(simdlen)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(linear)
OPENMP_PARALLEL_FOR_SIMD_CLAUSE(aligned)
+OPENMP_PARALLEL_FOR_SIMD_CLAUSE(ordered)
// Clauses allowed for OpenMP directive 'parallel sections'.
OPENMP_PARALLEL_SECTIONS_CLAUSE(if)
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 30 06:06:23 2015
@@ -1680,6 +1680,13 @@ StmtResult Sema::ActOnOpenMPRegionEnd(St
}
ErrorFound = true;
}
+ if (isOpenMPWorksharingDirective(DSAStack->getCurrentDirective()) &&
+ isOpenMPSimdDirective(DSAStack->getCurrentDirective()) && OC &&
+ OC->getNumForLoops()) {
+ Diag(OC->getLocStart(), diag::err_omp_ordered_simd)
+ << getOpenMPDirectiveName(DSAStack->getCurrentDirective());
+ ErrorFound = true;
+ }
if (ErrorFound) {
ActOnCapturedRegionError();
return StmtError();
Modified: cfe/trunk/test/OpenMP/for_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_ast_print.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_ast_print.cpp Wed Dec 30 06:06:23 2015
@@ -14,8 +14,8 @@ template<class T, class N> T reduct(T* a
N myind;
T sum = (T)0;
// CHECK: T sum = (T)0;
-#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr)
-// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr)
+#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr) ordered
+// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr) ordered
for (i = 0; i < num; ++i) {
myind = ind;
T cur = arr[myind];
@@ -92,8 +92,8 @@ int main (int argc, char **argv) {
int k1=0,k2=0;
static int *a;
// CHECK: static int *a;
-#pragma omp for simd
-// CHECK-NEXT: #pragma omp for simd
+#pragma omp for simd ordered
+// CHECK-NEXT: #pragma omp for simd ordered
for (int i=0; i < 2; ++i)*a=2;
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
// CHECK-NEXT: *a = 2;
Modified: cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp Wed Dec 30 06:06:23 2015
@@ -719,10 +719,18 @@ void test_loop_firstprivate_lastprivate(
void test_ordered() {
#pragma omp parallel
-// expected-error at +1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp for simd'}}
#pragma omp for simd ordered ordered // expected-error {{directive '#pragma omp for simd' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
+#pragma omp parallel
+#pragma omp for simd ordered
+ for (int i = 0; i < 16; ++i)
+ ;
+#pragma omp parallel
+// expected-error at +1 {{'ordered' clause with a parameter can not be specified in '#pragma omp for simd' directive}}
+#pragma omp for simd ordered(1)
+ for (int i = 0; i < 16; ++i)
+ ;
}
void test_nowait() {
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=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Wed Dec 30 06:06:23 2015
@@ -2060,12 +2060,22 @@ void foo() {
}
#pragma omp ordered
{
-#pragma omp parallel for simd ordered //expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
+#pragma omp parallel for simd ordered
for (int j = 0; j < 10; ++j) {
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
{
bar();
}
+ }
+ }
+#pragma omp ordered
+ {
+#pragma omp parallel for simd ordered
+ for (int j = 0; j < 10; ++j) {
+#pragma omp ordered simd
+ {
+ bar();
+ }
}
}
#pragma omp ordered
Modified: cfe/trunk/test/OpenMP/ordered_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/ordered_codegen.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/ordered_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/ordered_codegen.cpp Wed Dec 30 06:06:23 2015
@@ -224,6 +224,14 @@ void foo_simd(int low, int up) {
#pragma omp ordered simd
f[i] = 1.0;
}
+ // CHECK: store float 0.000000e+00, float* %{{.+}}, align {{[0-9]+}}, !llvm.mem.parallel_loop_access !
+ // CHECK-NEXT: call void [[CAP_FUNC:@.+]](i32* %{{.+}}) #{{[0-9]+}}, !llvm.mem.parallel_loop_access !
+#pragma omp for simd ordered
+ for (int i = low; i < up; ++i) {
+ f[i] = 0.0;
+#pragma omp ordered simd
+ f[i] = 1.0;
+ }
}
// CHECK: define internal void [[CAP_FUNC]](i32* dereferenceable({{[0-9]+}}) %{{.+}}) #
Modified: cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp Wed Dec 30 06:06:23 2015
@@ -44,8 +44,8 @@ template<class T> struct S {
}
const T clen = 3;
// CHECK: T clen = 3;
- #pragma omp parallel for simd safelen(clen-1) simdlen(clen-1)
-// CHECK-NEXT: #pragma omp parallel for simd safelen(clen - 1) simdlen(clen - 1)
+ #pragma omp parallel for simd safelen(clen-1) simdlen(clen-1) ordered
+// CHECK-NEXT: #pragma omp parallel for simd safelen(clen - 1) simdlen(clen - 1) ordered
for(T i = clen+2; i < 20; ++i) {
// CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
v[i] = v[v-clen] + 1;
@@ -92,8 +92,8 @@ int main (int argc, char **argv) {
int k1=0,k2=0;
static int *a;
// CHECK: static int *a;
-#pragma omp parallel for simd if(parallel :b)
-// CHECK-NEXT: #pragma omp parallel for simd if(parallel: b)
+#pragma omp parallel for simd if(parallel :b) ordered
+// CHECK-NEXT: #pragma omp parallel for simd if(parallel: b) ordered
for (int i=0; i < 2; ++i)*a=2;
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
// CHECK-NEXT: *a = 2;
Modified: cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp Wed Dec 30 06:06:23 2015
@@ -628,10 +628,16 @@ void test_loop_firstprivate_lastprivate(
}
void test_ordered() {
-// expected-error at +1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
+#pragma omp parallel for simd ordered
+ for (int i = 0; i < 16; ++i)
+ ;
+//expected-error at +1 {{'ordered' clause with a parameter can not be specified in '#pragma omp parallel for simd' directive}}
+#pragma omp parallel for simd ordered(1)
+ for (int i = 0; i < 16; ++i)
+ ;
}
void test_nowait() {
Modified: cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp?rev=256639&r1=256638&r2=256639&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp Wed Dec 30 06:06:23 2015
@@ -79,9 +79,15 @@ L1:
}
void test_ordered() {
-// expected-error at +1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
for (int i = 0; i < 16; ++i)
;
+#pragma omp parallel for simd ordered
+ for (int i = 0; i < 16; ++i)
+ ;
+// expected-error at +1 {{'ordered' clause with a parameter can not be specified in '#pragma omp parallel for simd' directive}}
+#pragma omp parallel for simd ordered(1)
+ for (int i = 0; i < 16; ++i)
+ ;
}
More information about the cfe-commits
mailing list