From patchwork Tue Nov 11 15:03:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 409500 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 952B91400E2 for ; Wed, 12 Nov 2014 02:03:29 +1100 (AEDT) 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=y6AdPrXtFZZctnH3 2+6yLCeBO4359BZXNQEcSXoAFRizEgBc4G4faYL1XEjlEBspRUcLmQodPUoocBqq c6gi4EC3fGnx/sl7JynMn9NpEaf2o9nK/0GgcQ2YaLPmYyGO0ZZxvAJS1eAlnMAn c4WLsHQ7u5XJxzEnZV6+ZgtOScE= 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=CO3Uy4VMXpx34PYQ7hPELx VTIGU=; b=UMGqgkLCuFDZA3634H/GD1+l5T3C2mSXjsA+mO62XavNjxMXnHwaO3 +fHSwfuLtogXmOokqRDj0a3isBZpxgw19BpD2RELjcottvRSZ82nqg2Js2+68z7e 6RvB26HFlwUkADERQDUHY9LRhq9SGzXCrz+iLG9BKTRYYbWnRvy+E= Received: (qmail 22278 invoked by alias); 11 Nov 2014 15:03:20 -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 22263 invoked by uid 89); 11 Nov 2014 15:03:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE 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; Tue, 11 Nov 2014 15:03:15 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XoCyN-00038Z-Sl from Thomas_Schwinge@mentor.com for gcc-patches@gcc.gnu.org; Tue, 11 Nov 2014 07:03:12 -0800 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.3.181.6; Tue, 11 Nov 2014 15:03:10 +0000 From: Thomas Schwinge To: "gcc-patches@gcc.gnu.org" CC: Cesar Philippidis Subject: Re: [patch,gomp-4_0-branch] openacc parallel reduction part 1 In-Reply-To: <53BC0008.70404@mentor.com> References: <53B9D780.4040904@mentor.com> <87zjglsdc8.fsf@schwinge.name> <53BC0008.70404@mentor.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) Date: Tue, 11 Nov 2014 16:03:05 +0100 Message-ID: <87a93xeq52.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Tue, 8 Jul 2014 07:28:24 -0700, Cesar Philippidis wrote: > On 07/07/2014 02:55 AM, Thomas Schwinge wrote: > > > On Sun, 6 Jul 2014 16:10:56 -0700, Cesar Philippidis wrote: > >> This patch is the first step to enabling parallel reductions in openacc. > I've committed this updated version > of the patch. In r217354, I just applied the following cleanup to gomp-4_0-branch: commit 4fe8b3620b258ac904d9eade5f76dede69a80c98 Author: tschwinge Date: Tue Nov 11 14:52:26 2014 +0000 OpenACC reductions maintenance. gcc/ * omp-low.c (maybe_lookup_reduction): Don't require an OpenACC context. (lower_oacc_offload): Simplify use of maybe_lookup_reduction. gcc/ * omp-low.c (delete_omp_context): Dispose of reduction_map. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@217354 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 6 ++++++ gcc/omp-low.c | 56 +++++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 26 deletions(-) Grüße, Thomas diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index dacfad8..94a7f8c 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,5 +1,11 @@ 2014-11-11 Thomas Schwinge + * omp-low.c (delete_omp_context): Dispose of reduction_map. + + * omp-low.c (maybe_lookup_reduction): Don't require an OpenACC + context. + (lower_oacc_offload): Simplify use of maybe_lookup_reduction. + * omp-low.c (lower_omp_target): Restore two gcc_asserts. 2014-11-06 Thomas Schwinge diff --git gcc/omp-low.c gcc/omp-low.c index c63ec4e..5695ec3 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -938,7 +938,7 @@ get_base_type (tree decl) return type; } -/* Lookup variables in the decl or field splay trees. The "maybe" form +/* Lookup variables. The "maybe" form allows for the variable form to not have been entered, otherwise we assert that the variable must have been entered. */ @@ -975,17 +975,6 @@ lookup_sfield (tree var, omp_context *ctx) } static inline tree -lookup_reduction (const char *id, omp_context *ctx) -{ - gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt)); - - splay_tree_node n; - n = splay_tree_lookup (ctx->reduction_map, - (splay_tree_key) id); - return (tree) n->value; -} - -static inline tree maybe_lookup_field (tree var, omp_context *ctx) { splay_tree_node n; @@ -994,14 +983,22 @@ maybe_lookup_field (tree var, omp_context *ctx) } static inline tree +lookup_reduction (const char *id, omp_context *ctx) +{ + gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt)); + + splay_tree_node n; + n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) id); + return (tree) n->value; +} + +static inline tree maybe_lookup_reduction (tree var, omp_context *ctx) { - gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt)); - - splay_tree_node n; - n = splay_tree_lookup (ctx->reduction_map, - (splay_tree_key) var); - return n ?(tree) n->value : NULL_TREE; + splay_tree_node n = NULL; + if (ctx->reduction_map) + n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) var); + return n ? (tree) n->value : NULL_TREE; } /* Return true if DECL should be copied by pointer. SHARED_CTX is @@ -1574,6 +1571,11 @@ delete_omp_context (splay_tree_value value) splay_tree_delete (ctx->field_map); if (ctx->sfield_map) splay_tree_delete (ctx->sfield_map); + if (ctx->reduction_map + /* Shared over several omp_contexts. */ + && (ctx->outer == NULL + || ctx->reduction_map != ctx->outer->reduction_map)) + splay_tree_delete (ctx->reduction_map); /* We hijacked DECL_ABSTRACT_ORIGIN earlier. We need to clear it before it produces corrupt debug information. */ @@ -10481,10 +10483,14 @@ lower_oacc_offload (gimple_stmt_iterator *gsi_p, omp_context *ctx) || (OMP_CLAUSE_MAP_KIND (c) != OMP_CLAUSE_MAP_FORCE_DEVICEPTR) || TREE_CODE (TREE_TYPE (ovar)) != ARRAY_TYPE); - if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP - && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER - && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c) - && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE) + if (maybe_lookup_reduction (var, ctx)) + { + gimplify_assign (x, var, &ilist); + } + else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP + && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER + && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c) + && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE) { tree avar = create_tmp_var (TREE_TYPE (TREE_TYPE (x)), NULL); @@ -10494,8 +10500,7 @@ lower_oacc_offload (gimple_stmt_iterator *gsi_p, omp_context *ctx) avar = build_fold_addr_expr (avar); gimplify_assign (x, avar, &ilist); } - else if (is_gimple_reg (var) - && !maybe_lookup_reduction (var, ctx)) + else if (is_gimple_reg (var)) { tree avar = create_tmp_var (TREE_TYPE (var), NULL); mark_addressable (avar); @@ -10521,8 +10526,7 @@ lower_oacc_offload (gimple_stmt_iterator *gsi_p, omp_context *ctx) } else { - if (!maybe_lookup_reduction (var, ctx)) - var = build_fold_addr_expr (var); + var = build_fold_addr_expr (var); gimplify_assign (x, var, &ilist); } }