diff mbox series

[04/11] AArch64: Test OpenMP lastprivate clause for various constructs.

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

Commit Message

Tejas Belagod May 27, 2024, 5:06 a.m. UTC
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.
---
 .../gcc.target/aarch64/sve/omp/lastprivate.c  | 121 ++++++++++++++++++
 1 file changed, 121 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/omp/lastprivate.c
diff mbox series

Patch

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..e4ecc58a9c4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/omp/lastprivate.c
@@ -0,0 +1,121 @@ 
+/* { dg-do compile } */
+/* { dg-options "-msve-vector-bits=256 -std=gnu99 -fopenmp -O2 -fdump-tree-ompexp" } */
+
+#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_simd ()
+{
+
+  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 simd lastprivate (va)
+  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;
+}