-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Openmp 6.0 allow default clause on the target directive #154942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: CHANDRA GHALE (chandraghale) ChangesSections 7.5.1 default Clause in OpenMP 6.0. Allow default clause on the target directive. Full diff: https://github.com/llvm/llvm-project/pull/154942.diff 3 Files Affected:
diff --git a/clang/test/OpenMP/target_default_ast.cpp b/clang/test/OpenMP/target_default_ast.cpp
new file mode 100644
index 0000000000000..854bea21d7f81
--- /dev/null
+++ b/clang/test/OpenMP/target_default_ast.cpp
@@ -0,0 +1,81 @@
+// expected-no-diagnostics
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -emit-pch -o %t %s
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+ int a;
+#pragma omp target default(firstprivate)
+ a++;
+ // PRINT: #pragma omp target default(firstprivate)
+ // PRINT-NEXT: a++;
+ // DUMP: -OMPTargetDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+
+}
+void fun(){
+int a = 0;
+ int x = 10;
+ #pragma omp target data default(firstprivate) map(a)
+ {
+ // DUMP: -OMPTargetDataDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPMapClause
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'x'
+
+
+ x += 10;
+ a += 1;
+ }
+}
+void bar(){
+int i = 0;
+int j = 0;
+int nn = 10;
+#pragma omp target default(firstprivate)
+#pragma omp teams
+#pragma teams distribute parallel for simd
+ for (j = 0; j < nn; j++ ) {
+ for (i = 0; i < nn; i++ ) {
+ ;
+ }
+ }
+
+ // PRINT: #pragma omp target default(firstprivate)
+ // DUMP: -OMPTargetDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'j'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'nn'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'i'
+}
+#endif
diff --git a/clang/test/OpenMP/target_default_messages.cpp b/clang/test/OpenMP/target_default_messages.cpp
new file mode 100644
index 0000000000000..c90c4f9a9cadc
--- /dev/null
+++ b/clang/test/OpenMP/target_default_messages.cpp
@@ -0,0 +1,51 @@
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -DOMP60 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -DOMP60 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -DOMP52 %s -Wuninitialized
+
+void foo();
+
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
+int main(int argc, char **argv) {
+#ifdef OMP60
+ #pragma omp target default // expected-error {{expected '(' after 'default'}}
+ for (int i=0; i<200; i++) foo();
+#pragma omp target default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ for (int i=0; i<200; i++) foo();
+#pragma omp target default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ for (int i=0; i<200; i++) foo();
+ #pragma omp target default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ for (int i=0; i<200; i++) foo();
+#pragma omp target default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ for (int i=0; i<200; i++) foo();
+#endif
+
+#ifdef OMP52
+#pragma omp target default(firstprivate) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target'}}
+ for (int i = 0; i < 200; i++) {
+ ++x;
+ ++y;
+ }
+#pragma omp target default(private) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target'}}
+ for (int i = 0; i < 200; i++) {
+ ++x;
+ ++y;
+ }
+
+int j = 0, i = 0, nn = 10;
+#pragma omp target teams distribute simd default(shared) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target teams distribute simd'}}
+ for (j = 0; j < nn; j++ ) {
+ for (i = 0; i < nn; i++ ) {
+ ;
+ }
+ }
+#endif
+
+ return 0;
+}
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index 8d62f7422a9dc..8fdb627705a8a 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1112,6 +1112,7 @@ def OMP_Target : Directive<[Spelling<"target">]> {
VersionedClause<OMPC_OMPX_Attribute>,
VersionedClause<OMPC_Private>,
VersionedClause<OMPC_UsesAllocators, 50>,
+ VersionedClause<OMPC_Default, 60>,
];
let allowedOnceClauses = [
VersionedClause<OMPC_DefaultMap>,
@@ -1130,6 +1131,7 @@ def OMP_TargetData : Directive<[Spelling<"target data", 1, 52>,
let allowedOnceClauses = [
VersionedClause<OMPC_Device>,
VersionedClause<OMPC_If>,
+ VersionedClause<OMPC_Default, 60>,
];
let requiredClauses = [
VersionedClause<OMPC_Map>,
@@ -2463,6 +2465,7 @@ def OMP_TargetTeamsDistributeSimd
VersionedClause<OMPC_Reduction>,
VersionedClause<OMPC_Shared>,
VersionedClause<OMPC_UsesAllocators, 50>,
+ VersionedClause<OMPC_Default, 60>,
];
let allowedOnceClauses = [
VersionedClause<OMPC_Collapse>,
|
@llvm/pr-subscribers-flang-openmp Author: CHANDRA GHALE (chandraghale) ChangesSections 7.5.1 default Clause in OpenMP 6.0. Allow default clause on the target directive. Full diff: https://github.com/llvm/llvm-project/pull/154942.diff 3 Files Affected:
diff --git a/clang/test/OpenMP/target_default_ast.cpp b/clang/test/OpenMP/target_default_ast.cpp
new file mode 100644
index 0000000000000..854bea21d7f81
--- /dev/null
+++ b/clang/test/OpenMP/target_default_ast.cpp
@@ -0,0 +1,81 @@
+// expected-no-diagnostics
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -ast-dump %s | FileCheck %s --check-prefix=DUMP
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -emit-pch -o %t %s
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 \
+//RUN: -x c++ -std=c++14 -fexceptions -fcxx-exceptions \
+//RUN: -Wno-source-uses-openmp -Wno-openmp-clauses \
+//RUN: -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+ int a;
+#pragma omp target default(firstprivate)
+ a++;
+ // PRINT: #pragma omp target default(firstprivate)
+ // PRINT-NEXT: a++;
+ // DUMP: -OMPTargetDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+
+}
+void fun(){
+int a = 0;
+ int x = 10;
+ #pragma omp target data default(firstprivate) map(a)
+ {
+ // DUMP: -OMPTargetDataDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPMapClause
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'a'
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'x'
+
+
+ x += 10;
+ a += 1;
+ }
+}
+void bar(){
+int i = 0;
+int j = 0;
+int nn = 10;
+#pragma omp target default(firstprivate)
+#pragma omp teams
+#pragma teams distribute parallel for simd
+ for (j = 0; j < nn; j++ ) {
+ for (i = 0; i < nn; i++ ) {
+ ;
+ }
+ }
+
+ // PRINT: #pragma omp target default(firstprivate)
+ // DUMP: -OMPTargetDirective
+ // DUMP-NEXT: -OMPDefaultClause
+ // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit>
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'j'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'nn'
+ // DUMP-NEXT: -DeclRefExpr {{.*}} 'i'
+}
+#endif
diff --git a/clang/test/OpenMP/target_default_messages.cpp b/clang/test/OpenMP/target_default_messages.cpp
new file mode 100644
index 0000000000000..c90c4f9a9cadc
--- /dev/null
+++ b/clang/test/OpenMP/target_default_messages.cpp
@@ -0,0 +1,51 @@
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -DOMP60 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -DOMP60 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -DOMP52 %s -Wuninitialized
+
+void foo();
+
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
+int main(int argc, char **argv) {
+#ifdef OMP60
+ #pragma omp target default // expected-error {{expected '(' after 'default'}}
+ for (int i=0; i<200; i++) foo();
+#pragma omp target default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+ for (int i=0; i<200; i++) foo();
+#pragma omp target default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ for (int i=0; i<200; i++) foo();
+ #pragma omp target default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ for (int i=0; i<200; i++) foo();
+#pragma omp target default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
+ for (int i=0; i<200; i++) foo();
+#endif
+
+#ifdef OMP52
+#pragma omp target default(firstprivate) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target'}}
+ for (int i = 0; i < 200; i++) {
+ ++x;
+ ++y;
+ }
+#pragma omp target default(private) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target'}}
+ for (int i = 0; i < 200; i++) {
+ ++x;
+ ++y;
+ }
+
+int j = 0, i = 0, nn = 10;
+#pragma omp target teams distribute simd default(shared) // expected-error {{unexpected OpenMP clause 'default' in directive '#pragma omp target teams distribute simd'}}
+ for (j = 0; j < nn; j++ ) {
+ for (i = 0; i < nn; i++ ) {
+ ;
+ }
+ }
+#endif
+
+ return 0;
+}
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index 8d62f7422a9dc..8fdb627705a8a 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1112,6 +1112,7 @@ def OMP_Target : Directive<[Spelling<"target">]> {
VersionedClause<OMPC_OMPX_Attribute>,
VersionedClause<OMPC_Private>,
VersionedClause<OMPC_UsesAllocators, 50>,
+ VersionedClause<OMPC_Default, 60>,
];
let allowedOnceClauses = [
VersionedClause<OMPC_DefaultMap>,
@@ -1130,6 +1131,7 @@ def OMP_TargetData : Directive<[Spelling<"target data", 1, 52>,
let allowedOnceClauses = [
VersionedClause<OMPC_Device>,
VersionedClause<OMPC_If>,
+ VersionedClause<OMPC_Default, 60>,
];
let requiredClauses = [
VersionedClause<OMPC_Map>,
@@ -2463,6 +2465,7 @@ def OMP_TargetTeamsDistributeSimd
VersionedClause<OMPC_Reduction>,
VersionedClause<OMPC_Shared>,
VersionedClause<OMPC_UsesAllocators, 50>,
+ VersionedClause<OMPC_Default, 60>,
];
let allowedOnceClauses = [
VersionedClause<OMPC_Collapse>,
|
@chandraghale - Hi Chandra. Not sure if you are aware of the following, so I thought I would pass it along for future reference. Per discussions in the OpenMP in LLVM biweekly meeting, it was decided that the OpenMPSupport.rst file should be kept up to date with information noting which OpenMP features are unclaimed, in progress, partially done, or done. This has been the case now for a few months, so when looking to work on a new feature, this file should be consulted first to ensure work is not duplicated. This feature (default clause on target) was already marked as "In Progress" in the OpenMPSupport.rst file, which indicates that someone is either preparing to work on, or already working on, this feature. In this particular case, I had already started some work on this feature. Your changes look fine to me as well, but Shilei's comment on the test should be addressed. I'll contact you directly so we can determine the status of any other related work done so far (beyond just enabling the clause). |
437bf4c
to
cd47a30
Compare
@ddpagan Thank you for the infomation. I wasn’t fully aware of that. Since you’ve made significant progress on the feature, I’ll limit my changes to just enabling the clause. |
Sections 7.5.1 default Clause in OpenMP 6.0. Allow default clause on the target directive.