From patchwork Wed Apr 2 08:33:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 336279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5A0401400F2 for ; Wed, 2 Apr 2014 19:34:20 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=F+Ggk6G9clKR1iOz rp1mCylgxkfej6ZQe507Z1QVPDtoS83/YnyFxo/2h4YdX2M4u8Qk8E5/yIGzGe3P bck6ZG+Oz/sxwZ49ssNyVzpcrpRSjnrAgtJXtqV+cLVJUxTdPGtYaRZZ/EUB7cJ8 Yuh3+V6fEft3Z0W46duaOIdChyU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=DY4uNyFl59SO3DbUP2Yt4A IuWJI=; b=a31fweZA4oQvPEwHI33jMPJKuS4XV/Y3S+EkyhUC4iph6Dd1V31G8g FD5F+3xT4/Uw7yN+XSfqSfEnXOUjGLa9VwHGo26CWnPjyH87RSWi4+MPI6nk/s1w Fu7Rdod0XOjxcuVhew5SMXY8LtrNN/W1+KTt8yztdQgEkDeMwgBKw= Received: (qmail 14046 invoked by alias); 2 Apr 2014 08:34:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 14033 invoked by uid 89); 2 Apr 2014 08:34:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Apr 2014 08:34:10 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WVGcZ-0002Ye-8L from Thomas_Schwinge@mentor.com ; Wed, 02 Apr 2014 01:34:07 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 2 Apr 2014 01:34:07 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 2 Apr 2014 09:34:04 +0100 From: Thomas Schwinge To: Bernd Schmidt CC: Ilya Verbin , Michael Zolotukhin , GCC Patches Subject: Re: [gomp4] Add tables generation In-Reply-To: <532B1C45.9020308@codesourcery.com> References: <532B1C45.9020308@codesourcery.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Wed, 2 Apr 2014 10:33:58 +0200 Message-ID: <87ob0ki0zt.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Thu, 20 Mar 2014 17:50:13 +0100, Bernd Schmidt wrote: > This is based on Michael Zolotukhin's patch 2/3 from a while ago. It > adds functionality to build function/variable tables that will allow > libgomp to look up offload target code based on the address of the > corresponding host function. There are two alternatives, one based on > named sections, and one based on a target hook when named sections are > unavailable (as on ptx). > > Committed on gomp-4_0-branch. > --- gcc/omp-low.c (revision 208706) > +++ gcc/omp-low.c (working copy) > @@ -8671,19 +8672,22 @@ expand_omp_target (struct omp_region *re > } > > gimple g; > - /* FIXME: This will be address of > - extern char __OPENMP_TARGET__[] __attribute__((visibility ("hidden"))) > - symbol, as soon as the linker plugin is able to create it for us. */ > - tree openmp_target = build_zero_cst (ptr_type_node); > + tree openmp_target > + = build_decl (UNKNOWN_LOCATION, VAR_DECL, > + get_identifier ("__OPENMP_TARGET__"), ptr_type_node); > + TREE_PUBLIC (openmp_target) = 1; > + DECL_EXTERNAL (openmp_target) = 1; > if (kind == GF_OMP_TARGET_KIND_REGION) > { > tree fnaddr = build_fold_addr_expr (child_fn); > - g = gimple_build_call (builtin_decl_explicit (start_ix), 7, > - device, fnaddr, openmp_target, t1, t2, t3, t4); > + g = gimple_build_call (builtin_decl_explicit (start_ix), 7, device, > + fnaddr, build_fold_addr_expr (openmp_target), > + t1, t2, t3, t4); > } > else > - g = gimple_build_call (builtin_decl_explicit (start_ix), 6, > - device, openmp_target, t1, t2, t3, t4); > + g = gimple_build_call (builtin_decl_explicit (start_ix), 6, device, > + build_fold_addr_expr (openmp_target), > + t1, t2, t3, t4); Committed in r209013: commit 1f54e08135bd8be59438977b4edbc102e7cef2d7 Author: tschwinge Date: Wed Apr 2 08:28:54 2014 +0000 Handle __OPENMP_TARGET__ symbol for OpenACC offloading functions, too. gcc/ * omp-low.c (expand_oacc_offload): Handle __OPENMP_TARGET__ symbol. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@209013 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 5 +++++ gcc/omp-low.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) Grüße, Thomas diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index 1d35b58..8983632 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,3 +1,8 @@ +2014-04-02 Thomas Schwinge + + * omp-low.c (expand_oacc_offload): Handle __OPENMP_TARGET__ + symbol. + 2014-03-20 Thomas Schwinge * gimple.h (enum gf_mask): Add GF_OMP_FOR_KIND_OACC_LOOP. diff --git gcc/omp-low.c gcc/omp-low.c index a7b93bc..01eda9d 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -5138,13 +5138,15 @@ expand_oacc_offload (struct omp_region *region) } gimple g; - /* FIXME: This will be address of - extern char __OPENMP_TARGET__[] __attribute__((visibility ("hidden"))) - symbol, as soon as the linker plugin is able to create it for us. */ - tree openmp_target = build_zero_cst (ptr_type_node); + tree openmp_target + = build_decl (UNKNOWN_LOCATION, VAR_DECL, + get_identifier ("__OPENMP_TARGET__"), ptr_type_node); + TREE_PUBLIC (openmp_target) = 1; + DECL_EXTERNAL (openmp_target) = 1; tree fnaddr = build_fold_addr_expr (child_fn); - g = gimple_build_call (builtin_decl_explicit (start_ix), - 10, device, fnaddr, openmp_target, t1, t2, t3, t4, + g = gimple_build_call (builtin_decl_explicit (start_ix), 10, device, + fnaddr, build_fold_addr_expr (openmp_target), + t1, t2, t3, t4, t_num_gangs, t_num_workers, t_vector_length); gimple_set_location (g, gimple_location (entry_stmt)); gsi_insert_before (&gsi, g, GSI_SAME_STMT); > +/* Create new symbol containing (address, size) pairs for omp-marked > + functions and global variables. */ > +void > +omp_finish_file (void) > +{ > + struct cgraph_node *node; > + struct varpool_node *vnode; > + const char *funcs_section_name = ".offload_func_table_section"; > + const char *vars_section_name = ".offload_var_table_section"; > + vec *v_funcs, *v_vars; > + > + vec_alloc (v_vars, 0); > + vec_alloc (v_funcs, 0); > + > + [...] > + unsigned num_vars = vec_safe_length (v_vars); > + unsigned num_funcs = vec_safe_length (v_funcs); > + [...] > + if (targetm_common.have_named_sections) > + { > + [...] > + } > + else > + { > + for (unsigned i = 0; i < num_funcs; i++) > + { > + tree it = (*v_funcs)[i]; > + targetm.record_offload_symbol (it); > + } > + for (unsigned i = 0; i < num_funcs; i++) > + { > + tree it = (*v_vars)[i]; > + targetm.record_offload_symbol (it); > + } > + } > +} Committed in r209014: commit abae7b762c0b9787dd21e863561af44472096eb3 Author: tschwinge Date: Wed Apr 2 08:29:07 2014 +0000 Fix typo/copy'n'pasto. gcc/ * omp-low.c (omp_finish_file): Use num_vars instead of num_funcs when recording offload symbols v_vars. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@209014 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 3 +++ gcc/omp-low.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index 8983632..64e0c35 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,5 +1,8 @@ 2014-04-02 Thomas Schwinge + * omp-low.c (omp_finish_file): Use num_vars instead of num_funcs + when recording offload symbols v_vars. + * omp-low.c (expand_oacc_offload): Handle __OPENMP_TARGET__ symbol. diff --git gcc/omp-low.c gcc/omp-low.c index 01eda9d..6c803a8 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -12934,7 +12934,7 @@ omp_finish_file (void) tree it = (*v_funcs)[i]; targetm.record_offload_symbol (it); } - for (unsigned i = 0; i < num_funcs; i++) + for (unsigned i = 0; i < num_vars; i++) { tree it = (*v_vars)[i]; targetm.record_offload_symbol (it);