Message ID | 20240527050626.3769230-8-tejas.belagod@arm.com |
---|---|
State | New |
Headers | show |
Series | AArch64/OpenMP: Test SVE ACLE types with various OpenMP constructs. | expand |
On Mon, May 27, 2024 at 10:36:22AM +0530, Tejas Belagod wrote: > This patch tests if simd uniform clause works with SVE types in simd regions. > > gcc/testsuite/ChangeLog > > * gcc.target/aarch64/sve/omp/simd-uniform.c: New test. > --- > .../gcc.target/aarch64/sve/omp/simd-uniform.c | 71 +++++++++++++++++++ > 1 file changed, 71 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c > > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c b/gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c > new file mode 100644 > index 00000000000..6256ce9fdc1 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c > @@ -0,0 +1,71 @@ > +/* { dg-do run { target aarch64_sve256_hw } } */ > +/* { dg-options "-msve-vector-bits=256 -std=gnu99 -fopenmp -O2 -fdump-tree-ompexp" } */ > + > +#include <arm_sve.h> > + > +#define N 256 > + > +void init(int *a, int *a_ref, int *b, int n) > +{ > + int i; > + for ( i=0; i<N; i++ ) > + { > + a[i] = i; > + a_ref[i] = i; > + b[i] = N-i; > + } > +} > + > +#pragma omp declare simd uniform(a, b, sz) linear (i) > +void vec_add(int *a, int *b, int i, int64_t sz) I don't see how this tests anything relevant to SVE types. That would be an argument which is svint32_t or something mentioned in uniform clause and using it in the function. Jakub
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c b/gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c new file mode 100644 index 00000000000..6256ce9fdc1 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/omp/simd-uniform.c @@ -0,0 +1,71 @@ +/* { dg-do run { target aarch64_sve256_hw } } */ +/* { dg-options "-msve-vector-bits=256 -std=gnu99 -fopenmp -O2 -fdump-tree-ompexp" } */ + +#include <arm_sve.h> + +#define N 256 + +void init(int *a, int *a_ref, int *b, int n) +{ + int i; + for ( i=0; i<N; i++ ) + { + a[i] = i; + a_ref[i] = i; + b[i] = N-i; + } +} + +#pragma omp declare simd uniform(a, b, sz) linear (i) +void vec_add(int *a, int *b, int i, int64_t sz) +{ + svint32_t va, vb, vc, tmp; + svint32_t ones = svdup_n_s32 (1); + + va = svld1_s32 (svptrue_b32 (), a + i * sz); + vb = svld1_s32 (svptrue_b32 (), b + i * sz); + tmp = svadd_s32_z (svptrue_b32 (), va, vb); + vc = svadd_s32_z (svptrue_b32 (), tmp, ones); + svst1_s32 (svptrue_b32 (), a + i * sz, vc); +} + +void work(int *a, int *b, int n) +{ + int i; + int64_t sz = svcntw (); + + #pragma omp simd + for (i = 0; i < n/sz; i++) + vec_add (a, b, i, sz); +} + +void work_ref(int *a, int *b, int n) +{ + int i; + for ( i = 0; i < n; i++ ) { + a[i] = a[i] + b[i] + 1; + } +} + +void check (int *a, int *b) +{ + int i; + for (i = 0; i < N; i++) + if (a[i] != b[i]) + __builtin_abort (); +} + +int main () +{ + int i; + int a[N], a_ref[N], b[N]; + + init(a, a_ref, b, N); + + work(a, b, N ); + work_ref(a_ref, b, N ); + + check(a, a_ref); + + return 0; +}