Handle sequential code in kernels region - Testcases
2015-10-12 Tom de Vries <tom@codesourcery.com>
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-2.c: New test.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-3.c: New test.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-4.c: New test.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-5.c: New test.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-6.c: New test.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq.c: New test.
---
.../kernels-loop-and-seq-2.c | 36 +++++++++++++++++++++
.../kernels-loop-and-seq-3.c | 37 ++++++++++++++++++++++
.../kernels-loop-and-seq-4.c | 36 +++++++++++++++++++++
.../kernels-loop-and-seq-5.c | 37 ++++++++++++++++++++++
.../kernels-loop-and-seq-6.c | 36 +++++++++++++++++++++
.../kernels-loop-and-seq.c | 37 ++++++++++++++++++++++
6 files changed, 219 insertions(+)
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-2.c
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-3.c
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-4.c
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-5.c
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-6.c
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq.c
new file mode 100644
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+
+#include <stdlib.h>
+
+#define N 32
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+#pragma acc kernels copy (a[0:N])
+ {
+ a[0] = a[0] + 1;
+
+ for (int i = 0; i < n; i++)
+ a[i] = 1;
+ }
+
+ return a[0];
+}
+
+int
+main (void)
+{
+ unsigned int a[N];
+ unsigned res, i;
+
+ for (i = 0; i < N; ++i)
+ a[i] = i % 4;
+
+ res = foo (N, a);
+ if (res != 1)
+ abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+
+#include <stdlib.h>
+
+#define N 32
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+
+#pragma acc kernels copy (a[0:N])
+ {
+ for (int i = 0; i < n; i++)
+ a[i] = 1;
+
+ a[0] = 2;
+ }
+
+ return a[0];
+}
+
+int
+main (void)
+{
+ unsigned int a[N];
+ unsigned res, i;
+
+ for (i = 0; i < N; ++i)
+ a[i] = i % 4;
+
+ res = foo (N, a);
+ if (res != 2)
+ abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+
+#include <stdlib.h>
+
+#define N 32
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+#pragma acc kernels copy (a[0:N])
+ {
+ a[0] = 2;
+
+ for (int i = 0; i < n; i++)
+ a[i] = 1;
+ }
+
+ return a[0];
+}
+
+int
+main (void)
+{
+ unsigned int a[N];
+ unsigned res, i;
+
+ for (i = 0; i < N; ++i)
+ a[i] = i % 4;
+
+ res = foo (N, a);
+ if (res != 1)
+ abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+
+#include <stdlib.h>
+
+#define N 32
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+ int r;
+#pragma acc kernels copyout(r) copy (a[0:N])
+ {
+ r = a[0];
+
+ for (int i = 0; i < n; i++)
+ a[i] = 1;
+ }
+
+ return r;
+}
+
+int
+main (void)
+{
+ unsigned int a[N];
+ unsigned res, i;
+
+ for (i = 0; i < N; ++i)
+ a[i] = i % 4;
+
+ res = foo (N, a);
+ if (res != 0)
+ abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+
+#include <stdlib.h>
+
+#define N 32
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+#pragma acc kernels copy (a[0:N])
+ {
+ int r = a[0];
+
+ for (int i = 0; i < n; i++)
+ a[i] = 1 + r;
+ }
+
+ return a[0];
+}
+
+int
+main (void)
+{
+ unsigned int a[N];
+ unsigned res, i;
+
+ for (i = 0; i < N; ++i)
+ a[i] = i % 4;
+
+ res = foo (N, a);
+ if (res != 1)
+ abort ();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+
+#include <stdlib.h>
+
+#define N 32
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+
+#pragma acc kernels copy (a[0:N])
+ {
+ for (int i = 0; i < n; i++)
+ a[i] = 1;
+
+ a[0] = a[0] + 1;
+ }
+
+ return a[0];
+}
+
+int
+main (void)
+{
+ unsigned int a[N];
+ unsigned res, i;
+
+ for (i = 0; i < N; ++i)
+ a[i] = i % 4;
+
+ res = foo (N, a);
+ if (res != 2)
+ abort ();
+
+ return 0;
+}
--
1.9.1