aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/gomp
diff options
context:
space:
mode:
authorTobias Burnus <tburnus@baylibre.com>2024-11-22 16:15:17 +0100
committerTobias Burnus <tburnus@baylibre.com>2024-11-22 16:15:17 +0100
commitf34422e06c38eb1f69c301ad5d8e2114c46a2796 (patch)
treedb9f0f76a6ee9779d3f0456b9cae6bbf36819331 /gcc/testsuite/c-c++-common/gomp
parent8f0c8e577a56891fa104c818834ddafe268722bb (diff)
downloadgcc-f34422e06c38eb1f69c301ad5d8e2114c46a2796.zip
gcc-f34422e06c38eb1f69c301ad5d8e2114c46a2796.tar.gz
gcc-f34422e06c38eb1f69c301ad5d8e2114c46a2796.tar.bz2
OpenMP: Add 'interop' clause to 'dispatch' for C/C++
Will fail with an error if/as no suitable 'append_args' has been specified, given that 'append_args' is not yet implemented. gcc/c-family/ChangeLog: * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_INTEROP. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_interop): New. (c_parser_omp_clause_name, c_parser_omp_all_clauses, c_parser_omp_dispatch_body): Handle 'interop' clause. * c-typeck.cc (c_finish_omp_clauses): Likewise. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_name, cp_parser_omp_all_clauses, cp_parser_omp_dispatch_body): Handle 'interop' clause. * pt.cc (tsubst_omp_clauses): Likewise. * semantics.cc (finish_omp_clauses): Likewise. gcc/ChangeLog: * gimplify.cc (gimplify_call_expr): Add initial support for dispatch's 'interop' clause. (gimplify_scan_omp_clauses): Handle interop clause. * tree-pretty-print.cc (dump_omp_clause): Likewise. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_INTEROP. * tree.cc (omp_clause_num_ops, omp_clause_code_name): Add interop. gcc/testsuite/ChangeLog: * c-c++-common/gomp/dispatch-11.c: New test. * c-c++-common/gomp/dispatch-12.c: New test.
Diffstat (limited to 'gcc/testsuite/c-c++-common/gomp')
-rw-r--r--gcc/testsuite/c-c++-common/gomp/dispatch-11.c84
-rw-r--r--gcc/testsuite/c-c++-common/gomp/dispatch-12.c53
2 files changed, 137 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-11.c b/gcc/testsuite/c-c++-common/gomp/dispatch-11.c
new file mode 100644
index 0000000..7f1d806
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/dispatch-11.c
@@ -0,0 +1,84 @@
+/* { dg-additional-options "-fdump-tree-original" } */
+
+/* The following definitions are in omp_lib, which cannot be included
+ in gcc/testsuite/ */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+ omp_interop_none = 0,
+ __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+
+float repl1();
+#pragma omp declare variant(repl1) match(construct={dispatch})
+float base1();
+
+void repl2(int *, int *);
+#pragma omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y)
+void base2(int *x, int *y);
+
+
+float
+dupl (int *a, int *b)
+{
+ omp_interop_t obj1, obj2;
+ float x;
+
+ #pragma omp dispatch interop ( obj1 ) interop(obj2) /* { dg-error "too many 'interop' clauses" } */
+ x = base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'float repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop ( obj1) nocontext(1) interop (obj2 ) /* { dg-error "too many 'interop' clauses" } */
+ base2 (a, b);
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'base2'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void base2\\(int\\*, int\\*\\)'" "" { target c++ } .-3 } */
+ return x;
+}
+
+
+float
+test (int *a, int *b)
+{
+ omp_interop_t obj1, obj2;
+ float x, y;
+
+ #pragma omp dispatch interop ( obj1 )
+ x = base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'float repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop ( obj1, obj1 ) /* Twice the same - should be fine. */
+ x = base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'float repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch novariants(1) interop(obj2, obj1)
+ y = base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'base1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'float base1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop(obj2, obj1)
+ base2 (a, b);
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl2'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void repl2\\(int\\*, int\\*\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop(obj2) nocontext(1)
+ base2 (a, b);
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'base2'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void base2\\(int\\*, int\\*\\)'" "" { target c++ } .-3 } */
+ return x + y;
+}
+
+/* { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\)\[\\n\\r\]" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\) interop\\(obj1\\)\[\\n\\r\]" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\) interop\\(obj2\\) novariants\\(1\\)\[\\n\\r\]" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\) interop\\(obj2\\)\[\\n\\r\]" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp dispatch nocontext\\(1\\) interop\\(obj2\\)\[\\n\\r\]" 1 "original" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-12.c b/gcc/testsuite/c-c++-common/gomp/dispatch-12.c
new file mode 100644
index 0000000..ea190c7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/dispatch-12.c
@@ -0,0 +1,53 @@
+/* The following definitions are in omp_lib, which cannot be included
+ in gcc/testsuite/ */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+ omp_interop_none = 0,
+ __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+
+void repl1();
+#pragma omp declare variant(repl1) match(construct={dispatch})
+void base1();
+
+void
+test ()
+{
+ const omp_interop_t obj1 = omp_interop_none;
+ omp_interop_t obj2[2];
+ const omp_interop_t *obj3;
+ short x;
+
+ #pragma omp dispatch interop ( obj1, obj2, obj1 ) /* { dg-error "'obj2' must be of 'omp_interop_t'" } */
+ base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop ( obj3 ) /* { dg-error "'obj3' must be of 'omp_interop_t'" } */
+ base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop ( obj1 )
+ base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop ( obj2 ) /* { dg-error "'obj2' must be of 'omp_interop_t'" } */
+ base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void repl1\\(\\)'" "" { target c++ } .-3 } */
+
+ #pragma omp dispatch interop ( x ) /* { dg-error "'x' must be of 'omp_interop_t'" } */
+ base1 ();
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'repl1'" "" { target c } .-2 } */
+ /* { dg-error "number of list items in 'interop' clause exceeds number of 'append_args' items for 'declare variant' candidate 'void repl1\\(\\)'" "" { target c++ } .-3 } */
+}