From: Kelvin Li Date: Mon, 20 Jun 2016 19:16:34 +0000 (+0000) Subject: [OpenMP] Add the nowait clause to target update construct. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c22cde5f80cd44a7c3b2f96f921a430f90ecaad2;p=clang [OpenMP] Add the nowait clause to target update construct. Differential Revision: http://reviews.llvm.org/D21477 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273190 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index cf91bc78c2..eb2a78e0fe 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -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. diff --git a/test/OpenMP/target_update_ast_print.cpp b/test/OpenMP/target_update_ast_print.cpp index fcb8625d7b..d739aab96b 100644 --- a/test/OpenMP/target_update_ast_print.cpp +++ b/test/OpenMP/target_update_ast_print.cpp @@ -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 index 0000000000..19bc58ea46 --- /dev/null +++ b/test/OpenMP/target_update_nowait_messages.cpp @@ -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; +}