]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp: Update SVE test
authorTejas Belagod <tejas.belagod@arm.com>
Fri, 11 Apr 2025 04:32:28 +0000 (10:02 +0530)
committerTejas Belagod <tejas.belagod@arm.com>
Tue, 6 May 2025 06:11:18 +0000 (11:41 +0530)
Fix udr-sve.c target test that to check for the correct results based on the
OpenMP clauses used.  The test was first written with a misunderstood
functionality of the reduction clause.

Tested with aarch64-linux-gnu. OK for trunk?

libgomp/ChangeLog:

* testsuite/libgomp.c-target/aarch64/udr-sve.c: Fix test.

libgomp/testsuite/libgomp.c-target/aarch64/udr-sve.c

index 03d93cc44b2c079ddb83ce4d4784bb4808aa4469..02e02dc04b67e68bc14464a0433643209fba52bd 100644 (file)
@@ -9,8 +9,8 @@
 void __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};
+  int a[8] = {11, 1, 1, 1, 1, 1, 1};
+  int b[8] = {00, 0, 0, 0, 0, 0, 0};
   svint32_t va = svld1_s32 (svptrue_b32 (), b);
   int i = 0;
   int64_t res;
@@ -30,8 +30,8 @@ parallel_reduction ()
 void __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};
+  int a[8] = {11, 1, 1, 1, 1, 1, 1};
+  int b[8] = {00, 0, 0, 0, 0, 0, 0};
   svint32_t va = svld1_s32 (svptrue_b32 (), b);
   int j;
   int64_t res;
@@ -58,13 +58,13 @@ simd_reduction ()
   for (j = 0; j < 8; j++)
     a[j] = 1;
 
-  #pragma omp simd reduction (+:va, i)
+  #pragma omp simd reduction (+:va)
   for (j = 0; j < 16; j++)
-    va = svld1_s32 (svptrue_b32 (), a);
+    va += svld1_s32 (svptrue_b32 (), a);
 
   res = svaddv_s32 (svptrue_b32 (), va);
 
-  if (res != 8)
+  if (res != 128)
     __builtin_abort ();
 }
 
@@ -72,22 +72,57 @@ void __attribute__ ((noipa))
 inscan_reduction_incl ()
 {
   svint32_t va = svindex_s32 (0, 0);
+  int a[8] = {1, 1, 1, 1, 1, 1, 1, 1};
+  int b[64] = { 0 };
   int j;
   int64_t res = 0;
 
-  #pragma omp parallel
-  #pragma omp for reduction (inscan,+:va) firstprivate (res) lastprivate (res)
+  #pragma omp parallel for reduction (inscan, +:va)
   for (j = 0; j < 8; j++)
     {
-      va = svindex_s32 (1, 0);
+      va += svld1_s32 (svptrue_b32 (), a);
       #pragma omp scan inclusive (va)
-      res += svaddv_s32 (svptrue_b32 (), va);
+      svst1_s32 (svptrue_b32 (), b + j * 8, va);
+    }
+
+  res = svaddv_s32 (svptrue_b32 (), va);
+
+  if (res != 64)
+    __builtin_abort ();
+
+  for (j = 0; j < 64; j+=8)
+    if (b[j] != (j / 8 + 1))
+      __builtin_abort ();
+}
+
+void __attribute__ ((noipa))
+inscan_reduction_excl ()
+{
+  svint32_t va = svindex_s32 (0, 0);
+  int a[8] = {1, 1, 1, 1, 1, 1, 1, 1};
+  int b[64] = { 0 };
+  int j;
+  int64_t res = 0;
+
+  #pragma omp parallel for reduction (inscan, +:va)
+  for (j = 0; j < 8; j++)
+    {
+      svst1_s32 (svptrue_b32 (), b + j * 8, va);
+      #pragma omp scan exclusive (va)
+      va += svld1_s32 (svptrue_b32 (), a);
     }
 
+  res = svaddv_s32 (svptrue_b32 (), va);
+
   if (res != 64)
     __builtin_abort ();
+
+  for (j = 0; j < 64; j+=8)
+    if (b[j] != j / 8)
+      __builtin_abort ();
 }
 
+
 int
 main ()
 {
@@ -95,4 +130,5 @@ main ()
   for_reduction ();
   simd_reduction ();
   inscan_reduction_incl ();
+  inscan_reduction_excl ();
 }