]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite/libgomp.*/target-present-*.{c,f90}: Improve and fix
authorTobias Burnus <tobias@codesourcery.com>
Wed, 7 Jun 2023 11:22:13 +0000 (13:22 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 7 Jun 2023 11:23:30 +0000 (13:23 +0200)
One of the testcases lacked variables in a map clause such that
the fail occurred too early. Additionally, it would have failed
for all those non-host devices where 'present' is always true, i.e.
non-host devices which can access all of the host memory
(shared-memory devices). [There are currently none.]

The commit now runs the code on all devices, which should succeed
for host fallback and for shared-memory devices, finding potenial issues
that way. Additionally, a checkpoint (required stdout output) is used
to ensure that the execution won't fail (with the same error) before
reaching the expected fail location.

2023-06-07  Thomas Schwinge  <thomas@codesourcery.com>
    Tobias Burnus  <tobias@codesourcery.com>

libgomp/
* testsuite/libgomp.c-c++-common/target-present-1.c: Run code
also for non-offload_device targets; check that it runs
successfully for those and for all until a checkpoint for all
* 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-3.f90: Likewise.
* testsuite/libgomp.fortran/target-present-2.f90: Likewise;
add missing vars to map clause.

libgomp/testsuite/libgomp.c-c++-common/target-present-1.c
libgomp/testsuite/libgomp.c-c++-common/target-present-2.c
libgomp/testsuite/libgomp.c-c++-common/target-present-3.c
libgomp/testsuite/libgomp.fortran/target-present-1.f90
libgomp/testsuite/libgomp.fortran/target-present-2.f90
libgomp/testsuite/libgomp.fortran/target-present-3.f90

index 12f154c91a89da95b55af2e2fa57b45233d434b4..aa343197e352c0bb473145db37519e5cb1975ab6 100644 (file)
@@ -1,5 +1,4 @@
-/* { dg-do run { target offload_device } } */
-/* { 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: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */
+    /* { dg-output "libgomp: present clause: not present on the device \\\(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];
index d4debbab10b73b044916ff97e192f5a4396c028d..ad11023b2d677833481ecfd9b2b85d6ad51e711e 100644 (file)
@@ -1,5 +1,4 @@
-/* { dg-do run { target offload_device } } */
-/* { 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 and 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: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */
+    /* { dg-output "libgomp: present clause: not present on the device \\\(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];
index 9d8d8f8a3350f2bfed0c0d1bcd1ed380317c9908..455519af4058620f13dc777b7d231c41ee953cfb 100644 (file)
@@ -1,6 +1,3 @@
-/* { dg-do run { target offload_device } } */
-/* { 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: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */
+  /* { dg-output "libgomp: present clause: not present on the device \\\(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)
index 349dcb118b238e86f29c7ef9e177ae74a2611a8d..768166fcff7259e62b08ac664ef813f75b0c92e7 100644 (file)
@@ -1,6 +1,3 @@
-! { dg-do run { target offload_device } }
-! { dg-shouldfail "present error triggered" }
-
 program main
   implicit none
   integer, parameter :: N = 100
@@ -19,8 +16,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: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" }
+    ! { dg-output "libgomp: present clause: not present on the device \\\(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)
index 07e79d1b576f701877de2700d94a82ec3851dc53..8f2c24ef5f261ad369c488c107b30844f1f77b57 100644 (file)
@@ -1,6 +1,3 @@
-! { dg-do run { target offload_device } }
-! { dg-shouldfail "present error triggered" }
-
 program main
   implicit none
   integer, parameter :: N = 100
@@ -11,16 +8,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, and 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: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" }
+    ! { dg-output "libgomp: present clause: not present on the device \\\(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)
index a2709eb6f179abe55ff843028f7b77efd76ac85c..eb29c907624677dd9e620075493514937b47e403 100644 (file)
@@ -1,6 +1,3 @@
-! { dg-do run { target offload_device } }
-! { dg-shouldfail "present error triggered" }
-
 program main
   implicit none
   integer, parameter :: N = 100
@@ -15,8 +12,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: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" }
+    ! { dg-output "libgomp: present clause: not present on the device \\\(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