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: [OpenACC] declare directive


On 11/06/2015 02:28 PM, Jakub Jelinek wrote:
On Fri, Nov 06, 2015 at 02:18:11PM -0600, James Norris wrote:
On 11/06/2015 01:22 PM, Jakub Jelinek wrote:
On Fri, Nov 06, 2015 at 08:03:52PM +0100, Jakub Jelinek wrote:
What exactly do you want to achieve?  Why do you record it
in gimplify_omp_ctx, but then only look at it in gimplify_body?
The way you abuse gimplify_omp_ctx for that is just too ugly.
All the gimplification code expects that when you enter some OpenMP/OpenACC
construct, you create new context if it needs one, then process the body
of the construct, then pop it up.  The declare_returns stuff
violates all of this.  Do you want to enqueue all the statements
at the end of the body?  Then just stick it into some gimple_seq
outside of the gimplify_omp_ctx, and process in there.  Or if you
want to process it when leaving some construct, arrange for that.
If the unmap operation is supposed to sit where the corresponding variable
goes out of scope, supposedly you would need to find out in which bind
(gimplify_ctx (not omp!)) the variable is declared and arrange for the
statement to be added as a cleanup of that region.
If you queue everything to the end of function, I'm afraid with e.g.
void foo (void)
{
   {
     char buf[2048];
     #acc declare whatever(buf)
     // ...
   }
   {
     char buf2[2048];
     #acc declare whatever(buf2)
     // ...
   }
}
both vars will be assigned overlapping ranges and you might run into
trouble trying to map buf2 while buf is still mapped.

	Jakub
Good point.
Perhaps what would work is stick the "exit" clauses you need for automatic
vars in the function inside of some pointer map / hash table / whatever,
and then in gimplify_bind_expr in the
   /* Add clobbers for all variables that go out of scope.  */
if if flag_openacc && the pointer_map /hash table has any entries look
up each variable in there and collect the clauses from those vars that go
out of scope, after the loop if any were collected construct the statement
you need prepend it to cleanup (so that it works before restoring VLA memory
and before the clobber stmts).

I like that. Thank you again.


	Jakub

Jim



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