This patch fixes a corner case issue (missing list items in a map clause)
and ensures that such an issue is caught.
Committed to mainline as https://gcc.gnu.org/r14-1605-gdd958667821e38
It is a forward port of Thomas' OG12 then OG13 commit which fixed
a run-time issue which the mainline version does not have; still fixing
the map issue (and doing the check-point check) is a good idea and,
hence, the patch was applied to mainline as well.
OG13 commit: https://gcc.gnu.org/g:f719ab9a3ac51d798b012a5ab7757af2b81b4ae2
OG12 commit, see Thomas email earlier in this thread.
Tobias
On 15.02.23 20:02, Thomas Schwinge wrote:
> On 2023-02-09T21:17:44+0000, Kwok Cheung Yeung <kcy@codesourcery.com> wrote:
>> [...]
> I've pushed to devel/omp/gcc-12 branch
> commit bbda035ee62ba4db21356136c97e9d83a97ba7d1
> "Fix 'libgomp.{c-c++-common,fortran}/target-present-*' test cases",
> see attached. [...]
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
From bbda035ee62ba4db21356136c97e9d83a97ba7d1 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 15 Feb 2023 12:39:19 +0100
Subject: [PATCH] Fix 'libgomp.{c-c++-common,fortran}/target-present-*' test
cases
Their execution isn't expected to error out if we've been *compiling for any
offload target*, but rather if they're *executing on a non-shared memory
offload device*. For example, if (any) offloading is configured but not
effective (no device available, for example), you'd get:
PASS: libgomp.c/../libgomp.c-c++-common/target-present-1.c (test for excess errors)
FAIL: libgomp.c/../libgomp.c-c++-common/target-present-1.c execution test
PASS: libgomp.c/../libgomp.c-c++-common/target-present-2.c (test for excess errors)
FAIL: libgomp.c/../libgomp.c-c++-common/target-present-2.c execution test
PASS: libgomp.c/../libgomp.c-c++-common/target-present-3.c (test for excess errors)
FAIL: libgomp.c/../libgomp.c-c++-common/target-present-3.c execution test
PASS: libgomp.c++/../libgomp.c-c++-common/target-present-1.c (test for excess errors)
FAIL: libgomp.c++/../libgomp.c-c++-common/target-present-1.c execution test
PASS: libgomp.c++/../libgomp.c-c++-common/target-present-2.c (test for excess errors)
FAIL: libgomp.c++/../libgomp.c-c++-common/target-present-2.c execution test
PASS: libgomp.c++/../libgomp.c-c++-common/target-present-3.c (test for excess errors)
FAIL: libgomp.c++/../libgomp.c-c++-common/target-present-3.c execution test
PASS: libgomp.fortran/target-present-1.f90 -O0 (test for excess errors)
FAIL: libgomp.fortran/target-present-1.f90 -O0 execution test
[...]
PASS: libgomp.fortran/target-present-2.f90 -O0 (test for excess errors)
FAIL: libgomp.fortran/target-present-2.f90 -O0 execution test
[...]
PASS: libgomp.fortran/target-present-3.f90 -O0 (test for excess errors)
FAIL: libgomp.fortran/target-present-3.f90 -O0 execution test
[...]
Also, verify reaching a checkpoint before the expected error condition -- and
fix up one case where that didn't happen; missing OpenMP 'map' clauses
('libgomp.fortran/target-present-2.f90').
Fix-up for recent og12 commit 229b705862c1d7f9634f72272b77c22970baf821
"openmp: Add support for the 'present' modifier"
libgomp/
* testsuite/libgomp.c-c++-common/target-present-1.c: Fix.
* testsuite/libgomp.c-c++-common/target-present-2.c: Likewise.
* testsuite/libgomp.c-c++-common/target-present-3.c: Likewise.
* testsuite/libgomp.fortran/target-present-1.f90: Likewise.
* testsuite/libgomp.fortran/target-present-2.f90: Likewise.
* testsuite/libgomp.fortran/target-present-3.f90: Likewise.
---
libgomp/ChangeLog.omp | 9 +++++++++
.../libgomp.c-c++-common/target-present-1.c | 9 ++++++---
.../libgomp.c-c++-common/target-present-2.c | 11 +++++++----
.../libgomp.c-c++-common/target-present-3.c | 9 +++++----
.../testsuite/libgomp.fortran/target-present-1.f90 | 9 ++++++---
.../testsuite/libgomp.fortran/target-present-2.f90 | 13 ++++++++-----
.../testsuite/libgomp.fortran/target-present-3.f90 | 9 ++++++---
7 files changed, 47 insertions(+), 22 deletions(-)
@@ -1,3 +1,12 @@
+2023-02-15 Thomas Schwinge <thomas@codesourcery.com>
+
+ * testsuite/libgomp.c-c++-common/target-present-1.c: Fix.
+ * testsuite/libgomp.c-c++-common/target-present-2.c: Likewise.
+ * testsuite/libgomp.c-c++-common/target-present-3.c: Likewise.
+ * testsuite/libgomp.fortran/target-present-1.f90: Likewise.
+ * testsuite/libgomp.fortran/target-present-2.f90: Likewise.
+ * testsuite/libgomp.fortran/target-present-3.f90: Likewise.
+
2023-02-15 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
@@ -1,5 +1,4 @@
-/* { dg-do run { target offload_target_any } } */
-/* { dg-shouldfail "present error triggered" } */
+#include <stdio.h>
#define N 100
@@ -18,8 +17,12 @@ int main (void)
for (int i = 0; i < N; i++)
c[i] = a[i];
+ fprintf (stderr, "CheCKpOInT\n");
+ /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
+
/* b has not been allocated, so this should result in an error. */
- /* { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */
+ /* { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } }
+ { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */
#pragma omp target map (present, to: b)
for (int i = 0; i < N; i++)
c[i] += b[i];
@@ -1,5 +1,4 @@
-/* { dg-do run { target offload_target_any } } */
-/* { dg-shouldfail "present error triggered" } */
+#include <stdio.h>
#define N 100
@@ -13,13 +12,17 @@ int main (void)
}
#pragma omp target enter data map (alloc: a, c)
- /* a has already been allocated, so this should be okay. */
+ /* a, c have already been allocated, so this should be okay. */
#pragma omp target defaultmap (present)
for (int i = 0; i < N; i++)
c[i] = a[i];
+ fprintf (stderr, "CheCKpOInT\n");
+ /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
+
/* b has not been allocated, so this should result in an error. */
- /* { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */
+ /* { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } }
+ { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */
#pragma omp target defaultmap (present)
for (int i = 0; i < N; i++)
c[i] += b[i];
@@ -1,6 +1,3 @@
-/* { dg-do run { target offload_target_any } } */
-/* { dg-shouldfail "present error triggered" } */
-
#include <stdio.h>
#define N 100
@@ -19,8 +16,12 @@ int main (void)
/* This should work as a has already been allocated. */
#pragma omp target update to (present: a)
+ fprintf (stderr, "CheCKpOInT\n");
+ /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
+
/* This should fail as b has not been allocated. */
- /* { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */
+ /* { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } }
+ { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */
#pragma omp target update to (present: b)
#pragma omp target exit data map (from: c)
@@ -1,5 +1,4 @@
-! { dg-do run { target offload_target_any } }
-! { dg-shouldfail "present error triggered" }
+! { dg-do run }
program main
implicit none
@@ -19,8 +18,12 @@ program main
end do
!$omp end target
+ print *, "CheCKpOInT"
+ ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" }
+
! b has not been allocated, so this should result in an error.
- ! { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" }
+ ! { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } }
+ ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } }
!$omp target map (present, to: b)
do i = 1, N
c(i) = c(i) + b(i)
@@ -1,5 +1,4 @@
-! { dg-do run { target offload_target_any } }
-! { dg-shouldfail "present error triggered" }
+! { dg-do run }
program main
implicit none
@@ -11,16 +10,20 @@ program main
b(i) = i * 3 + 1
end do
- !$omp target enter data map (alloc: a)
- ! a has already been allocated, so this should be okay.
+ !$omp target enter data map (alloc: a, c, i)
+ ! a, c, i have already been allocated, so this should be okay.
!$omp target defaultmap (present)
do i = 1, N
c(i) = a(i)
end do
!$omp end target
+ print *, "CheCKpOInT"
+ ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" }
+
! b has not been allocated, so this should result in an error.
- ! { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" }
+ ! { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } }
+ ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } }
!$omp target defaultmap (present)
do i = 1, N
c(i) = c(i) + b(i)
@@ -1,5 +1,4 @@
-! { dg-do run { target offload_target_any } }
-! { dg-shouldfail "present error triggered" }
+! { dg-do run }
program main
implicit none
@@ -15,8 +14,12 @@ program main
! This should work as a has already been allocated.
!$omp target update to (present: a)
+ print *, "CheCKpOInT"
+ ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" }
+
! This should fail as b has not been allocated.
- ! { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" }
+ ! { dg-output "libgomp: present clause: !omp_target_is_present \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } }
+ ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } }
!$omp target update to (present: b)
!$omp target exit data map (from: c)
end program
--
2.25.1