[gomp4] libgomp: Additional acc_shutdown bug fixing and testing (was: [gomp4, PATCH] Fix libgomp.oacc-c-c++-common/lib-3.c)

Thomas Schwinge thomas@codesourcery.com
Wed Jul 22 14:49:00 GMT 2015


Hi!

On Wed, 22 Jul 2015 16:32:17 +0200, I wrote:
> On Wed, 1 Jul 2015 13:16:14 +0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
> > testcase libgomp.oacc-c-c++-common/lib-3.c is supposed to fail.

> --- libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c
> +++ libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c
> @@ -1,4 +1,6 @@
> -/* { dg-do run } */
> +/* Expect an error message when shutting down a device different from the one
> +   that has been initialized.  */
> +/* { dg-do run { target { ! openacc_host_selected } } } */
>  
>  #include <openacc.h>
>  
> @@ -6,12 +8,10 @@ int
>  main (int argc, char **argv)
>  {
>    acc_init (acc_device_host);
> -
> -  acc_shutdown (acc_device_not_host);
> +  acc_shutdown (acc_device_default);
>  
>    return 0;
>  }
>  
> -/* TODO: currently prints: "libgomp: no device found".  */
> -/* { dg-output "device \[0-9\]+\\\(\[0-9\]+\\\) is initialized" { xfail *-*-* } } */
> +/* { dg-output "no device initialized" } */
>  /* { dg-shouldfail "" } */

Looking at this issue, I had found an inconsistency in libgomp; committed
to gomp-4_0-branch in r226071:

commit 4e1d42a292c3f868f63ec0b9a3577b6344e087e5
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Jul 22 14:24:33 2015 +0000

    libgomp: Additional acc_shutdown bug fixing and testing
    
    	libgomp/
    	* oacc-init.c (acc_shutdown): Call gomp_init_targets_once.
    	* testsuite/libgomp.oacc-c-c++-common/lib-8.c: New file.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@226071 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp                              |  3 +++
 libgomp/oacc-init.c                                 |  2 ++
 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-8.c | 16 ++++++++++++++++
 3 files changed, 21 insertions(+)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index d71282c..0d3c62f 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,8 @@
 2015-07-22  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* oacc-init.c (acc_shutdown): Call gomp_init_targets_once.
+	* testsuite/libgomp.oacc-c-c++-common/lib-8.c: New file.
+
 	* testsuite/libgomp.oacc-c-c++-common/lib-3.c: Resolve XFAIL.
 
 2015-07-21  James Norris  <jnorris@codesourcery.com>
diff --git libgomp/oacc-init.c libgomp/oacc-init.c
index 63ac710..f0d1df9 100644
--- libgomp/oacc-init.c
+++ libgomp/oacc-init.c
@@ -461,6 +461,8 @@ ialias (acc_init)
 void
 acc_shutdown (acc_device_t d)
 {
+  gomp_init_targets_once ();
+
   gomp_mutex_lock (&acc_device_lock);
 
   acc_shutdown_1 (d);
diff --git libgomp/testsuite/libgomp.oacc-c-c++-common/lib-8.c libgomp/testsuite/libgomp.oacc-c-c++-common/lib-8.c
new file mode 100644
index 0000000..5eb28af
--- /dev/null
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/lib-8.c
@@ -0,0 +1,16 @@
+/* Expect error message when shutting down a device that has never been
+   initialized.  */
+/* { dg-do run } */
+
+#include <openacc.h>
+
+int
+main (int argc, char **argv)
+{
+  acc_shutdown (acc_device_default);
+
+  return 0;
+}
+
+/* { dg-output "no device initialized" } */
+/* { dg-shouldfail "" } */


Grüße,
 Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150722/9cd9e242/attachment.sig>


More information about the Gcc-patches mailing list