]> granicus.if.org Git - clang/commitdiff
[OpenMP] Add the nowait clause to target update construct.
authorKelvin Li <kkwli0@gmail.com>
Mon, 20 Jun 2016 19:16:34 +0000 (19:16 +0000)
committerKelvin Li <kkwli0@gmail.com>
Mon, 20 Jun 2016 19:16:34 +0000 (19:16 +0000)
Differential Revision: http://reviews.llvm.org/D21477

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

include/clang/Basic/OpenMPKinds.def
test/OpenMP/target_update_ast_print.cpp
test/OpenMP/target_update_nowait_messages.cpp [new file with mode: 0644]

index cf91bc78c228c2103a7fc883701151db6ec71751..eb2a78e0fec36c696f02d55da85e9cb633b5a73d 100644 (file)
@@ -454,6 +454,7 @@ OPENMP_TARGET_UPDATE_CLAUSE(if)
 OPENMP_TARGET_UPDATE_CLAUSE(device)
 OPENMP_TARGET_UPDATE_CLAUSE(to)
 OPENMP_TARGET_UPDATE_CLAUSE(from)
+OPENMP_TARGET_UPDATE_CLAUSE(nowait)
 
 // Clauses allowed for OpenMP directive 'teams'.
 // TODO More clauses for 'teams' directive.
index fcb8625d7b237e46c6b7698e7542d3eba1c12eef..d739aab96bcd0ca5cf414a157319a3e3c28ba155 100644 (file)
@@ -13,26 +13,26 @@ T foo(T targ, U uarg) {
   static T a;
   U b;
   int l;
-#pragma omp target update to(a) if(l>5) device(l)
+#pragma omp target update to(a) if(l>5) device(l) nowait
 
-#pragma omp target update from(b) if(l<5) device(l-1)
+#pragma omp target update from(b) if(l<5) device(l-1) nowait
   return a + targ + (T)b;
 }
 // CHECK:      static int a;
 // CHECK-NEXT: float b;
 // CHECK-NEXT: int l;
 // CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l)
-// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1)
+// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait
 // CHECK:      static char a;
 // CHECK-NEXT: float b;
 // CHECK-NEXT: int l;
-// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l)
-// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1)
+// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait
+// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait
 // CHECK:      static T a;
 // CHECK-NEXT: U b;
 // CHECK-NEXT: int l;
-// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l)
-// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1)
+// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait
+// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait
 
 int main(int argc, char **argv) {
   static int a;
@@ -42,10 +42,10 @@ int main(int argc, char **argv) {
 // CHECK:      static int a;
 // CHECK-NEXT: int n;
 // CHECK-NEXT: float f;
-#pragma omp target update to(a) if(f>0.0) device(n)
-  // CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n)
-#pragma omp target update from(f) if(f<0.0) device(n+1)
-  // CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1)
+#pragma omp target update to(a) if(f>0.0) device(n) nowait
+// CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n) nowait
+#pragma omp target update from(f) if(f<0.0) device(n+1) nowait
+// CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1) nowait
   return foo(argc, f) + foo(argv[0][0], f) + a;
 }
 
diff --git a/test/OpenMP/target_update_nowait_messages.cpp b/test/OpenMP/target_update_nowait_messages.cpp
new file mode 100644 (file)
index 0000000..19bc58e
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+int main(int argc, char **argv) {
+  int i;
+
+  #pragma omp nowait target update to(i) // expected-error {{expected an OpenMP directive}}
+  #pragma omp target nowait update to(i) // expected-error {{unexpected OpenMP clause 'update' in directive '#pragma omp target'}} expected-error {{unexpected OpenMP clause 'to' in directive '#pragma omp target'}}
+  {}
+  #pragma omp target update nowait() to(i) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(i) nowait( // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
+  #pragma omp target update to(i) nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
+  #pragma omp target update to(i) nowait device (-10u)
+  #pragma omp target update to(i) nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
+  #pragma omp target update to(i) nowait nowait // expected-error {{directive '#pragma omp target update' cannot contain more than one 'nowait' clause}}
+  #pragma omp target update nowait to(i) nowait // expected-error {{directive '#pragma omp target update' cannot contain more than one 'nowait' clause}}
+  return 0;
+}