aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-10-28 10:34:29 +0100
committerJakub Jelinek <jakub@redhat.com>2020-10-28 10:36:31 +0100
commit2298ca2d3e133945f5034065e843e2ea0f36e0bb (patch)
treedf6cf359ee3a11e786641b73d6f51872410ee4d4 /libgomp
parent3f39b64e57ab8e8f69a017e4bd20aa6dd2aec492 (diff)
downloadgcc-2298ca2d3e133945f5034065e843e2ea0f36e0bb.zip
gcc-2298ca2d3e133945f5034065e843e2ea0f36e0bb.tar.gz
gcc-2298ca2d3e133945f5034065e843e2ea0f36e0bb.tar.bz2
openmp: Implicitly discover declare target for variants of declare variant calls
This marks all variants of declare variant also declare target if the base functions are called directly in target regions or declare target functions. 2020-10-28 Jakub Jelinek <jakub@redhat.com> gcc/ * omp-offload.c (omp_declare_target_tgt_fn_r): Handle direct calls to declare variant base functions. libgomp/ * testsuite/libgomp.c/target-42.c: New test.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/testsuite/libgomp.c/target-42.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/target-42.c b/libgomp/testsuite/libgomp.c/target-42.c
new file mode 100644
index 0000000..fc0e265
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/target-42.c
@@ -0,0 +1,42 @@
+#include <stdio.h>
+
+int
+on_nvptx (void)
+{
+ return 1;
+}
+
+int
+on_gcn (void)
+{
+ return 2;
+}
+
+#pragma omp declare variant (on_nvptx) match(construct={target},device={arch(nvptx)})
+#pragma omp declare variant (on_gcn) match(construct={target},device={arch(gcn)})
+int
+on (void)
+{
+ return 0;
+}
+
+int
+main ()
+{
+ int v;
+ #pragma omp target map(from:v)
+ v = on ();
+ switch (v)
+ {
+ default:
+ printf ("Host fallback or unknown offloading\n");
+ break;
+ case 1:
+ printf ("Offloading to NVidia PTX\n");
+ break;
+ case 2:
+ printf ("Offloading to AMD GCN\n");
+ break;
+ }
+ return 0;
+}