public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1893] Add libgomp.c-c++-common/pr106449-2.c
@ 2022-07-29 10:42 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2022-07-29 10:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0

commit r13-1893-g85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Jul 29 12:41:08 2022 +0200

    Add libgomp.c-c++-common/pr106449-2.c
    
    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.

Diff:
---
 .../testsuite/libgomp.c-c++-common/pr106449-2.c    | 64 ++++++++++++++++++++++
 1 file changed, 64 insertions(+)

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
index 00000000000..7fef7461bcf
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c
@@ -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;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-29 10:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 10:42 [gcc r13-1893] Add libgomp.c-c++-common/pr106449-2.c Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).