]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add libgomp.c-c++-common/pr106449-2.c
authorTobias Burnus <tobias@codesourcery.com>
Fri, 29 Jul 2022 10:44:45 +0000 (12:44 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 29 Jul 2022 10:44:45 +0000 (12:44 +0200)
This run-time test test pointer-based iteration with collapse,
similar to the '(parallel) simd' test for PR106449 but for 'for'.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/pr106449-2.c: New test.

(cherry picked from commit 85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0)

libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c [new file with mode: 0644]

index ef977cab3d38443cb4b884bf479aeeaa7eaa7256..9821d702a320de676ada17b97786f10dad790e10 100644 (file)
@@ -1,3 +1,10 @@
+2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       2022-07-29  Tobias Burnus  <tobias@codesourcery.com>
+
+       * libgomp.c-c++-common/pr106449-2.c: New test.
+
 2022-07-13  Tobias Burnus  <tobias@codesourcery.com>
 
        Backport from mainline:
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c b/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c
new file mode 100644 (file)
index 0000000..7fef746
--- /dev/null
@@ -0,0 +1,64 @@
+/* { dg-do run } */
+
+/* Based on pr106449.c - but using 'for' instead of 'simd'.
+   Cf. PR middle-end/106449 (for pr106449.c) and PR middle-end/106467.  */
+
+void
+foo (void)
+{
+  int a[1024], *b[65536], *c[65536];
+  int *p, *q, **r = &b[0], **r2 = &c[0], i;
+  #pragma omp for collapse(2)
+  for (p = &a[0]; p < &a[512]; p++)
+    for (q = p + 64; q < p + 128; q++)
+      {
+       *r++ = p;
+       *r2++ = q;
+      }
+  for (i = 0; i < 32768; i++)
+    if (b[i] != &a[i / 64] || c[i] != &a[(i / 64) + 64 + (i % 64)])
+      __builtin_abort ();
+}
+
+void
+bar (int n, int m)
+{
+  int a[1024], *b[32768], *c[32768];
+  int *p, *q, **r = &b[0], **r2 = &c[0], i;
+  #pragma omp for collapse(2)
+  for (p = &a[0]; p < &a[512]; p++)
+    for (q = p + n; q < p + m; q++)
+      {
+       *r++ = p;
+       *r2++ = q;
+      }
+  for (i = 0; i < 32768; i++)
+    if (b[i] != &a[i / 64] || c[i] != &a[(i / 64) + 64 + (i % 64)])
+      __builtin_abort ();
+}
+
+void
+baz (int n, int m)
+{
+  int a[1024], *b[8192], *c[8192];
+  int *p, *q, **r = &b[0], **r2 = &c[0], i;
+  #pragma omp for collapse(2)
+  for (p = &a[0]; p < &a[512]; p += 4)
+    for (q = p + n; q < p + m; q += 2)
+      {
+       *r++ = p;
+       *r2++ = q;
+      }
+  for (i = 0; i < 4096; i++)
+    if (b[i] != &a[(i / 32) * 4] || c[i] != &a[(i / 32) * 4 + 64 + (i % 32) * 2])
+      __builtin_abort ();
+}
+
+int
+main ()
+{
+  foo ();
+  bar (64, 128);
+  baz (64, 128);
+  return 0;
+}