From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63323 invoked by alias); 6 Apr 2016 14:23:49 -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 63304 invoked by uid 89); 6 Apr 2016 14:23:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Wed, 06 Apr 2016 14:23:48 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA92C7F356; Wed, 6 Apr 2016 14:23:46 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-22.phx2.redhat.com [10.3.113.22]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u36ENjin024307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 6 Apr 2016 10:23:46 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u36ENgZj001170; Wed, 6 Apr 2016 16:23:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u36ENeER001169; Wed, 6 Apr 2016 16:23:40 +0200 Date: Wed, 06 Apr 2016 14:23:00 -0000 From: Jakub Jelinek To: Cesar Philippidis Cc: "gcc-patches@gcc.gnu.org" , Nathan Sidwell Subject: Re: openacc reference reductions Message-ID: <20160406142340.GZ19207@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <56BA0257.6050607@codesourcery.com> <56BA06C3.90606@acm.org> <56BA10FC.90705@codesourcery.com> <56CB2A76.3090809@codesourcery.com> <57046C2B.6080002@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57046C2B.6080002@codesourcery.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00298.txt.bz2 On Tue, Apr 05, 2016 at 06:53:47PM -0700, Cesar Philippidis wrote: > --- a/gcc/omp-low.c > +++ b/gcc/omp-low.c > @@ -309,6 +309,25 @@ is_oacc_kernels (omp_context *ctx) > == GF_OMP_TARGET_KIND_OACC_KERNELS)); > } > > +/* Return true if CTX corresponds to an oacc parallel region and if > + VAR is used in a reduction. */ > + > +static bool > +is_oacc_parallel_reduction (tree var, omp_context *ctx) > +{ > + if (!is_oacc_parallel (ctx)) > + return false; > + > + tree clauses = gimple_omp_target_clauses (ctx->stmt); > + > + for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) > + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION > + && OMP_CLAUSE_DECL (c) == var) > + return true; > + > + return false; > +} > + > /* If DECL is the artificial dummy VAR_DECL created for non-static > data member privatization, return the underlying "this" parameter, > otherwise return NULL. */ > @@ -2122,7 +2141,8 @@ scan_sharing_clauses (tree clauses, omp_context *ctx, > else > install_var_field (decl, true, 3, ctx, > base_pointers_restrict); > - if (is_gimple_omp_offloaded (ctx->stmt)) > + if (is_gimple_omp_offloaded (ctx->stmt) > + && !is_oacc_parallel_reduction (decl, ctx)) > install_var_local (decl, ctx); > } > } The above is O(n^2) in number of clauses on the construct. Perhaps better define some OMP_CLAUSE_MAP_IN_REDUCTION macro (e.g. TREE_PRIVATE bit is unused on OMP_CLAUSE_MAP right now), make sure to set it e.g. during gimplification where you can see all GOVD_* flags for a particular decl), and then use this flag here? Jakub