diff mbox series

[v2,07/12] libgomp, AArch64: Test OpenMP user-defined reductions with SVE types.

Message ID 20241018062233.243950-8-tejas.belagod@arm.com
State New
Headers show
Series AArch64/OpenMP: Test SVE ACLE types with various OpenMP constructs. | expand

Commit Message

Tejas Belagod Oct. 18, 2024, 6:22 a.m. UTC
This patch tests user-defined reductions on various constructs with objects
of SVE type.

libgomp/ChangeLog:

	* testsuite/libgomp.target/aarch64/udr-sve.c: New.
---
 .../libgomp.target/aarch64/udr-sve.c          | 108 ++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 libgomp/testsuite/libgomp.target/aarch64/udr-sve.c
diff mbox series

Patch

diff --git a/libgomp/testsuite/libgomp.target/aarch64/udr-sve.c b/libgomp/testsuite/libgomp.target/aarch64/udr-sve.c
new file mode 100644
index 00000000000..749f3c2123b
--- /dev/null
+++ b/libgomp/testsuite/libgomp.target/aarch64/udr-sve.c
@@ -0,0 +1,108 @@ 
+/* { dg-do run } */
+/* { dg-options "-msve-vector-bits=256 -std=gnu99 -fopenmp -O2" } */
+
+#include <arm_sve.h>
+
+#pragma omp declare reduction (+:svint32_t: omp_out = svadd_s32_z (svptrue_b32(), omp_in, omp_out)) \
+		    initializer (omp_priv = svindex_s32 (0, 0))
+
+int __attribute__((noipa))
+parallel_reduction ()
+{
+  int a[8] = {1 ,1, 1, 1, 1, 1, 1, 1};
+  int b[8] = {0 ,0, 0, 0, 0, 0, 0, 0};
+  svint32_t va = svld1_s32 (svptrue_b32 (), b);
+  int i = 0;
+  int64_t res;
+
+  #pragma omp parallel reduction (+:va, i)
+    {
+      va = svld1_s32 (svptrue_b32 (), a);
+      i++;
+    }
+
+  res = svaddv_s32 (svptrue_b32 (), va);
+
+  if (res != i * 8)
+    __builtin_abort ();
+
+  return 0;
+}
+
+int  __attribute__((noipa))
+for_reduction ()
+{
+  int a[8] = {1 ,1, 1, 1, 1, 1, 1, 1};
+  int b[8] = {0 ,0, 0, 0, 0, 0, 0, 0};
+  svint32_t va = svld1_s32 (svptrue_b32 (), b);
+  int j;
+  int64_t res;
+
+  #pragma omp parallel for reduction (+:va)
+  for (j = 0; j < 8; j++)
+    va = svld1_s32 (svptrue_b32 (), a);
+
+  res = svaddv_s32 (svptrue_b32 (), va);
+
+  if (res != 64)
+    __builtin_abort ();
+
+  return 0;
+}
+
+int __attribute__((noipa))
+simd_reduction ()
+{
+  int a[8];
+  svint32_t va = svindex_s32 (0, 0);
+  int i = 0;
+  int j;
+  int64_t res = 0;
+
+  for (j = 0; j < 8; j++)
+    a[j] = 1;
+
+  #pragma omp simd reduction (+:va, i)
+  for (j = 0; j < 16; j++)
+    va = svld1_s32 (svptrue_b32 (), a);
+
+  res = svaddv_s32 (svptrue_b32 (), va);
+
+  if (res != 8)
+    __builtin_abort ();
+
+  return 0;
+}
+
+int __attribute__((noipa))
+inscan_reduction_incl ()
+{
+  svint32_t va = svindex_s32 (0, 0);
+  int j;
+  int64_t res = 0;
+
+  #pragma omp parallel
+  #pragma omp for reduction (inscan,+:va) firstprivate (res) lastprivate (res)
+  for (j = 0; j < 8; j++)
+    {
+      va = svindex_s32 (1, 0);
+      #pragma omp scan inclusive (va)
+      res += svaddv_s32 (svptrue_b32 (), va);
+    }
+
+  if (res != 64)
+    __builtin_abort ();
+
+  return 0;
+}
+
+int
+main ()
+{
+  parallel_reduction ();
+  for_reduction ();
+  simd_reduction ();
+  inscan_reduction_incl ();
+
+  return 0;
+}