diff mbox series

[og7,openacc,libgomp,testsuite] Fix asserts in non-scalar-data.C

Message ID bb52a24c-6b7a-6b7a-1619-8541b7b00b55@mentor.com
State New
Headers show
Series [og7,openacc,libgomp,testsuite] Fix asserts in non-scalar-data.C | expand

Commit Message

Tom de Vries April 18, 2018, 9 a.m. UTC
[ was: Re: [gomp4] fix c++ reference mappings in openacc ]


On 01/21/2016 04:47 AM, Cesar Philippidis wrote:
> diff --git a/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C b/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C
> new file mode 100644
> index 0000000..180e86f
> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C
> @@ -0,0 +1,109 @@
> +// Ensure that a non-scalar dummy arguments which are implicitly used inside
> +// offloaded regions are properly mapped using present_or_copy.
> +
> +// { dg-do run }
> +
> +#include <cassert>
> +
> +const int n = 100;
> +
> +struct data {
> +  int v;
> +};
> +
> +void
> +kernels_present (data &d, int &x)
> +{
> +#pragma acc kernels present (d, x) default (none)
> +  {
> +    d.v = x;
> +  }
> +}
> +
> +void
> +parallel_present (data &d, int &x)
> +{
> +#pragma acc parallel present (d, x) default (none)
> +  {
> +    d.v = x;
> +  }
> +}
> +
> +void
> +kernels_implicit (data &d, int &x)
> +{
> +#pragma acc kernels
> +  {
> +    d.v = x;
> +  }
> +}
> +
> +void
> +parallel_implicit (data &d, int &x)
> +{
> +#pragma acc parallel
> +  {
> +    d.v = x;
> +  }
> +}
> +
> +void
> +reference_data (data &d, int &x)
> +{
> +#pragma acc data copy(d, x)
> +  {
> +    kernels_present (d, x);
> +
> +#pragma acc update host(d)
> +    assert (d.v == x);
> +
> +    x = 200;
> +#pragma acc update device(x)
> +
> +    parallel_present (d, x);
> +  }
> +
> +  assert (d.v = x);
> +
> +  x = 300;
> +  kernels_implicit (d, x);
> +  assert (d.v = x);
> +
> +  x = 400;
> +  parallel_implicit (d, x);
> +  assert (d.v = x);
> +}
> +
> +int
> +main ()
> +{
> +  data d;
> +  int x = 100;
> +
> +#pragma acc data copy(d, x)
> +  {
> +    kernels_present (d, x);
> +
> +#pragma acc update host(d)
> +    assert (d.v == x);
> +
> +    x = 200;
> +#pragma acc update device(x)
> +
> +    parallel_present (d, x);
> +  }
> +
> +  assert (d.v = x);
> +
> +  x = 300;
> +  kernels_implicit (d, x);
> +  assert (d.v = x);
> +
> +  x = 400;
> +  parallel_implicit (d, x);
> +  assert (d.v = x);
> +
> +  reference_data (d, x);
> +
> +  return 0;
> +}
> 

Some of these assert have assigns in them.

Fixed in attached patch, committed.

Thanks,
- Tom
diff mbox series

Patch

[openacc, libgomp, testsuite] Fix asserts in non-scalar-data.C

2018-04-18  Tom de Vries  <tom@codesourcery.com>

	* testsuite/libgomp.oacc-c++/non-scalar-data.C (reference_data, main):
	Fix asserts.

---
 libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C b/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C
index f24e31e..8143533 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/non-scalar-data.C
@@ -69,15 +69,15 @@  reference_data (data &d, int &x)
     parallel_present (d, x);
   }
 
-  assert (d.v = x);
+  assert (d.v == x);
 
   x = 300;
   kernels_implicit (d, x);
-  assert (d.v = x);
+  assert (d.v == x);
 
   x = 400;
   parallel_implicit (d, x);
-  assert (d.v = x);
+  assert (d.v == x);
 }
 
 int
@@ -99,15 +99,15 @@  main ()
     parallel_present (d, x);
   }
 
-  assert (d.v = x);
+  assert (d.v == x);
 
   x = 300;
   kernels_implicit (d, x);
-  assert (d.v = x);
+  assert (d.v == x);
 
   x = 400;
   parallel_implicit (d, x);
-  assert (d.v = x);
+  assert (d.v == x);
 
   reference_data (d, x);