Another change that's required is (something like) the following. For ptx, we need to know whether to output something as a .func (callable from ptx code) or a .kernel (callable from the host). That means we need to mark the kernel functions somehow in omp-low.c, and the following does that by way of a new attribute (already recognized by the nvptx backend).

Bernd

        * omp-low.c (create_omp_child_function): Tag entrypoint
        functions with a special attribute.

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 42ba317..8408025 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2228,6 +2228,12 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
            break;
          }
     }
+  if (cgraph_node::get_create (decl)->offloadable
+      && !lookup_attribute ("omp declare target",
+                           DECL_ATTRIBUTES (current_function_decl)))
+    DECL_ATTRIBUTES (decl)
+      = tree_cons (get_identifier ("omp target entrypoint"),
+                   NULL_TREE, DECL_ATTRIBUTES (decl));

   t = build_decl (DECL_SOURCE_LOCATION (decl),
                  RESULT_DECL, NULL_TREE, void_type_node);

Reply via email to