]> granicus.if.org Git - clang/commitdiff
[OPENMP 4.5] Allow 'ordered' clause on 'loop simd' constructs.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 30 Dec 2015 12:06:23 +0000 (12:06 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 30 Dec 2015 12:06:23 +0000 (12:06 +0000)
OpenMP 4.5 allows to use 'ordered' clause without parameter on 'loop simd' constructs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256639 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/OpenMPKinds.def
lib/Sema/SemaOpenMP.cpp
test/OpenMP/for_simd_ast_print.cpp
test/OpenMP/for_simd_loop_messages.cpp
test/OpenMP/nesting_of_regions.cpp
test/OpenMP/ordered_codegen.cpp
test/OpenMP/parallel_for_simd_ast_print.cpp
test/OpenMP/parallel_for_simd_loop_messages.cpp
test/OpenMP/parallel_for_simd_messages.cpp

index 1f2791c1c8fc84904467305f8385f0239e7697e0..25fbe2db1ca8ee8dce97ef2ab7d3c7e2eea51d4d 100644 (file)
@@ -7969,6 +7969,8 @@ def err_omp_schedule_nonmonotonic_static : Error<
   "'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 {
index 313e1c1ac686b37f58cd4ba78614cd3ec22a9f0a..44f77ad32fd4f2ae6d53072fa026f766f9aee345 100644 (file)
@@ -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)
index 5dd835498a9ac522e97e13d4110910d3c102284d..f66e2181b28faee482a67980f4b40bbddd4c7a28 100644 (file)
@@ -1680,6 +1680,13 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S,
     }
     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();
index 725c727e261eb27d35c6175871843c5e60330249..d4b13ba1998c8cb0fc10018a60384805750928e7 100644 (file)
@@ -14,8 +14,8 @@ template<class T, class N> T reduct(T* arr, N num) {
   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;
index 958c7f60d0eb58d116143d655d52022100c7524f..afd7b0bb545e579fa77e81e9f53f36d467c4c659 100644 (file)
@@ -719,10 +719,18 @@ void test_loop_firstprivate_lastprivate() {
 
 void test_ordered() {
 #pragma omp parallel
-// expected-error@+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@+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() {
index 6445c6b1c6d98b2078db7453b0070dccf585228a..b2b87db6a158afa596fc9e67d2548677a396bf93 100644 (file)
@@ -2060,7 +2060,7 @@ 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}}
       {
@@ -2070,6 +2070,16 @@ void foo() {
   }
 #pragma omp ordered
   {
+#pragma omp parallel for simd ordered
+    for (int j = 0; j < 10; ++j) {
+#pragma omp ordered simd
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp ordered
+  {
 #pragma omp parallel for
     for (int i = 0; i < 10; ++i)
       ;
index e77c1bed97caa6181816b50f5a36ff08cab3f11c..6448ddf08320d0697f2cccfff187b30b52bc8dd5 100644 (file)
@@ -221,6 +221,14 @@ void foo_simd(int low, int up) {
 #pragma omp simd
   for (int i = low; i < up; ++i) {
     f[i] = 0.0;
+#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;
   }
index e23c2cbd2428c44d7ea77f8e31aa89976f695c59..1b9415d8dbf30cafdca06b7693bea7844d57691c 100644 (file)
@@ -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;
index f4929d97d48499841e63f1aefbf4a88cf8cc8ca1..e5fd8c04c0cfc680ff24894cb9f5d7ac68c1d4f4 100644 (file)
@@ -628,10 +628,16 @@ void test_loop_firstprivate_lastprivate() {
 }
 
 void test_ordered() {
-// expected-error@+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@+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() {
index fe14883080c0602bc1b9d3ef181e59c222e8ac5b..18f25fa0f66ace49357b6fe991de7c87bd4035d8 100644 (file)
@@ -79,9 +79,15 @@ L1:
 }
 
 void test_ordered() {
-// expected-error@+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@+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)
+    ;
 }