diff mbox

[gomp4,committed] Add goacc/kernels-acc-on-device.c

Message ID 5618ED1D.60906@mentor.com
State New
Headers show

Commit Message

Tom de Vries Oct. 10, 2015, 10:49 a.m. UTC
Hi,

this patch adds a new kernels region test-case.

Committed to gomp-4_0-branch as trivial.

Thanks,
- Tom

Comments

Thomas Schwinge Oct. 12, 2015, 10:49 a.m. UTC | #1
Hi Tom!

On Sat, 10 Oct 2015 12:49:01 +0200, Tom de Vries <Tom_deVries@mentor.com> wrote:
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/goacc/kernels-acc-on-device.c
> @@ -0,0 +1,39 @@
> +/* { dg-additional-options "-O2" } */
> +
> +#include <openacc.h>

That doesn't work (at least in build-tree testing), as gcc/testsuite/ is
not set up to look for header files in [target]/libgomp/:

    [...]/source-gcc/gcc/testsuite/c-c++-common/goacc/kernels-acc-on-device.c:3:21: fatal error: openacc.h: No such file or directory
    compilation terminated.
    compiler exited with status 1

> +
> +#define N 32
> +
> +void
> +foo (float *a, float *b)
> +{
> +  float exp;
> +  int i;
> +  int n;
> +
> +#pragma acc kernels copyin(a[0:N]) copyout(b[0:N])
> +  {
> +    int ii;
> +
> +    for (ii = 0; ii < N; ii++)
> +      {
> +	if (acc_on_device (acc_device_host))

Your two options are: if that's applicable/sufficient for what you intend
to test here, use __builtin_acc_on_device with a hard-coded acc_device_*,
or duplicate part of <openacc.h> as done for example in
gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c.

> +	  b[ii] = a[ii] + 1;
> +	else
> +	  b[ii] = a[ii];
> +      }
> +  }
> +
> +#pragma acc kernels copyin(a[0:N]) copyout(b[0:N])
> +  {
> +    int ii;
> +
> +    for (ii = 0; ii < N; ii++)
> +      {
> +	if (acc_on_device (acc_device_host))
> +	  b[ii] = a[ii] + 2;
> +	else
> +	  b[ii] = a[ii];
> +      }
> +  }
> +}


Grüße,
 Thomas
diff mbox

Patch

Add goacc/kernels-acc-on-device.c

2015-10-10  Tom de Vries  <tom@codesourcery.com>

	* c-c++-common/goacc/kernels-acc-on-device.c: New test.
---
 .../c-c++-common/goacc/kernels-acc-on-device.c     | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-acc-on-device.c

diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-acc-on-device.c b/gcc/testsuite/c-c++-common/goacc/kernels-acc-on-device.c
new file mode 100644
index 0000000..e9e93c7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-acc-on-device.c
@@ -0,0 +1,39 @@ 
+/* { dg-additional-options "-O2" } */
+
+#include <openacc.h>
+
+#define N 32
+
+void
+foo (float *a, float *b)
+{
+  float exp;
+  int i;
+  int n;
+
+#pragma acc kernels copyin(a[0:N]) copyout(b[0:N])
+  {
+    int ii;
+
+    for (ii = 0; ii < N; ii++)
+      {
+	if (acc_on_device (acc_device_host))
+	  b[ii] = a[ii] + 1;
+	else
+	  b[ii] = a[ii];
+      }
+  }
+
+#pragma acc kernels copyin(a[0:N]) copyout(b[0:N])
+  {
+    int ii;
+
+    for (ii = 0; ii < N; ii++)
+      {
+	if (acc_on_device (acc_device_host))
+	  b[ii] = a[ii] + 2;
+	else
+	  b[ii] = a[ii];
+      }
+  }
+}
-- 
1.9.1