[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-commits
Subject: Re: [PATCH] D11619: [OPENMP] allow static local variable on data-sharing attribute clause
From: Kelvin Li <kkwli0 () gmail ! com>
Date: 2015-07-31 21:51:25
Message-ID: 98bcd108f8a08f8320cc0b779ea36835 () localhost ! localdomain
[Download RAW message or body]
kkwli0 updated this revision to Diff 31171.
kkwli0 added a comment.
Updated unit tests.
http://reviews.llvm.org/D11619
Files:
lib/Sema/SemaOpenMP.cpp
test/OpenMP/for_firstprivate_messages.cpp
test/OpenMP/for_lastprivate_messages.cpp
test/OpenMP/for_private_messages.cpp
test/OpenMP/for_reduction_messages.cpp
test/OpenMP/for_simd_firstprivate_messages.cpp
test/OpenMP/for_simd_lastprivate_messages.cpp
test/OpenMP/for_simd_private_messages.cpp
test/OpenMP/for_simd_reduction_messages.cpp
test/OpenMP/parallel_firstprivate_messages.cpp
test/OpenMP/parallel_for_firstprivate_messages.cpp
test/OpenMP/parallel_for_lastprivate_messages.cpp
test/OpenMP/parallel_for_private_messages.cpp
test/OpenMP/parallel_for_reduction_messages.cpp
test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
test/OpenMP/parallel_for_simd_private_messages.cpp
test/OpenMP/parallel_for_simd_reduction_messages.cpp
test/OpenMP/parallel_private_messages.cpp
test/OpenMP/parallel_reduction_messages.cpp
test/OpenMP/parallel_sections_firstprivate_messages.cpp
test/OpenMP/parallel_sections_lastprivate_messages.cpp
test/OpenMP/parallel_sections_private_messages.cpp
test/OpenMP/parallel_sections_reduction_messages.cpp
test/OpenMP/sections_firstprivate_messages.cpp
test/OpenMP/sections_lastprivate_messages.cpp
test/OpenMP/sections_private_messages.cpp
test/OpenMP/sections_reduction_messages.cpp
test/OpenMP/simd_lastprivate_messages.cpp
test/OpenMP/single_firstprivate_messages.cpp
test/OpenMP/single_private_messages.cpp
test/OpenMP/task_firstprivate_messages.cpp
test/OpenMP/task_private_messages.cpp
test/OpenMP/teams_firstprivate_messages.cpp
test/OpenMP/teams_private_messages.cpp
test/OpenMP/teams_reduction_messages.cpp
["D11619.31171.patch" (text/x-patch)]
Index: test/OpenMP/teams_reduction_messages.cpp
===================================================================
--- test/OpenMP/teams_reduction_messages.cpp
+++ test/OpenMP/teams_reduction_messages.cpp
@@ -310,6 +310,10 @@
#pragma omp target
#pragma omp teams reduction(+ : fl)
foo();
+ static int m;
+#pragma omp target
+#pragma omp teams reduction(+ : m) // OK
+ foo();
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/teams_private_messages.cpp
===================================================================
--- test/OpenMP/teams_private_messages.cpp
+++ test/OpenMP/teams_private_messages.cpp
@@ -122,6 +122,10 @@
#pragma omp parallel private(i)
foo();
}
+ static int m;
+ #pragma omp target
+ #pragma omp teams private(m) // OK
+ foo();
return 0;
}
Index: test/OpenMP/teams_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/teams_firstprivate_messages.cpp
+++ test/OpenMP/teams_firstprivate_messages.cpp
@@ -127,6 +127,10 @@
#pragma omp target
#pragma omp teams firstprivate(j) // expected-error {{arguments of OpenMP clause \
'firstprivate' cannot be of reference type}} foo();
+ static int m;
+#pragma omp target
+#pragma omp teams firstprivate(m) // OK
+ foo();
return 0;
}
Index: test/OpenMP/task_private_messages.cpp
===================================================================
--- test/OpenMP/task_private_messages.cpp
+++ test/OpenMP/task_private_messages.cpp
@@ -93,6 +93,9 @@
#pragma omp task private(i)
foo();
}
+ static int m;
+#pragma omp task private(m) // OK
+ foo();
return 0;
}
Index: test/OpenMP/task_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/task_firstprivate_messages.cpp
+++ test/OpenMP/task_firstprivate_messages.cpp
@@ -71,6 +71,7 @@
S5 g(5);
int i;
int &j = i; // expected-note {{'j' \
defined here}} + static int m;
#pragma omp task firstprivate // expected-error \
{{expected '(' after 'firstprivate'}} #pragma omp task firstprivate( \
// expected-error {{expected expression}} expected-error {{expected ')'}} \
expected-note {{to match this '('}} #pragma omp task firstprivate() \
// expected-error {{expected expression}} @@ -93,6 +94,7 @@
#pragma omp task shared(i)
#pragma omp task firstprivate(i)
#pragma omp task firstprivate(j) // expected-error {{arguments of OpenMP clause \
'firstprivate' cannot be of reference type}} +#pragma omp task firstprivate(m) // OK
foo();
return 0;
Index: test/OpenMP/single_private_messages.cpp
===================================================================
--- test/OpenMP/single_private_messages.cpp
+++ test/OpenMP/single_private_messages.cpp
@@ -142,6 +142,9 @@
foo();
#pragma omp single private(i)
foo();
+ static int m;
+#pragma omp single private(m) // OK
+ foo();
return 0;
}
Index: test/OpenMP/single_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/single_firstprivate_messages.cpp
+++ test/OpenMP/single_firstprivate_messages.cpp
@@ -242,6 +242,9 @@
#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
#pragma omp single firstprivate(i) // expected-error {{firstprivate variable must \
be shared}} foo();
+ static int t;
+#pragma omp single firstprivate(t) // OK
+ foo();
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/simd_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/simd_lastprivate_messages.cpp
+++ test/OpenMP/simd_lastprivate_messages.cpp
@@ -213,5 +213,9 @@
#pragma omp simd lastprivate(j) // expected-error {{arguments of OpenMP clause \
'lastprivate' cannot be of reference type}} for (i = 0; i < argc; ++i)
foo();
+ static int t;
+#pragma omp simd lastprivate(t) // OK
+ for (i = 0; i < argc; ++i)
+ foo();
return 0;
}
Index: test/OpenMP/sections_reduction_messages.cpp
===================================================================
--- test/OpenMP/sections_reduction_messages.cpp
+++ test/OpenMP/sections_reduction_messages.cpp
@@ -416,6 +416,11 @@
{
foo();
}
+ static int m;
+#pragma omp sections reduction(+ : m) // OK
+ {
+ foo();
+ }
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/sections_private_messages.cpp
===================================================================
--- test/OpenMP/sections_private_messages.cpp
+++ test/OpenMP/sections_private_messages.cpp
@@ -206,6 +206,11 @@
{
foo();
}
+ static int m;
+#pragma omp sections private(m)
+ {
+ foo();
+ }
return 0;
}
Index: test/OpenMP/sections_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/sections_lastprivate_messages.cpp
+++ test/OpenMP/sections_lastprivate_messages.cpp
@@ -314,5 +314,10 @@
{
foo();
}
+ static int r;
+#pragma omp sections lastprivate(r) // OK
+ {
+ foo();
+ }
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/sections_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/sections_firstprivate_messages.cpp
+++ test/OpenMP/sections_firstprivate_messages.cpp
@@ -338,6 +338,11 @@
{
foo();
}
+ static int r;
+#pragma omp sections firstprivate(r) // OK
+ {
+ foo();
+ }
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_sections_reduction_messages.cpp
===================================================================
--- test/OpenMP/parallel_sections_reduction_messages.cpp
+++ test/OpenMP/parallel_sections_reduction_messages.cpp
@@ -361,6 +361,11 @@
{
foo();
}
+ static int m;
+#pragma omp parallel sections reduction(+ : m) // OK
+ {
+ foo();
+ }
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/parallel_sections_private_messages.cpp
===================================================================
--- test/OpenMP/parallel_sections_private_messages.cpp
+++ test/OpenMP/parallel_sections_private_messages.cpp
@@ -206,6 +206,11 @@
{
foo();
}
+ static int m;
+#pragma omp parallel sections private(m)
+ {
+ foo();
+ }
return 0;
}
Index: test/OpenMP/parallel_sections_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_sections_lastprivate_messages.cpp
+++ test/OpenMP/parallel_sections_lastprivate_messages.cpp
@@ -274,5 +274,10 @@
{
foo();
}
+ static int r;
+#pragma omp parallel sections lastprivate(r) // OK
+ {
+ foo();
+ }
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_sections_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_sections_firstprivate_messages.cpp
+++ test/OpenMP/parallel_sections_firstprivate_messages.cpp
@@ -298,6 +298,11 @@
{
foo();
}
+ static int r;
+#pragma omp parallel sections firstprivate(r) // OK
+ {
+ foo();
+ }
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_reduction_messages.cpp
===================================================================
--- test/OpenMP/parallel_reduction_messages.cpp
+++ test/OpenMP/parallel_reduction_messages.cpp
@@ -243,6 +243,9 @@
for (int i = 0; i < 10; ++i)
#pragma omp parallel reduction(+ : fl)
foo();
+ static int m;
+#pragma omp parallel reduction(+ : m) // OK
+ m++;
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/parallel_private_messages.cpp
===================================================================
--- test/OpenMP/parallel_private_messages.cpp
+++ test/OpenMP/parallel_private_messages.cpp
@@ -84,6 +84,9 @@
#pragma omp parallel private(i)
foo();
}
+ static int m;
+ #pragma omp parallel private(m) // OK
+ foo();
return 0;
}
Index: test/OpenMP/parallel_for_simd_reduction_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_simd_reduction_messages.cpp
+++ test/OpenMP/parallel_for_simd_reduction_messages.cpp
@@ -298,6 +298,10 @@
#pragma omp parallel for simd reduction(+ : fl)
for (int i = 0; i < 10; ++i)
foo();
+ static int m;
+#pragma omp parallel for simd reduction(+ : m) // OK
+ for (int i = 0; i < 10; ++i)
+ m++;
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/parallel_for_simd_private_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_simd_private_messages.cpp
+++ test/OpenMP/parallel_for_simd_private_messages.cpp
@@ -175,6 +175,10 @@
#pragma omp parallel for simd private(i)
for (int k = 0; k < argc; ++k)
++k;
+ static int m;
+#pragma omp parallel for simd private(m) // OK
+ for (int k = 0; k < argc; ++k)
+ m = k + 3;
return 0;
}
Index: test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
+++ test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
@@ -231,5 +231,9 @@
#pragma omp parallel for simd lastprivate(n) firstprivate(n) // OK
for (i = 0; i < argc; ++i)
foo();
+ static int si;
+#pragma omp parallel for simd lastprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 3;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
+++ test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
@@ -253,6 +253,10 @@
#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as \
firstprivate}} for (i = 0; i < argc; ++i) // expected-error {{loop iteration \
variable in the associated loop of 'omp parallel for simd' directive may not be \
firstprivate, predetermined as linear}} foo();
+ static int si;
+#pragma omp parallel for simd firstprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 2;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_for_reduction_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_reduction_messages.cpp
+++ test/OpenMP/parallel_for_reduction_messages.cpp
@@ -298,6 +298,10 @@
#pragma omp parallel for reduction(+ : fl)
for (int i = 0; i < 10; ++i)
foo();
+ static int m;
+#pragma omp parallel for reduction(+ : m) // OK
+ for (int i = 0; i < 10; ++i)
+ m++;
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/parallel_for_private_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_private_messages.cpp
+++ test/OpenMP/parallel_for_private_messages.cpp
@@ -175,6 +175,10 @@
#pragma omp parallel for private(i)
for (int k = 0; k < argc; ++k)
++k;
+ static int m;
+#pragma omp parallel for private(m)
+ for (int k = 0; k < argc; ++k)
+ m = k + 2;
return 0;
}
Index: test/OpenMP/parallel_for_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_lastprivate_messages.cpp
+++ test/OpenMP/parallel_for_lastprivate_messages.cpp
@@ -232,5 +232,10 @@
#pragma omp parallel for lastprivate(n) firstprivate(n) // OK
for (i = 0; i < argc; ++i)
foo();
+ static int si;
+#pragma omp parallel for lastprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 2;
+
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_for_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_for_firstprivate_messages.cpp
+++ test/OpenMP/parallel_for_firstprivate_messages.cpp
@@ -255,6 +255,10 @@
#pragma omp parallel for firstprivate(i) // expected-note {{defined as \
firstprivate}} for (i = 0; i < argc; ++i) // expected-error {{loop iteration \
variable in the associated loop of 'omp parallel for' directive may not be \
firstprivate, predetermined as private}} foo();
+ static int si;
+#pragma omp parallel for firstprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 1;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/parallel_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -62,6 +62,7 @@
S5 g(5);
int i;
int &j = i; // expected-note {{'j' defined here}}
+ static int m;
#pragma omp parallel firstprivate // expected-error {{expected '(' after \
'firstprivate'}} #pragma omp parallel firstprivate ( // expected-error {{expected \
expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} \
#pragma omp parallel firstprivate () // expected-error {{expected expression}} @@ \
-84,6 +85,7 @@ #pragma omp parallel shared(i)
#pragma omp parallel firstprivate(i)
#pragma omp parallel firstprivate(j) // expected-error {{arguments of OpenMP \
clause 'firstprivate' cannot be of reference type}} + #pragma omp parallel \
firstprivate(m) foo();
return 0;
Index: test/OpenMP/for_simd_reduction_messages.cpp
===================================================================
--- test/OpenMP/for_simd_reduction_messages.cpp
+++ test/OpenMP/for_simd_reduction_messages.cpp
@@ -353,6 +353,10 @@
#pragma omp for simd reduction(+ : fl) // expected-error {{reduction variable \
must be shared}} for (int i = 0; i < 10; ++i)
foo();
+ static int m;
+#pragma omp for simd reduction(+ : m)
+ for (int i = 0; i < 10; ++i)
+ m++;
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/for_simd_private_messages.cpp
===================================================================
--- test/OpenMP/for_simd_private_messages.cpp
+++ test/OpenMP/for_simd_private_messages.cpp
@@ -175,6 +175,10 @@
#pragma omp for simd private(i)
for (int k = 0; k < argc; ++k)
++k;
+ static int m;
+#pragma omp for simd private(m)
+ for (int k = 0; k < argc; ++k)
+ m = k + 2;
return 0;
}
Index: test/OpenMP/for_simd_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/for_simd_lastprivate_messages.cpp
+++ test/OpenMP/for_simd_lastprivate_messages.cpp
@@ -272,5 +272,9 @@
#pragma omp for simd lastprivate(n) firstprivate(n) // OK
for (i = 0; i < argc; ++i)
foo();
+ static int si;
+#pragma omp for simd lastprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 1;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/for_simd_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/for_simd_firstprivate_messages.cpp
+++ test/OpenMP/for_simd_firstprivate_messages.cpp
@@ -300,6 +300,10 @@
#pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable \
must be shared}} for (i = 0; i < argc; ++i)
foo();
+ static int si;
+#pragma omp for simd firstprivate(si)
+ for (i = 0; i < argc; ++i)
+ si = i + 1;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/for_reduction_messages.cpp
===================================================================
--- test/OpenMP/for_reduction_messages.cpp
+++ test/OpenMP/for_reduction_messages.cpp
@@ -357,6 +357,10 @@
#pragma omp for reduction(+ : fl) // expected-error {{reduction variable must \
be shared}} for (int i = 0; i < 10; ++i)
foo();
+ static int m=0;
+#pragma omp for reduction(+:m)
+ for (int i = 0; i < 10; ++i)
+ m++;
return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function \
template specialization 'tmain<int>' requested here}} expected-note {{in \
instantiation of function template specialization 'tmain<float>' requested here}} }
Index: test/OpenMP/for_private_messages.cpp
===================================================================
--- test/OpenMP/for_private_messages.cpp
+++ test/OpenMP/for_private_messages.cpp
@@ -185,6 +185,10 @@
#pragma omp for private(i)
for (int k = 0; k < argc; ++k)
++k;
+ static int si;
+#pragma omp for private(si) // OK
+ for(int k = 0; k < argc; ++k)
+ si = k + 1;
return 0;
}
Index: test/OpenMP/for_lastprivate_messages.cpp
===================================================================
--- test/OpenMP/for_lastprivate_messages.cpp
+++ test/OpenMP/for_lastprivate_messages.cpp
@@ -283,5 +283,9 @@
#pragma omp for lastprivate(n) firstprivate(n) // OK
for (i = 0; i < argc; ++i)
foo();
+ static int si;
+#pragma omp for lastprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 1;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: test/OpenMP/for_firstprivate_messages.cpp
===================================================================
--- test/OpenMP/for_firstprivate_messages.cpp
+++ test/OpenMP/for_firstprivate_messages.cpp
@@ -307,6 +307,10 @@
#pragma omp for firstprivate(B::x) // expected-error {{threadprivate or thread local \
variable cannot be firstprivate}} for (i = 0; i < argc; ++i)
foo();
+ static int si;
+#pragma omp for firstprivate(si) // OK
+ for (i = 0; i < argc; ++i)
+ si = i + 1;
return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of \
function template specialization 'foomain<S4, S5>' requested here}} }
Index: lib/Sema/SemaOpenMP.cpp
===================================================================
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -521,7 +521,7 @@
// in a Construct, C/C++, predetermined, p.7]
// Variables with static storage duration that are declared in a scope
// inside the construct are shared.
- if (D->isStaticDataMember() || D->isStaticLocal()) {
+ if (D->isStaticDataMember()) {
DSAVarData DVarTemp =
hasDSA(D, isOpenMPPrivate, MatchesAlways(), FromParent);
if (DVarTemp.CKind != OMPC_unknown && DVarTemp.RefExpr)
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic