From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 8C5423857B88; Fri, 29 Jul 2022 10:45:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C5423857B88 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] Add libgomp.c-c++-common/pr106449-2.c X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 547a6252e94837e143f13bd7f8dc5f38dd5acd1a X-Git-Newrev: c68a8f1a9672e21bd62a53b18d6f08c448e669ee Message-Id: <20220729104525.8C5423857B88@sourceware.org> Date: Fri, 29 Jul 2022 10:45:25 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2022 10:45:25 -0000 https://gcc.gnu.org/g:c68a8f1a9672e21bd62a53b18d6f08c448e669ee commit c68a8f1a9672e21bd62a53b18d6f08c448e669ee Author: Tobias Burnus Date: Fri Jul 29 12:44:45 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. (cherry picked from commit 85fe7e7dd1f1461b86d92a3a0c1bfd97a06efcc0) Diff: --- libgomp/ChangeLog.omp | 7 +++ .../testsuite/libgomp.c-c++-common/pr106449-2.c | 64 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index ef977cab3d3..9821d702a32 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,10 @@ +2022-07-29 Tobias Burnus + + Backport from mainline: + 2022-07-29 Tobias Burnus + + * libgomp.c-c++-common/pr106449-2.c: New test. + 2022-07-13 Tobias Burnus 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 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; +}