This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp4, committed] Add goacc/kernels-acc-on-device.c
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: "gcc-patches at gnu dot org" <gcc-patches at gnu dot org>
- Date: Sat, 10 Oct 2015 12:49:01 +0200
- Subject: [gomp4, committed] Add goacc/kernels-acc-on-device.c
- Authentication-results: sourceware.org; auth=none
Hi,
this patch adds a new kernels region test-case.
Committed to gomp-4_0-branch as trivial.
Thanks,
- Tom
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