aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2023-06-10 22:17:29 +0000
committerSandra Loosemore <sandra@codesourcery.com>2023-06-14 21:32:15 +0000
commitbf38eb98eafe12613ae5434e4a78bd34946809ff (patch)
treef0097430dd90ffd2213fb83a1ab31fcba927a0f4 /gcc
parent546b34603465bb14d3d49861e8089bed11e9f57a (diff)
downloadgcc-bf38eb98eafe12613ae5434e4a78bd34946809ff.zip
gcc-bf38eb98eafe12613ae5434e4a78bd34946809ff.tar.gz
gcc-bf38eb98eafe12613ae5434e4a78bd34946809ff.tar.bz2
OpenMP: New c/c++ testcases for imperfectly-nested loops
gcc/testsuite/ChangeLog * c-c++-common/gomp/imperfect1.c: New. * c-c++-common/gomp/imperfect2.c: New. * c-c++-common/gomp/imperfect3.c: New. * c-c++-common/gomp/imperfect4.c: New. * c-c++-common/gomp/imperfect5.c: New. libgomp/ChangeLog * testsuite/libgomp.c-c++-common/imperfect-transform-1.c: New. * testsuite/libgomp.c-c++-common/imperfect-transform-2.c: New. * testsuite/libgomp.c-c++-common/imperfect1.c: New. * testsuite/libgomp.c-c++-common/imperfect2.c: New. * testsuite/libgomp.c-c++-common/imperfect3.c: New. * testsuite/libgomp.c-c++-common/imperfect4.c: New. * testsuite/libgomp.c-c++-common/imperfect5.c: New. * testsuite/libgomp.c-c++-common/imperfect6.c: New. * testsuite/libgomp.c-c++-common/target-imperfect-transform-1.c: New. * testsuite/libgomp.c-c++-common/target-imperfect-transform-2.c: New. * testsuite/libgomp.c-c++-common/target-imperfect1.c: New. * testsuite/libgomp.c-c++-common/target-imperfect2.c: New. * testsuite/libgomp.c-c++-common/target-imperfect3.c: New. * testsuite/libgomp.c-c++-common/target-imperfect4.c: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog.omp8
-rw-r--r--gcc/testsuite/c-c++-common/gomp/imperfect1.c38
-rw-r--r--gcc/testsuite/c-c++-common/gomp/imperfect2.c34
-rw-r--r--gcc/testsuite/c-c++-common/gomp/imperfect3.c33
-rw-r--r--gcc/testsuite/c-c++-common/gomp/imperfect4.c33
-rw-r--r--gcc/testsuite/c-c++-common/gomp/imperfect5.c57
6 files changed, 203 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index d428136..72d7b52 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,5 +1,13 @@
2023-06-13 Sandra Loosemore <sandra@codesourcery.com>
+ * c-c++-common/gomp/imperfect1.c: New.
+ * c-c++-common/gomp/imperfect2.c: New.
+ * c-c++-common/gomp/imperfect3.c: New.
+ * c-c++-common/gomp/imperfect4.c: New.
+ * c-c++-common/gomp/imperfect5.c: New.
+
+2023-06-13 Sandra Loosemore <sandra@codesourcery.com>
+
* c-c++-common/goacc/tile-2.c: Adjust expected error patterns.
* c-c++-common/gomp/loop-transforms/imperfect-loop-nest: Likewise.
* c-c++-common/gomp/loop-transforms/tile-1.c: Likewise.
diff --git a/gcc/testsuite/c-c++-common/gomp/imperfect1.c b/gcc/testsuite/c-c++-common/gomp/imperfect1.c
new file mode 100644
index 0000000..705626a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/imperfect1.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+
+/* This test case is expected to fail due to errors. */
+
+int f1 (int depth, int iter);
+int f2 (int depth, int iter);
+
+void s1 (int a1, int a2, int a3)
+{
+ int i, j, k;
+
+#pragma omp for collapse(3)
+ for (i = 0; i < a1; i++)
+ {
+ f1 (0, i);
+ for (j = 0; j < a2; j++)
+ {
+#pragma omp barrier /* { dg-error "intervening code must not contain OpenMP directives" } */
+ f1 (1, j);
+ if (i == 2)
+ continue; /* { dg-error "invalid exit" } */
+ else
+ break; /* { dg-error "invalid exit" } */
+ for (k = 0; k < a3; k++)
+ {
+ f1 (2, k);
+ f2 (2, k);
+ }
+ f2 (1, j);
+ }
+ for (k = 0; k < a3; k++) /* { dg-error "loop not permitted in intervening code " } */
+ {
+ f1 (2, k);
+ f2 (2, k);
+ }
+ f2 (0, i);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/imperfect2.c b/gcc/testsuite/c-c++-common/gomp/imperfect2.c
new file mode 100644
index 0000000..dff17dd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/imperfect2.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+
+/* This test case is expected to fail due to errors. */
+
+/* These functions that are part of the OpenMP runtime API would ordinarily
+ be declared in omp.h, but we don't have that here. */
+extern int omp_get_num_threads(void);
+extern int omp_get_max_threads(void);
+
+int f1 (int depth, int iter);
+int f2 (int depth, int iter);
+
+void s1 (int a1, int a2, int a3)
+{
+ int i, j, k;
+#pragma omp for collapse(3)
+ for (i = 0; i < a1; i++)
+ {
+ f1 (0, i);
+ for (j = 0; j < omp_get_num_threads (); j++) /* This is OK */
+ {
+ f1 (1, omp_get_num_threads ()); /* { dg-error "not permitted in intervening code" } */
+ for (k = omp_get_num_threads (); k < a3; k++) /* This is OK */
+ {
+ f1 (2, omp_get_num_threads ());
+ f2 (2, omp_get_max_threads ());
+ }
+ f2 (1, omp_get_max_threads ()); /* { dg-error "not permitted in intervening code" } */
+ }
+ f2 (0, i);
+ }
+}
+
+
diff --git a/gcc/testsuite/c-c++-common/gomp/imperfect3.c b/gcc/testsuite/c-c++-common/gomp/imperfect3.c
new file mode 100644
index 0000000..ad727ed
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/imperfect3.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+
+/* This test case is expected to fail due to errors. */
+
+/* Test that the imperfectly-nested loops with the ordered clause gives
+ an error, and that there is only one error (and not one on every
+ intervening statement). */
+
+int f1 (int depth, int iter);
+int f2 (int depth, int iter);
+
+void s1 (int a1, int a2, int a3)
+{
+ int i, j, k;
+
+#pragma omp for ordered(3)
+ for (i = 0; i < a1; i++) /* { dg-error "inner loops must be perfectly nested" } */
+ {
+ f1 (0, i);
+ for (j = 0; j < a2; j++)
+ {
+ f1 (1, j);
+ for (k = 0; k < a3; k++)
+ {
+ f1 (2, k);
+ f2 (2, k);
+ }
+ f2 (1, j);
+ }
+ f2 (0, i);
+ }
+}
+
diff --git a/gcc/testsuite/c-c++-common/gomp/imperfect4.c b/gcc/testsuite/c-c++-common/gomp/imperfect4.c
new file mode 100644
index 0000000..1a0c07c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/imperfect4.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+
+/* This test case is expected to fail due to errors. */
+
+int f1 (int depth, int iter);
+int f2 (int depth, int iter);
+
+void s1 (int a1, int a2, int a3)
+{
+ int i, j, k;
+
+#pragma omp for collapse(4)
+ for (i = 0; i < a1; i++) /* { dg-error "not enough nested loops" } */
+ {
+ f1 (0, i);
+ for (j = 0; j < a2; j++)
+ {
+ f1 (1, j);
+ for (k = 0; k < a3; k++)
+ {
+ /* According to the grammar, this is intervening code; we
+ don't know that we are also missing a nested for loop
+ until we have parsed this whole compound expression. */
+#pragma omp barrier /* { dg-error "intervening code must not contain OpenMP directives" } */
+ f1 (2, k);
+ f2 (2, k);
+ }
+ f2 (1, j);
+ }
+ f2 (0, i);
+ }
+}
+
diff --git a/gcc/testsuite/c-c++-common/gomp/imperfect5.c b/gcc/testsuite/c-c++-common/gomp/imperfect5.c
new file mode 100644
index 0000000..585d89f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/imperfect5.c
@@ -0,0 +1,57 @@
+/* { dg-do compile } */
+
+/* This test case is expected to fail due to errors. */
+
+int f1 (int depth, int iter);
+int f2 (int depth, int iter);
+int ijk (int x, int y, int z);
+void f3 (int sum);
+
+/* This function isn't particularly meaningful, but it should compile without
+ error. */
+int s1 (int a1, int a2, int a3)
+{
+ int i, j, k;
+ int r = 0;
+
+#pragma omp simd collapse(3) reduction (inscan, +:r)
+ for (i = 0; i < a1; i++)
+ {
+ for (j = 0; j < a2; j++)
+ {
+ for (k = 0; k < a3; k++)
+ {
+ r = r + ijk (i, j, k);
+#pragma omp scan exclusive (r)
+ f3 (r);
+ }
+ }
+ }
+ return r;
+}
+
+/* Adding intervening code should trigger an error. */
+int s2 (int a1, int a2, int a3)
+{
+ int i, j, k;
+ int r = 0;
+
+#pragma omp simd collapse(3) reduction (inscan, +:r)
+ for (i = 0; i < a1; i++) /* { dg-error "inner loops must be perfectly nested" } */
+ {
+ f1 (0, i);
+ for (j = 0; j < a2; j++)
+ {
+ f1 (1, j);
+ for (k = 0; k < a3; k++)
+ {
+ r = r + ijk (i, j, k);
+#pragma omp scan exclusive (r)
+ f3 (r);
+ }
+ f2 (1, j);
+ }
+ f2 (0, i);
+ }
+ return r;
+}