aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2018-04-19 10:53:38 +0200
committerThomas Schwinge <tschwinge@gcc.gnu.org>2018-04-19 10:53:38 +0200
commit6e0d40b6f82b3573b7345e0400000dbd612541b7 (patch)
tree24ddf33011e25e1eeddf1b584fb5a990e27ed36e
parent1781a04fcc32c710b4bcd9080d8e1d7462ca3226 (diff)
PR85463 '[nvptx] "exit" in offloaded region doesn't terminate process'
libgomp/ PR libfortran/85166 * testsuite/libgomp.oacc-fortran/abort-1.f90: Switch back to "call abort". * testsuite/libgomp.oacc-fortran/abort-2.f90: Likewise. libgfortran/ PR libfortran/85166 PR libgomp/85463 * runtime/minimal.c (stop_numeric): Reimplement. (stop_string, error_stop_string, error_stop_numeric): New functions. libgomp/ PR libgomp/85463 * testsuite/libgomp.oacc-fortran/error_stop-1.f: New file. * testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise. * testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise. * testsuite/libgomp.oacc-fortran/stop-1.f: Likewise. * testsuite/libgomp.oacc-fortran/stop-2.f: Likewise. * testsuite/libgomp.oacc-fortran/stop-3.f: Likewise. From-SVN: r259491
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/runtime/minimal.c80
-rw-r--r--libgomp/ChangeLog15
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/abort-1.f905
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/abort-2.f905
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f20
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f20
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f20
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/stop-1.f22
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/stop-2.f20
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/stop-3.f23
11 files changed, 234 insertions, 4 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index d4a1fbb08ab..ea4358cc54e 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2018-04-19 Thomas Schwinge <thomas@codesourcery.com>
+
+ PR libfortran/85166
+ PR libgomp/85463
+ * runtime/minimal.c (stop_numeric): Reimplement.
+ (stop_string, error_stop_string, error_stop_numeric): New
+ functions.
+
2018-04-19 Jakub Jelinek <jakub@redhat.com>
* configure: Regenerated.
diff --git a/libgfortran/runtime/minimal.c b/libgfortran/runtime/minimal.c
index e17666b7b82..0b1efeb0d58 100644
--- a/libgfortran/runtime/minimal.c
+++ b/libgfortran/runtime/minimal.c
@@ -188,6 +188,22 @@ sys_abort (void)
abort();
}
+
+/* runtime/stop.c */
+
+#undef report_exception
+#define report_exception() do {} while (0)
+#undef st_printf
+#define st_printf printf
+#undef estr_write
+#define estr_write printf
+/* Map "exit" to "abort"; see PR85463 '[nvptx] "exit" in offloaded region
+ doesn't terminate process'. */
+#undef exit
+#define exit(...) do { abort (); } while (0)
+#undef exit_error
+#define exit_error(...) do { abort (); } while (0)
+
/* A numeric STOP statement. */
extern _Noreturn void stop_numeric (int, bool);
@@ -197,7 +213,67 @@ void
stop_numeric (int code, bool quiet)
{
if (!quiet)
- printf ("STOP %d\n", code);
-
+ {
+ report_exception ();
+ st_printf ("STOP %d\n", code);
+ }
exit (code);
}
+
+
+/* A character string or blank STOP statement. */
+
+void
+stop_string (const char *string, size_t len, bool quiet)
+{
+ if (!quiet)
+ {
+ report_exception ();
+ if (string)
+ {
+ estr_write ("STOP ");
+ (void) write (STDERR_FILENO, string, len);
+ estr_write ("\n");
+ }
+ }
+ exit (0);
+}
+
+
+/* Per Fortran 2008, section 8.4: "Execution of a STOP statement initiates
+ normal termination of execution. Execution of an ERROR STOP statement
+ initiates error termination of execution." Thus, error_stop_string returns
+ a nonzero exit status code. */
+
+extern _Noreturn void error_stop_string (const char *, size_t, bool);
+export_proto(error_stop_string);
+
+void
+error_stop_string (const char *string, size_t len, bool quiet)
+{
+ if (!quiet)
+ {
+ report_exception ();
+ estr_write ("ERROR STOP ");
+ (void) write (STDERR_FILENO, string, len);
+ estr_write ("\n");
+ }
+ exit_error (1);
+}
+
+
+/* A numeric ERROR STOP statement. */
+
+extern _Noreturn void error_stop_numeric (int, bool);
+export_proto(error_stop_numeric);
+
+void
+error_stop_numeric (int code, bool quiet)
+{
+ if (!quiet)
+ {
+ report_exception ();
+ st_printf ("ERROR STOP %d\n", code);
+ }
+ exit_error (code);
+}
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 1025acb5d81..f68a4a83fad 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,18 @@
+2018-04-19 Thomas Schwinge <thomas@codesourcery.com>
+
+ PR libgomp/85463
+ * testsuite/libgomp.oacc-fortran/error_stop-1.f: New file.
+ * testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise.
+ * testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise.
+ * testsuite/libgomp.oacc-fortran/stop-1.f: Likewise.
+ * testsuite/libgomp.oacc-fortran/stop-2.f: Likewise.
+ * testsuite/libgomp.oacc-fortran/stop-3.f: Likewise.
+
+ PR libfortran/85166
+ * testsuite/libgomp.oacc-fortran/abort-1.f90: Switch back to "call
+ abort".
+ * testsuite/libgomp.oacc-fortran/abort-2.f90: Likewise.
+
2018-04-19 Jakub Jelinek <jakub@redhat.com>
* configure: Regenerated.
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90
index dde35123e79..fc0af7ff7d8 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90
+++ b/libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90
@@ -1,9 +1,12 @@
+! Verify that an unconditional "call abort" inside an OpenACC parallel region
+! does the right thing.
+
program main
implicit none
print *, "CheCKpOInT"
!$acc parallel
- STOP 1
+ call abort
!$acc end parallel
end program main
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90
index 68d90e94539..97a692ba667 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90
+++ b/libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90
@@ -1,3 +1,6 @@
+! Verify that a conditional "call abort" inside an OpenACC parallel region does
+! the right thing.
+
program main
implicit none
@@ -6,7 +9,7 @@ program main
!$acc parallel copyin(argc)
if (argc .ne. 0) then
- STOP 1
+ call abort
end if
!$acc end parallel
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f
new file mode 100644
index 00000000000..4965e674c27
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f
@@ -0,0 +1,20 @@
+! { dg-do run }
+
+ PROGRAM MAIN
+ IMPLICIT NONE
+
+ PRINT *, "CheCKpOInT"
+!$ACC PARALLEL
+ ERROR STOP
+!$ACC END PARALLEL
+ PRINT *, "WrONg WAy"
+
+ END PROGRAM MAIN
+
+! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+! { dg-output "ERROR STOP (\n|\r\n|\r)+" }
+! PR85463. The "minimal" libgfortran implementation used with nvptx
+! offloading is a little bit different.
+! { dg-output "Error termination.*" { target { ! openacc_nvidia_accel_selected } } }
+! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } }
+! { dg-shouldfail "" }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f
new file mode 100644
index 00000000000..7103fdb5d8e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f
@@ -0,0 +1,20 @@
+! { dg-do run }
+
+ PROGRAM MAIN
+ IMPLICIT NONE
+
+ PRINT *, "CheCKpOInT"
+!$ACC PARALLEL
+ ERROR STOP 35
+!$ACC END PARALLEL
+ PRINT *, "WrONg WAy"
+
+ END PROGRAM MAIN
+
+! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+! { dg-output "ERROR STOP 35(\n|\r\n|\r)+" }
+! PR85463. The "minimal" libgfortran implementation used with nvptx
+! offloading is a little bit different.
+! { dg-output "Error termination.*" { target { ! openacc_nvidia_accel_selected } } }
+! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } }
+! { dg-shouldfail "" }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f
new file mode 100644
index 00000000000..9c217f14ea1
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f
@@ -0,0 +1,20 @@
+! { dg-do run }
+
+ PROGRAM MAIN
+ IMPLICIT NONE
+
+ PRINT *, "CheCKpOInT"
+!$ACC PARALLEL
+ ERROR STOP "SiGN"
+!$ACC END PARALLEL
+ PRINT *, "WrONg WAy"
+
+ END PROGRAM MAIN
+
+! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+! { dg-output "ERROR STOP SiGN(\n|\r\n|\r)+" }
+! PR85463. The "minimal" libgfortran implementation used with nvptx
+! offloading is a little bit different.
+! { dg-output "Error termination.*" { target { ! openacc_nvidia_accel_selected } } }
+! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } }
+! { dg-shouldfail "" }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f
new file mode 100644
index 00000000000..af267fc08d1
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f
@@ -0,0 +1,22 @@
+! { dg-do run }
+
+ PROGRAM MAIN
+ IMPLICIT NONE
+
+ PRINT *, "CheCKpOInT"
+!$ACC PARALLEL
+ STOP
+!$ACC END PARALLEL
+ PRINT *, "WrONg WAy"
+
+ END PROGRAM MAIN
+
+! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+! PR85463. The "minimal" libgfortran implementation used with nvptx
+! offloading is a little bit different.
+! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } }
+! { dg-output "$" }
+! PR85463. STOP with code zero (as implied here) should actually
+! terminate the process normally, but doesn't in the "minimal"
+! libgfortran implementation used with nvptx offloading.
+! { dg-shouldfail "" { openacc_nvidia_accel_selected } }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f
new file mode 100644
index 00000000000..13c06845c08
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f
@@ -0,0 +1,20 @@
+! { dg-do run }
+
+ PROGRAM MAIN
+ IMPLICIT NONE
+
+ PRINT *, "CheCKpOInT"
+!$ACC PARALLEL
+ STOP 35
+!$ACC END PARALLEL
+ PRINT *, "WrONg WAy"
+
+ END PROGRAM MAIN
+
+! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+! { dg-output "STOP 35(\n|\r\n|\r)+" }
+! PR85463. The "minimal" libgfortran implementation used with nvptx
+! offloading is a little bit different.
+! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } }
+! { dg-output "$" }
+! { dg-shouldfail "" }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f
new file mode 100644
index 00000000000..3bd7446571d
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f
@@ -0,0 +1,23 @@
+! { dg-do run }
+
+ PROGRAM MAIN
+ IMPLICIT NONE
+
+ PRINT *, "CheCKpOInT"
+!$ACC PARALLEL
+ STOP "SiGN"
+!$ACC END PARALLEL
+ PRINT *, "WrONg WAy"
+
+ END PROGRAM MAIN
+
+! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+! { dg-output "STOP SiGN(\n|\r\n|\r)+" }
+! PR85463. The "minimal" libgfortran implementation used with nvptx
+! offloading is a little bit different.
+! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } }
+! { dg-output "$" }
+! PR85463. STOP with code zero (as implied here) should actually
+! terminate the process normally, but doesn't in the "minimal"
+! libgfortran implementation used with nvptx offloading.
+! { dg-shouldfail "" { openacc_nvidia_accel_selected } }