diff mbox

[gomp4] declare directive [5/5]

Message ID 87380s1dbn.fsf@kepler.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge July 13, 2015, 11:55 a.m. UTC
Hi Jim!

On Mon, 8 Jun 2015 10:06:21 -0500, James Norris <jnorris@codesourcery.com> wrote:
> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.oacc-c++/declare-1.C
> @@ -0,0 +1,24 @@
> +
> +template<class T>
> +T foo()
> +{
> +  T a;
> +  #pragma acc declare create (a)
> +
> +  #pragma acc parallel
> +  {
> +    a = 5;
> +  }
> +
> +  return a;
> +}
> +
> +int
> +main (void)
> +{
> +  int rc;
> +
> +  rc = foo<int>();
> +
> +  return rc;
> +}

I wonder, in a shared-memory setting (say, host-fallback because of the
OpenACC if clause, or acc_device_host, or acc_device_host_nonshm),
shouldn't the original and "declare"d objects of variable a be the same
(just like with the other data clauses), and thus the function foo return
the value 5 instead of 0?


Anyway, as-is, this test case FAILed in 32-bit x86 GNU/Linux testing
(acc_device_host, acc_device_host_nonshm), which I fixed in r225734 as
follows:

commit 016e15e94b8511f2041646c43d4344e1ea424e62
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Jul 13 11:48:33 2015 +0000

    libgomp testsuite: Don't read from uninitialized variables
    
    	libgomp/
    	* testsuite/libgomp.oacc-c++/declare-1.C (foo): Initialize a.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@225734 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp                         | 2 ++
 libgomp/testsuite/libgomp.oacc-c++/declare-1.C | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)



Grüße,
 Thomas
diff mbox

Patch

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index fd7887a..7d1e9ad 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,7 @@ 
 2015-07-13  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* testsuite/libgomp.oacc-c++/declare-1.C (foo): Initialize a.
+
 	* testsuite/libgomp.oacc-c-c++-common/private-vars-loop-gang-5.c:
 	Add XFAIL.
 
diff --git libgomp/testsuite/libgomp.oacc-c++/declare-1.C libgomp/testsuite/libgomp.oacc-c++/declare-1.C
index 268809b..6618b10 100644
--- libgomp/testsuite/libgomp.oacc-c++/declare-1.C
+++ libgomp/testsuite/libgomp.oacc-c++/declare-1.C
@@ -2,7 +2,7 @@ 
 template<class T>
 T foo()
 {
-  T a;
+  T a = 0;
   #pragma acc declare create (a)
 
   #pragma acc parallel