From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13325 invoked by alias); 19 Nov 2015 13:13:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13308 invoked by uid 89); 19 Nov 2015 13:13:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 Nov 2015 13:13:54 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 836F7C0BFBAA; Thu, 19 Nov 2015 13:13:52 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAJDDnjH006725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 19 Nov 2015 08:13:51 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id tAJDDl1x006698; Thu, 19 Nov 2015 14:13:48 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id tAJDDjwW006697; Thu, 19 Nov 2015 14:13:45 +0100 Date: Thu, 19 Nov 2015 13:13:00 -0000 From: Jakub Jelinek To: Julian Brown Cc: James Norris , GCC Patches , "Joseph S. Myers" , Nathan Sidwell Subject: Re: [OpenACC 0/7] host_data construct Message-ID: <20151119131345.GX5675@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <56293476.5020801@codesourcery.com> <562A578E.4080907@codesourcery.com> <20151026183422.GW478@tucnak.redhat.com> <20151102183339.365c3d33@octopus> <20151112111621.657650bc@octopus> <20151118124747.30a2ec5d@octopus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151118124747.30a2ec5d@octopus> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg02331.txt.bz2 On Wed, Nov 18, 2015 at 12:47:47PM +0000, Julian Brown wrote: The FE/gimplifier part is okay, but I really don't like the omp-low.c changes, mostly the *lookup_decl_in_outer_ctx* changes. If I count well, we have right now 27 maybe_lookup_decl_in_outer_ctx callers and 7 lookup_decl_in_outer_ctx callers, you want to change behavior of 1 maybe_lookup_decl_in_outer_ctx and 1 lookup_decl_in_outer_ctx. Why exactly those 2 and not the others? What are the exact rules (what does the standard say about it)? I'd expect that all phases (scan_sharing_clauses, lower_omp* and expand_omp*) should agree on the same behavior, otherwise I can't see how it can work properly. And, if you want to change just a couple of spots, I'd strongly prefer to add new functions with this weirdo behavior, rather than tweaking the original function. > --- a/gcc/omp-low.c > +++ b/gcc/omp-low.c > @@ -390,8 +390,8 @@ scan_omp_op (tree *tp, omp_context *ctx) > } > > static void lower_omp (gimple_seq *, omp_context *); > -static tree lookup_decl_in_outer_ctx (tree, omp_context *); > -static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *); > +static tree lookup_decl_in_outer_ctx (tree, omp_context *, bool = false); > +static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *, bool = false); > > /* Find an OMP clause of type KIND within CLAUSES. */ > > @@ -1935,6 +1935,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > install_var_local (decl, ctx); > break; > > + case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE_USE_DEVICE_PTR: > decl = OMP_CLAUSE_DECL (c); > if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) > @@ -2137,7 +2138,6 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > break; > > case OMP_CLAUSE_DEVICE_RESIDENT: > - case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE__CACHE_: > sorry ("Clause not supported yet"); > break; > @@ -2288,6 +2288,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > case OMP_CLAUSE_SIMD: > case OMP_CLAUSE_NOGROUP: > case OMP_CLAUSE_DEFAULTMAP: > + case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE_USE_DEVICE_PTR: > case OMP_CLAUSE__CILK_FOR_COUNT_: > case OMP_CLAUSE_ASYNC: > @@ -2305,7 +2306,6 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) > break; > > case OMP_CLAUSE_DEVICE_RESIDENT: > - case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE__CACHE_: > sorry ("Clause not supported yet"); > break; > @@ -3608,6 +3608,8 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) > case GF_OMP_TARGET_KIND_OACC_UPDATE: stmt_name = "update"; break; > case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA: > stmt_name = "enter/exit data"; break; > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: stmt_name = "host_data"; > + break; > default: gcc_unreachable (); > } > switch (gimple_omp_target_kind (ctx->stmt)) > @@ -3619,6 +3621,8 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) > case GF_OMP_TARGET_KIND_OACC_KERNELS: > ctx_stmt_name = "kernels"; break; > case GF_OMP_TARGET_KIND_OACC_DATA: ctx_stmt_name = "data"; break; > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: > + ctx_stmt_name = "host_data"; break; > default: gcc_unreachable (); > } > > @@ -3941,13 +3945,22 @@ maybe_lookup_ctx (gimple *stmt) > parallelism happens only rarely. */ > > static tree > -lookup_decl_in_outer_ctx (tree decl, omp_context *ctx) > +lookup_decl_in_outer_ctx (tree decl, omp_context *ctx, > + bool skip_hostdata) > { > tree t; > omp_context *up; > > for (up = ctx->outer, t = NULL; up && t == NULL; up = up->outer) > - t = maybe_lookup_decl (decl, up); > + { > + if (skip_hostdata > + && gimple_code (up->stmt) == GIMPLE_OMP_TARGET > + && gimple_omp_target_kind (up->stmt) > + == GF_OMP_TARGET_KIND_OACC_HOST_DATA) > + continue; > + > + t = maybe_lookup_decl (decl, up); > + } > > gcc_assert (!ctx->is_nested || t || is_global_var (decl)); > > @@ -3959,13 +3972,22 @@ lookup_decl_in_outer_ctx (tree decl, omp_context *ctx) > in outer contexts. */ > > static tree > -maybe_lookup_decl_in_outer_ctx (tree decl, omp_context *ctx) > +maybe_lookup_decl_in_outer_ctx (tree decl, omp_context *ctx, > + bool skip_hostdata) > { > tree t = NULL; > omp_context *up; > > for (up = ctx->outer, t = NULL; up && t == NULL; up = up->outer) > - t = maybe_lookup_decl (decl, up); > + { > + if (skip_hostdata > + && gimple_code (up->stmt) == GIMPLE_OMP_TARGET > + && gimple_omp_target_kind (up->stmt) > + == GF_OMP_TARGET_KIND_OACC_HOST_DATA) > + continue; > + > + t = maybe_lookup_decl (decl, up); > + } > > return t ? t : decl; > } > @@ -12499,6 +12521,7 @@ expand_omp_target (struct omp_region *region) > break; > case GF_OMP_TARGET_KIND_DATA: > case GF_OMP_TARGET_KIND_OACC_DATA: > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: > data_region = true; > break; > default: > @@ -12742,6 +12765,9 @@ expand_omp_target (struct omp_region *region) > case GF_OMP_TARGET_KIND_OACC_DECLARE: > start_ix = BUILT_IN_GOACC_DECLARE; > break; > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: > + start_ix = BUILT_IN_GOACC_HOST_DATA; > + break; > default: > gcc_unreachable (); > } > @@ -12866,6 +12892,7 @@ expand_omp_target (struct omp_region *region) > case BUILT_IN_GOACC_DATA_START: > case BUILT_IN_GOACC_DECLARE: > case BUILT_IN_GOMP_TARGET_DATA: > + case BUILT_IN_GOACC_HOST_DATA: > break; > case BUILT_IN_GOMP_TARGET: > case BUILT_IN_GOMP_TARGET_UPDATE: > @@ -13173,6 +13200,7 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent, > case GF_OMP_TARGET_KIND_OACC_PARALLEL: > case GF_OMP_TARGET_KIND_OACC_KERNELS: > case GF_OMP_TARGET_KIND_OACC_DATA: > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: > break; > case GF_OMP_TARGET_KIND_UPDATE: > case GF_OMP_TARGET_KIND_ENTER_DATA: > @@ -14972,6 +15000,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > break; > case GF_OMP_TARGET_KIND_DATA: > case GF_OMP_TARGET_KIND_OACC_DATA: > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: > data_region = true; > break; > default: > @@ -15079,7 +15108,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > { > if (TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE) > { > - if (is_global_var (maybe_lookup_decl_in_outer_ctx (var, ctx)) > + if (is_global_var (maybe_lookup_decl_in_outer_ctx (var, ctx, > + true)) > && varpool_node::get_create (var)->offloadable) > continue; > > @@ -15178,6 +15208,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > } > break; > > + case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE_USE_DEVICE_PTR: > case OMP_CLAUSE_IS_DEVICE_PTR: > var = OMP_CLAUSE_DECL (c); > @@ -15316,7 +15347,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > talign = DECL_ALIGN_UNIT (ovar); > if (nc) > { > - var = lookup_decl_in_outer_ctx (ovar, ctx); > + var = lookup_decl_in_outer_ctx (ovar, ctx, true); > x = build_sender_ref (ovar, ctx); > > if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP > @@ -15563,12 +15594,14 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > build_int_cstu (tkind_type, tkind)); > break; > > + case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE_USE_DEVICE_PTR: > case OMP_CLAUSE_IS_DEVICE_PTR: > ovar = OMP_CLAUSE_DECL (c); > var = lookup_decl_in_outer_ctx (ovar, ctx); > x = build_sender_ref (ovar, ctx); > - if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR) > + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR > + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE) > tkind = GOMP_MAP_USE_DEVICE_PTR; > else > tkind = GOMP_MAP_FIRSTPRIVATE_INT; > @@ -15771,10 +15804,12 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) > gimple_build_assign (new_var, x)); > } > break; > + case OMP_CLAUSE_USE_DEVICE: > case OMP_CLAUSE_USE_DEVICE_PTR: > case OMP_CLAUSE_IS_DEVICE_PTR: > var = OMP_CLAUSE_DECL (c); > - if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR) > + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR > + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE) > x = build_sender_ref (var, ctx); > else > x = build_receiver_ref (var, false, ctx); > @@ -16761,6 +16796,7 @@ make_gimple_omp_edges (basic_block bb, struct omp_region **region, > case GF_OMP_TARGET_KIND_OACC_PARALLEL: > case GF_OMP_TARGET_KIND_OACC_KERNELS: > case GF_OMP_TARGET_KIND_OACC_DATA: > + case GF_OMP_TARGET_KIND_OACC_HOST_DATA: > break; > case GF_OMP_TARGET_KIND_UPDATE: > case GF_OMP_TARGET_KIND_ENTER_DATA: Jakub