This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "omp declare target" on DECL_EXTERNAL vars


On Mon, May 23, 2016 at 05:37:17PM +0300, Alexander Monakov wrote:
> Hello,
> 
> On Fri, 20 May 2016, Jakub Jelinek wrote:
> [snip]
> > The reason I needed the above is that both gimplify.c and omp-low.c
> > test just the node->offloadable flag, bit the attribute, and so when
> > it is external and the flag wasn't set, we could privatize the vars
> > even when we were supposed to map them etc.
> > In the C/C++ FEs, we set not just node->offloadable, but also
> > for ENABLE_OFFLOADING g->have_offload and offload_vars too.
> > Wonder if that means we register even non-local vars, that would be IMHO a
> > bug.  On the other side, we need to watch for an extern declaration
> > of a VAR_DECL marked for offloading and only later on locally defined,
> > in that case if we haven't set g->have_offload and added entry to
> > offload_vars, we'd need to do it when merging the extern decl with the
> > definition.
> > 
> > So, your thoughts on that?
> 
> As I'm relatively late to this game, at times like this it's hard for me to
> follow what's the general model is. It appears that 'omp declare target' is
> superfluous given symtab_node::offloadable. Offloading compilation still needs
> to distinguish target region entry points from the rest of the functions
> (hence 'omp target entrypoint' serves a clear purpose), but does plain 'omp
> declare target' have a particular meaning not conveyed by
> symtab_node::offloadable && !'omp target entrypoint'?

"omp declare target" and "omp declare target link" attributes are FE
representation, symtab_node::offloadable is ME representation.
We have just one bit in the latter right now, so e.g. it does not
differentiate between the two kinds of offloadable vars.  In the C/C++ FE,
we set the offloadable bit right away next to the creation of the attribute,
in the Fortran FE we don't (and not sure if it is even safe to create symtab
node at that point yet).

> Is/should be there an invariant like "when omp-low is completed, all decls
> annotated with 'omp declare target' will also have symtab_node::offloadable
> set"?

Without my patch to gomp4.5 branch, that invariant didn't hold for Fortran
DECL_EXTERNAL vars.  With the patch it holds, but we need to come to
agreement what behavior we do want for DECL_EXTERNAL vars.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]