This patch tests various OpenMP lastprivate clause with SVE object types in various construct contexts.
gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/omp/lastprivate.c: New test. libgomp/ChangeLog: * testsuite/libgomp.target/aarch64/lastprivate.c: New test. --- .../gcc.target/aarch64/sve/omp/lastprivate.c | 94 ++++++++++ .../libgomp.target/aarch64/lastprivate.c | 162 ++++++++++++++++++ 2 files changed, 256 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/omp/lastprivate.c create mode 100644 libgomp/testsuite/libgomp.target/aarch64/lastprivate.c diff --git a/gcc/testsuite/gcc.target/aarch64/sve/omp/lastprivate.c b/gcc/testsuite/gcc.target/aarch64/sve/omp/lastprivate.c new file mode 100644 index 00000000000..8f89c68647b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/omp/lastprivate.c @@ -0,0 +1,94 @@ +/* { dg-do compile } */ +/* { dg-options "-msve-vector-bits=256 -std=gnu99 -fopenmp -O2" } */ + +#include <arm_sve.h> + +#define N 8 + +#ifndef CONSTRUCT +#define CONSTRUCT +#endif + +svint32_t __attribute__ ((noinline)) +omp_lastprivate_sections () +{ + + int a[N], b[N], c[N]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < N; i++) + { + b[i] = i; + c[i] = i + 1; + } + +/* This worksharing construct binds to an implicit outer parallel region in + whose scope va is declared and therefore is default private. This causes + the lastprivate clause list item va to be diagnosed as private in the outer + context. Similarly for constructs for and distribute. */ +#pragma omp sections lastprivate (va) /* { dg-error {lastprivate variable 'va' is private in outer context} } */ + { + #pragma omp section + vb = svld1_s32 (svptrue_b32 (), b); + #pragma omp section + vc = svld1_s32 (svptrue_b32 (), c); + #pragma omp section + va = svadd_s32_z (svptrue_b32 (), vb, vc); + } + + return va; +} + +svint32_t __attribute__ ((noinline)) +omp_lastprivate_for () +{ + + int a[N], b[N], c[N]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < N; i++) + { + b[i] = i; + c[i] = i + 1; + } + +#pragma omp for lastprivate (va) /* { dg-error {lastprivate variable 'va' is private in outer context} } */ + for (i = 0; i < 1; i++) + { + vb = svld1_s32 (svptrue_b32 (), b); + vc = svld1_s32 (svptrue_b32 (), c); + va = svadd_s32_z (svptrue_b32 (), vb, vc); + } + + return va; +} + +svint32_t __attribute__ ((noinline)) +omp_lastprivate_distribute () +{ + + int a[N], b[N], c[N]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < N; i++) + { + b[i] = i; + c[i] = i + 1; + } + +#pragma omp distribute lastprivate (va) /* { dg-error {lastprivate variable 'va' is private in outer context} } */ + for (i = 0; i < 1; i++) + { + vb = svld1_s32 (svptrue_b32 (), b); + vc = svld1_s32 (svptrue_b32 (), c); + va = svadd_s32_z (svptrue_b32 (), vb, vc); + } + + return va; +} diff --git a/libgomp/testsuite/libgomp.target/aarch64/lastprivate.c b/libgomp/testsuite/libgomp.target/aarch64/lastprivate.c new file mode 100644 index 00000000000..da3c4d64d70 --- /dev/null +++ b/libgomp/testsuite/libgomp.target/aarch64/lastprivate.c @@ -0,0 +1,162 @@ +/* { dg-do run { target aarch64_sve256_hw } } */ +/* { dg-options "-msve-vector-bits=256 -std=gnu99 -fopenmp -O2" } */ + +#include <arm_sve.h> + +#ifndef CONSTRUCT +#define CONSTRUCT +#endif + +void __attribute__ ((noinline)) +omp_lastprivate_sections () +{ + + int a[8], b[8], c[8]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < 8; i++) + { + b[i] = i; + c[i] = i + 1; + } + +#pragma omp parallel +#pragma omp sections lastprivate (vb, vc) + { + #pragma omp section + vb = svld1_s32 (svptrue_b32 (), b); + #pragma omp section + vc = svld1_s32 (svptrue_b32 (), c); + } + + va = svadd_s32_z (svptrue_b32 (), vb, vc); + svst1_s32 (svptrue_b32 (), a, va); + + for (i = 0; i < 8; i++) + if (a[i] != b[i] + c[i]) + __builtin_abort (); +} + +void __attribute__ ((noinline)) +omp_lastprivate_for () +{ + + int a[32], b[32], c[32]; + int aa[8], bb[8], cc[8]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < 32; i++) + { + b[i] = i; + c[i] = i + 1; + } + +#pragma omp parallel +#pragma omp for lastprivate (va, vb, vc) + for (i = 0; i < 4; i++) + { + vb = svld1_s32 (svptrue_b32 (), b + i * 8); + vc = svld1_s32 (svptrue_b32 (), c + i * 8); + va = svadd_s32_z (svptrue_b32 (), vb, vc); + svst1_s32 (svptrue_b32 (), a + i * 8, va); + } + + svst1_s32 (svptrue_b32 (), aa, va); + svst1_s32 (svptrue_b32 (), bb, vb); + svst1_s32 (svptrue_b32 (), cc, vc); + for (i = 0; i < 8; i++) + if (aa[i] != bb[i] + cc[i]) + __builtin_abort (); + + for (i = 0; i < 32; i++) + if (a[i] != b[i] + c[i]) + __builtin_abort (); +} + +void __attribute__ ((noinline)) +omp_lastprivate_simd () +{ + + int a[64], b[64], c[64]; + int aa[8], bb[8], cc[8]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < 64; i++) + { + b[i] = i; + c[i] = i + 1; + } + +#pragma omp simd lastprivate (va, vb, vc) + for (i = 0; i < 8; i++) + { + vb = svld1_s32 (svptrue_b32 (), b + i * 8); + vc = svld1_s32 (svptrue_b32 (), c + i * 8); + va = svadd_s32_z (svptrue_b32 (), vb, vc); + svst1_s32 (svptrue_b32 (), a + i * 8, va); + } + + svst1_s32 (svptrue_b32 (), aa, va); + svst1_s32 (svptrue_b32 (), bb, vb); + svst1_s32 (svptrue_b32 (), cc, vc); + for (i = 0; i < 8; i++) + if (aa[i] != bb[i] + cc[i]) + __builtin_abort (); + + for (i = 0; i < 64; i++) + if (a[i] != b[i] + c[i]) + __builtin_abort (); +} + +void __attribute__ ((noinline)) +omp_lastprivate_distribute () +{ + + int a[32], b[32], c[32]; + int aa[8], bb[8], cc[8]; + svint32_t va, vb, vc; + int i; + +#pragma omp parallel for + for (i = 0; i < 32; i++) + { + b[i] = i; + c[i] = i + 1; + } + +#pragma omp teams +#pragma omp distribute lastprivate (va, vb, vc) + for (i = 0; i < 4; i++) + { + vb = svld1_s32 (svptrue_b32 (), b + i * 8); + vc = svld1_s32 (svptrue_b32 (), c + i * 8); + va = svadd_s32_z (svptrue_b32 (), vb, vc); + svst1_s32 (svptrue_b32 (), a + i * 8, va); + } + + svst1_s32 (svptrue_b32 (), aa, va); + svst1_s32 (svptrue_b32 (), bb, vb); + svst1_s32 (svptrue_b32 (), cc, vc); + for (i = 0; i < 8; i++) + if (aa[i] != bb[i] + cc[i]) + __builtin_abort (); + + for (i = 0; i < 32; i++) + if (a[i] != b[i] + c[i]) + __builtin_abort (); +} + +int +main() +{ + omp_lastprivate_for (); + omp_lastprivate_sections (); + omp_lastprivate_simd (); + omp_lastprivate_distribute (); +} -- 2.25.1