diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-05-24 23:31:59 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-05-24 23:31:59 +0200 |
commit | 6c7ae8c56f9341f180e097d5eb7ba05cb8eec413 (patch) | |
tree | 425965042d935027e8cc7045b383f6b7b6f714f9 /libgomp | |
parent | 09b4000c7c5b359ec62b5d621daf6ab95233ce10 (diff) | |
download | gcc-6c7ae8c56f9341f180e097d5eb7ba05cb8eec413.tar.gz |
tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.
* tree.h (OMP_CLAUSE_DECL): Use OMP_CLAUSE__CONDTEMP_ instead of
OMP_CLAUSE__REDUCTEMP_.
* tree.c (omp_clause_num_ops, omp_clause_code_name): Add
OMP_CLAUSE__CONDTEMP_.
(walk_tree_1): Handle OMP_CLAUSE__CONDTEMP_.
* tree-pretty-print.c (dump_omp_clause): Likewise.
* tree-nested.c (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Likewise.
* gimplify.c (enum gimplify_omp_var_data): Use hexadecimal constants
instead of decimal. Add GOVD_LASTPRIVATE_CONDITIONAL.
(gimplify_scan_omp_clauses): Don't reject lastprivate conditional
on OMP_FOR.
(gimplify_omp_for): Warn and disable conditional modifier from
lastprivate on loop iterators.
* omp-general.h (struct omp_for_data): Add lastprivate_conditional
member.
* omp-general.c (omp_extract_for_data): Initialize it.
* omp-low.c (struct omp_context): Add lastprivate_conditional_map
member.
(delete_omp_context): Delete it.
(lower_lastprivate_conditional_clauses): New function.
(lower_lastprivate_clauses): Add BODY_P and CSTMT_LIST arguments,
handle lastprivate conditional clauses.
(lower_reduction_clauses): Add CLIST argument, emit it into
the critical section if any.
(lower_omp_sections): Adjust lower_lastprivate_clauses and
lower_reduction_clauses callers.
(lower_omp_for_lastprivate): Add CLIST argument, pass it through
to lower_lastprivate_clauses.
(lower_omp_for): Call lower_lastprivate_conditional_clauses, adjust
lower_omp_for_lastprivate and lower_reduction_clauses callers, emit
clist into a critical section if not emitted there already by
lower_reduction_clauses.
(lower_omp_taskreg, lower_omp_teams): Adjust lower_reduction_clauses
callers.
(lower_omp_1): Handle GIMPLE_ASSIGNs storing into lastprivate
conditional variables.
* omp-expand.c (determine_parallel_type): Punt if OMP_CLAUSE__CONDTEMP_
clause is present.
(expand_omp_for_generic, expand_omp_for_static_nochunk,
expand_omp_for_static_chunk): Handle lastprivate conditional.
(expand_omp_for): Handle fd.lastprivate_conditional like
fd.have_reductemp.
gcc/testsuite/
* c-c++-common/gomp/lastprivate-conditional-2.c (foo): Don't expect
sorry for omp for.
* c-c++-common/gomp/lastprivate-conditional-3.c: New test.
libgomp/
* testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c: New test.
* testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c: New test.
From-SVN: r271610
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 3 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c | 144 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c | 171 |
3 files changed, 318 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 5b427abc192..f88e06abf68 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,8 @@ 2019-05-24 Jakub Jelinek <jakub@redhat.com> + * testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c: New test. + * testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c: New test. + PR libgomp/90585 * plugin/plugin-hsa.c: Include gstdint.h. Include inttypes.h only if HAVE_INTTYPES_H is defined. diff --git a/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c new file mode 100644 index 00000000000..a7e9f90c5a8 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c @@ -0,0 +1,144 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-additional-options "-std=gnu99" {target c } } */ + +#include <omp.h> +#include <stdlib.h> + +int r, s, u, v, r2, s2, u2, v2, r3, s3, u3, v3; +long long w, w2, w3, p, p2, p3; +int *x, *x2, *x3; +short y, y2, y3; +int z; +int thr1, thr2; +#pragma omp threadprivate (thr1, thr2) + +void +foo (int *a, long long int b, long long int c) +{ + int i; + long long j; + #pragma omp for lastprivate (conditional: u, x) nowait + for (i = 15; i < 64; i++) + { + if ((a[i] % 5) == 3) + u = i; + if ((a[i] % 7) == 2) + x = &a[i]; + } + #pragma omp for nowait lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) + for (i = -3; i < 119; i += 2) + { + ++s; + if ((a[i + 4] % 11) == 9) + v = i; + else + ++r; + } + #pragma omp for schedule (monotonic: static) lastprivate (conditional: w) nowait + for (j = b; j < b + 115 * c; j += (b & 3) + 7) + if ((a[j] % 13) == 5) + w = j * 2; + #pragma omp for schedule (auto) lastprivate (conditional: p) collapse(3) + for (i = -5; i < (int) (b + 5); i += 2) + for (j = b + 12 + c; j > b; --j) + for (int k = 0; k < 5; k += c) + if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6) + p = i * 10000 + j * 100 + k; + + #pragma omp for schedule (nonmonotonic: static, 2) nowait lastprivate (conditional: u2, x2) + for (i = 15; i < 64; i++) + { + if ((a[i] % 5) == 3) + u2 = i; + if ((a[i] % 7) == 2) + x2 = &a[i]; + } + #pragma omp for schedule (static, 3) lastprivate (conditional: v2) reduction (+:r2, s2) + for (i = -3; i < 119; i += 2) + { + ++s2; + if ((a[i + 4] % 11) == 9) + v2 = i; + else + ++r2; + } + #pragma omp for lastprivate (conditional: w2) schedule (static, 1) nowait + for (j = b; j < b + 115 * c; j += (b & 3) + 7) + if ((a[j] % 13) == 5) + w2 = j * 2; + #pragma omp for schedule (static, 3) collapse (3) lastprivate (conditional: p2) + for (i = -5; i < (int) (b + 5); i += 2) + for (j = b + 12 + c; j > b; --j) + for (int k = 0; k < 5; k += c) + if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6) + p2 = i * 10000 + j * 100 + k; + + #pragma omp for lastprivate (conditional: u3, x3) nowait schedule (runtime) + for (i = 15; i < 64; i++) + { + if ((a[i] % 5) == 3) + u3 = i; + if ((a[i] % 7) == 2) + x3 = &a[i]; + } + #pragma omp for nowait lastprivate (conditional: v3) reduction (+:r3, s3) schedule (nonmonotonic: dynamic) + for (i = -3; i < 119; i += 2) + { + ++s3; + if ((a[i + 4] % 11) == 9) + v3 = i; + else + ++r3; + } + #pragma omp for schedule (monotonic: guided, 3) lastprivate (conditional: w3) nowait + for (j = b; j < b + 115 * c; j += (b & 3) + 7) + if ((a[j] % 13) == 5) + w3 = j * 2; + #pragma omp for schedule (dynamic, 4) lastprivate (conditional: p3) collapse(3) + for (i = -5; i < (int) (b + 5); i += 2) + for (j = b + 12 + c; j > b; --j) + for (int k = 0; k < 5; k += c) + if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6) + p3 = i * 10000 + j * 100 + k; + + /* Nasty testcase, verify that even a no-op assignment is accounted + for in lastprivate(conditional:). */ + #pragma omp for schedule (monotonic: static, 2) firstprivate (z) \ + lastprivate (conditional: z) + for (int k = -2000; k < 8000; ++k) + { + if (k < 3000 && (k & 3) == 1) + { + z = k; + thr1 = k; + } + else if (k == 7931) + { + z = z; + thr2 = 1; + } + } + + if (thr2 && z != thr1) + abort (); +} + +int +main () +{ + int a[128], i; + volatile int j = 0; + for (i = 0; i < 128; i++) + a[i] = i; + w = 1234; + #pragma omp parallel + foo (a, j, j + 1); + if (u != 63 || v != 115 || w != 140 || x != &a[58] || r != 55 || s != 61 || p != 30104) + abort (); + if (u2 != 63 || v2 != 115 || w2 != 140 || x2 != &a[58] || r2 != 55 || s2 != 61 || p2 != 30104) + abort (); + if (u3 != 63 || v3 != 115 || w3 != 140 || x3 != &a[58] || r3 != 55 || s3 != 61 || p3 != 30104) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c new file mode 100644 index 00000000000..f252206f5b3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c @@ -0,0 +1,171 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-additional-options "-std=gnu99" {target c } } */ + +#include <omp.h> +#include <stdlib.h> + +int r, s, u, v, r2, s2, u2, v2, r3, s3, u3, v3, t; +long long w, w2, w3, p, p2, p3; +int *x, *x2, *x3; +short y, y2, y3; +int z; +int thr1, thr2; +#pragma omp threadprivate (thr1, thr2) + +void +foo (int *a, long long int b, long long int c) +{ + int i; + long long j; + #pragma omp for lastprivate (conditional: u, x) reduction (task, +: t) + for (i = 15; i < 64; i++) + { + ++t; + if ((a[i] % 5) == 3) + u = i; + if ((a[i] % 7) == 2) + x = &a[i]; + } + #pragma omp for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) reduction (task, +: t) + for (i = -3; i < 119; i += 2) + { + ++s; + ++t; + if ((a[i + 4] % 11) == 9) + v = i; + else + ++r; + } + #pragma omp for schedule (monotonic: static) lastprivate (conditional: w) reduction (task, +: t) + for (j = b; j < b + 115 * c; j += (b & 3) + 7) + { + if ((a[j] % 13) == 5) + w = j * 2; + ++t; + } + #pragma omp for schedule (auto) lastprivate (conditional: p) collapse(3) reduction (task, +: t) + for (i = -5; i < (int) (b + 5); i += 2) + for (j = b + 12 + c; j > b; --j) + for (int k = 0; k < 5; k += c) + { + ++t; + if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6) + p = i * 10000 + j * 100 + k; + } + + #pragma omp for schedule (nonmonotonic: static, 2) reduction (task, +: t) lastprivate (conditional: u2, x2) + for (i = 15; i < 64; i++) + { + if ((a[i] % 5) == 3) + u2 = i; + if ((a[i] % 7) == 2) + x2 = &a[i]; + t++; + } + #pragma omp for schedule (static, 3) lastprivate (conditional: v2) reduction (+:r2, s2) reduction (task, +: t) + for (i = -3; i < 119; i += 2) + { + ++s2; + if ((a[i + 4] % 11) == 9) + v2 = i; + else + ++r2; + t++; + } + #pragma omp for lastprivate (conditional: w2) schedule (static, 1) reduction (task, +: t) + for (j = b; j < b + 115 * c; j += (b & 3) + 7) + { + if ((a[j] % 13) == 5) + w2 = j * 2; + t += 1; + } + #pragma omp for schedule (static, 3) collapse (3) reduction (task, +: t) lastprivate (conditional: p2) + for (i = -5; i < (int) (b + 5); i += 2) + for (j = b + 12 + c; j > b; --j) + for (int k = 0; k < 5; k += c) + { + ++t; + if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6) + p2 = i * 10000 + j * 100 + k; + } + + #pragma omp for lastprivate (conditional: u3, x3) reduction (task, +: t) schedule (runtime) + for (i = 15; i < 64; i++) + { + t = t + 1; + if ((a[i] % 5) == 3) + u3 = i; + if ((a[i] % 7) == 2) + x3 = &a[i]; + } + #pragma omp for reduction (task, +: t) lastprivate (conditional: v3) reduction (+:r3, s3) schedule (nonmonotonic: dynamic) + for (i = -3; i < 119; i += 2) + { + ++s3; + if ((a[i + 4] % 11) == 9) + v3 = i; + else + ++r3; + ++t; + } + #pragma omp for schedule (monotonic: guided, 3) lastprivate (conditional: w3) reduction (task, +: t) + for (j = b; j < b + 115 * c; j += (b & 3) + 7) + { + if ((a[j] % 13) == 5) + w3 = j * 2; + t++; + } + #pragma omp for schedule (dynamic, 4) lastprivate (conditional: p3) collapse(3) reduction (task, +: t) + for (i = -5; i < (int) (b + 5); i += 2) + for (j = b + 12 + c; j > b; --j) + for (int k = 0; k < 5; k += c) + { + ++t; + if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6) + p3 = i * 10000 + j * 100 + k; + } + + /* Nasty testcase, verify that even a no-op assignment is accounted + for in lastprivate(conditional:). */ + #pragma omp for schedule (monotonic: static, 2) firstprivate (z) \ + lastprivate (conditional: z) reduction (task, +: t) + for (int k = -2000; k < 8000; ++k) + { + t++; + if (k < 3000 && (k & 3) == 1) + { + z = k; + thr1 = k; + } + else if (k == 7931) + { + z = z; + thr2 = 1; + } + } + + if (thr2 && z != thr1) + abort (); +} + +int +main () +{ + int a[128], i; + volatile int j = 0; + for (i = 0; i < 128; i++) + a[i] = i; + w = 1234; + #pragma omp parallel + foo (a, j, j + 1); + if (u != 63 || v != 115 || w != 140 || x != &a[58] || r != 55 || s != 61 || p != 30104) + abort (); + if (u2 != 63 || v2 != 115 || w2 != 140 || x2 != &a[58] || r2 != 55 || s2 != 61 || p2 != 30104) + abort (); + if (u3 != 63 || v3 != 115 || w3 != 140 || x3 != &a[58] || r3 != 55 || s3 != 61 || p3 != 30104) + abort (); + if (t != 11356) + abort (); + return 0; +} |