diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-11-13 18:57:06 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-11-13 18:57:06 +0100 |
commit | 67100cb50ea22e1fc855360b887959f874fafe2c (patch) | |
tree | 8ef9baeb007dcce1c7d132966f7d819e6ce2ab72 /libgomp | |
parent | 2e97d6443f0a862ce9b798084499635914e3b8c6 (diff) | |
download | gcc-67100cb50ea22e1fc855360b887959f874fafe2c.zip gcc-67100cb50ea22e1fc855360b887959f874fafe2c.tar.gz gcc-67100cb50ea22e1fc855360b887959f874fafe2c.tar.bz2 |
openmp: Support allocate for C/C++ array section reductions
This adds allocate clause support for array section reductions.
Furthermore, it fixes one bug that would cause inscan reductions with
allocate to be rejected by C, and for now just ignores allocate for
inscan/task reductions, that will need slightly more work.
2020-11-13 Jakub Jelinek <jakub@redhat.com>
gcc/
* omp-low.c (scan_sharing_clauses): For now remove for reduction
clauses with inscan or task modifiers decl from allocate_map.
(lower_private_allocate): Handle TYPE_P (new_var).
(lower_rec_input_clauses): Handle allocate clause for C/C++ array
reductions.
gcc/c/
* c-typeck.c (c_finish_omp_clauses): Don't clear
OMP_CLAUSE_REDUCTION_INSCAN unless reduction_seen == -2.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-1.c (foo): Add tests
for array reductions.
(main): Adjust foo callers.
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/allocate-1.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/allocate-1.c b/libgomp/testsuite/libgomp.c-c++-common/allocate-1.c index 532795f..5dd51b5 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/allocate-1.c +++ b/libgomp/testsuite/libgomp.c-c++-common/allocate-1.c @@ -3,7 +3,7 @@ #include <stdint.h> void -foo (int x, omp_allocator_handle_t h, int fl) +foo (int x, int *p, int *q, int px, omp_allocator_handle_t h, int fl) { int y = 0, r = 0, i, i1, l, l2[4], l3, n = 8; int i2, j2, n2 = 9, l4; @@ -11,7 +11,12 @@ foo (int x, omp_allocator_handle_t h, int fl) int i4, j4, n4 = 11, l6; int i5; int v[x], w[x]; + int r2[4] = { 0, 0, 0, 0 }; int xo = x; + for (i = 0; i < 4; i++) + p[i] = 0; + for (i = 0; i < 3; i++) + q[i] = 0; for (i = 0; i < x; i++) w[i] = i; #pragma omp parallel private (y, v) firstprivate (x) allocate (x, y, v) @@ -117,6 +122,21 @@ foo (int x, omp_allocator_handle_t h, int fl) if ((fl & 2) && (((uintptr_t) &i5) & 63) != 0) abort (); } + #pragma omp for reduction(+:p[2:px], q[:3], r2) allocate(h: p, q, r2) + for (i = 0; i < 32; i++) + { + p[2] += i; + p[3] += 2 * i; + q[0] += 3 * i; + q[2] += 4 * i; + r2[0] += 5 * i; + r2[3] += 6 * i; + /* Can't really rely on alignment of &p[0], the implementation could + allocate the whole array or do what GCC does and allocate only part + of it. */ + if ((fl & 1) && (((uintptr_t) &q[0] | (uintptr_t) &r2[0]) & 63) != 0) + abort (); + } } if (r != 64 * 63 / 2 || l != 63 || n != 8 + 16 * 64) abort (); @@ -130,6 +150,10 @@ foo (int x, omp_allocator_handle_t h, int fl) abort (); if (i5 != 19) abort (); + if (p[2] != (32 * 31) / 2 || p[3] != 2 * (32 * 31) / 2 + || q[0] != 3 * (32 * 31) / 2 || q[2] != 4 * (32 * 31) / 2 + || r2[0] != 5 * (32 * 31) / 2 || r2[3] != 6 * (32 * 31) / 2) + abort (); } void @@ -239,15 +263,16 @@ main () { omp_atk_fallback, omp_atv_null_fb } }; omp_allocator_handle_t a = omp_init_allocator (omp_default_mem_space, 2, traits); + int p[4], q[3]; if (a == omp_null_allocator) abort (); omp_set_default_allocator (omp_default_mem_alloc); - foo (42, omp_null_allocator, 0); - foo (42, omp_default_mem_alloc, 0); - foo (42, a, 1); + foo (42, p, q, 2, omp_null_allocator, 0); + foo (42, p, q, 2, omp_default_mem_alloc, 0); + foo (42, p, q, 2, a, 1); omp_set_default_allocator (a); - foo (42, omp_null_allocator, 3); - foo (42, omp_default_mem_alloc, 2); + foo (42, p, q, 2, omp_null_allocator, 3); + foo (42, p, q, 2, omp_default_mem_alloc, 2); bar (42, a); omp_destroy_allocator (a); return 0; |