diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2022-07-29 12:41:08 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2022-07-29 12:41:08 +0200 |
commit | 85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0 (patch) | |
tree | a846d0a9aa2452450f9ac75de82f745358afecbd | |
parent | a6afbe5e9528e9ec3f0426d9791bd28e6e584d82 (diff) | |
download | gcc-85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0.zip gcc-85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0.tar.gz gcc-85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0.tar.bz2 |
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.
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/pr106449-2.c | 64 |
1 files changed, 64 insertions, 0 deletions
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 0000000..7fef746 --- /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; +} |