diff mbox

OpenACC middle end changes

Message ID 546CF508.9010807@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt Nov. 19, 2014, 7:52 p.m. UTC
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.

                   RESULT_DECL, NULL_TREE, void_type_node);

Comments

Jakub Jelinek Nov. 19, 2014, 9:59 p.m. UTC | #1
On Wed, Nov 19, 2014 at 08:52:40PM +0100, Bernd Schmidt wrote:
> 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).

I think Richard's and Honza's preference in this case is a flag in
cgraph_node instead of an attribute.

> 	* 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);

	Jakub
Jakub Jelinek Feb. 20, 2015, 9:47 a.m. UTC | #2
On Wed, Nov 19, 2014 at 08:52:40PM +0100, Bernd Schmidt wrote:
> 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).

On a second though, I guess this is ok.  Adding a cgraph bit that is
interesting to just a single target and is quite rare is probably waste,
especially when it would need to be streamed in and out in every cgraph
node.
As nvptx backend already recognizes it and we have "omp declare target"
attribute already, this is ok for trunk.

> 	* 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);

	Jakub
Thomas Schwinge Feb. 20, 2015, 10:01 a.m. UTC | #3
Hi!

On Fri, 20 Feb 2015 10:47:13 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Nov 19, 2014 at 08:52:40PM +0100, Bernd Schmidt wrote:
> > 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).
> 
> On a second though, I guess this is ok.  Adding a cgraph bit that is
> interesting to just a single target and is quite rare is probably waste,
> especially when it would need to be streamed in and out in every cgraph
> node.

Heh, that's precisely the question I had just drafted in an email, just
about to send, when your email arrived.  ;-)

> As nvptx backend already recognizes it and we have "omp declare target"
> attribute already, this is ok for trunk.

Bernd, are you going to commit this, and the other approved changes of
yours?

> > 	* 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);


Grüße,
 Thomas
diff mbox

Patch

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),