From patchwork Fri Feb 21 19:48:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 323007 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 D303F2C0323 for ; Sat, 22 Feb 2014 06:48:38 +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=vnoKDQMXzXQ89Ml+ K+FnYwkkitnQP+f4TXqiGJ0v3JvW3y12j+I4Zs8Gc/qqJ0BBNg3ppCVvAdMgBAzN zVw/1JzZHxfg/6BAaa0LenYlFYRMCVYPoQxoWsboJol/dn06GniFIFpqXrsxjhwh U2VbcmZ2bOBwEG0kqwVicdhoD/4= 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=bC/EjcUbl5g0DetUq6LmpC Z+urg=; b=JUJnSCU2ViSq+y8Dqt5608oevrDk6hKzkv666213UKcqzupRtRMqte U0okPVGKxxqtaeR07vTaEcICX/nM905N5AMr59LA9hzAky/f1tfAb74E4vnnvLH2 k8Hdqiw7/xZgdok1O3Bdt9LgnsbBTkHYUq77HDA8C0ZI58H8Ue0sU= Received: (qmail 23338 invoked by alias); 21 Feb 2014 19:48:31 -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 23324 invoked by uid 89); 21 Feb 2014 19:48:31 -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; Fri, 21 Feb 2014 19:48:29 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WGw5A-0004zZ-Rw from Thomas_Schwinge@mentor.com ; Fri, 21 Feb 2014 11:48:24 -0800 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); Fri, 21 Feb 2014 11:48:24 -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.2.247.3; Fri, 21 Feb 2014 19:48:22 +0000 From: Thomas Schwinge To: CC: Subject: Re: [gomp4 3/6] Initial support for OpenACC memory mapping semantics. In-Reply-To: <1389712208-416-3-git-send-email-thomas@codesourcery.com> References: <87ppnuvbv6.fsf@schwinge.name> <1389712208-416-1-git-send-email-thomas@codesourcery.com> <1389712208-416-2-git-send-email-thomas@codesourcery.com> <1389712208-416-3-git-send-email-thomas@codesourcery.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Fri, 21 Feb 2014 20:48:18 +0100 Message-ID: <877g8os0vx.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Tue, 14 Jan 2014 16:10:05 +0100, I wrote: > --- gcc/gimplify.c > +++ gcc/gimplify.c > @@ -86,7 +92,11 @@ enum omp_region_type > ORT_UNTIED_TASK = 5, > ORT_TEAMS = 8, > ORT_TARGET_DATA = 16, > - ORT_TARGET = 32 > + ORT_TARGET = 32, > + > + /* Flags for ORT_TARGET. */ > + /* Default to GOVD_MAP_FORCE for implicit mappings in this region. */ > + ORT_TARGET_MAP_FORCE = 64 > }; Continuing on that route, I have now applied the following to gomp-4_0-branch in r208014: commit dee2965ae547af0bc90d618e7fa40fbf2f5292b4 Author: tschwinge Date: Fri Feb 21 19:45:12 2014 +0000 Gimplification: New flag ORT_TARGET_OFFLOAD replaces !ORT_TARGET_DATA. gcc/ * gimplify.c (enum omp_region_type): Make ORT_TARGET_OFFLOAD a flag for ORT_TARGET, in its negation replacing ORT_TARGET_DATA. Update all users. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@208014 138bc75d-0d04-0410-961f-82ee72b054a4 Grüße, Thomas diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index 1ce952d..bf8ec96 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,5 +1,9 @@ 2014-02-21 Thomas Schwinge + * gimplify.c (enum omp_region_type): Make ORT_TARGET_OFFLOAD a + flag for ORT_TARGET, in its negation replacing ORT_TARGET_DATA. + Update all users. + * omp-low.c (gimple_code_is_oacc): Move to... * gimple.h (is_gimple_omp_oacc_specifically): ... here. Update users, and also use it in more places where currently we've only diff --git gcc/gimplify.c gcc/gimplify.c index 51a1b73..9aa9301c 100644 --- gcc/gimplify.c +++ gcc/gimplify.c @@ -100,10 +100,11 @@ enum omp_region_type ORT_TASK = 4, ORT_UNTIED_TASK = 5, ORT_TEAMS = 8, - ORT_TARGET_DATA = 16, - ORT_TARGET = 32, + ORT_TARGET = 16, /* Flags for ORT_TARGET. */ + /* Prepare this region for offloading. */ + ORT_TARGET_OFFLOAD = 32, /* Default to GOVD_MAP_FORCE for implicit mappings in this region. */ ORT_TARGET_MAP_FORCE = 64 }; @@ -2202,7 +2203,7 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) return gimplify_expr (arg_p, pre_p, NULL, test, fb); } -/* Don't fold STMT inside ORT_TARGET, because it can break code by adding decl +/* Don't fold inside offloading regsion: it can break code by adding decl references that weren't in the source. We'll do it during omplower pass instead. */ @@ -2211,7 +2212,8 @@ maybe_fold_stmt (gimple_stmt_iterator *gsi) { struct gimplify_omp_ctx *ctx; for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context) - if (ctx->region_type & ORT_TARGET) + if (ctx->region_type & ORT_TARGET + && ctx->region_type & ORT_TARGET_OFFLOAD) return false; return fold_stmt (gsi); } @@ -5388,10 +5390,12 @@ omp_firstprivatize_variable (struct gimplify_omp_ctx *ctx, tree decl) return; } else if (ctx->region_type & ORT_TARGET) - omp_add_variable (ctx, decl, GOVD_MAP | GOVD_MAP_TO_ONLY); + { + if (ctx->region_type & ORT_TARGET_OFFLOAD) + omp_add_variable (ctx, decl, GOVD_MAP | GOVD_MAP_TO_ONLY); + } else if (ctx->region_type != ORT_WORKSHARE - && ctx->region_type != ORT_SIMD - && ctx->region_type != ORT_TARGET_DATA) + && ctx->region_type != ORT_SIMD) omp_add_variable (ctx, decl, GOVD_FIRSTPRIVATE); ctx = ctx->outer_context; @@ -5580,7 +5584,8 @@ omp_notice_threadprivate_variable (struct gimplify_omp_ctx *ctx, tree decl, struct gimplify_omp_ctx *octx; for (octx = ctx; octx; octx = octx->outer_context) - if (octx->region_type & ORT_TARGET) + if ((octx->region_type & ORT_TARGET) + && (octx->region_type & ORT_TARGET_OFFLOAD)) { gcc_assert (!(octx->region_type & ORT_TARGET_MAP_FORCE)); @@ -5643,7 +5648,8 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) } n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl); - if (ctx->region_type & ORT_TARGET) + if ((ctx->region_type & ORT_TARGET) + && (ctx->region_type & ORT_TARGET_OFFLOAD)) { unsigned map_force; if (ctx->region_type & ORT_TARGET_MAP_FORCE) @@ -5695,7 +5701,8 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) if (ctx->region_type == ORT_WORKSHARE || ctx->region_type == ORT_SIMD - || ctx->region_type == ORT_TARGET_DATA) + || ((ctx->region_type & ORT_TARGET) + && !(ctx->region_type & ORT_TARGET_OFFLOAD))) goto do_outer; /* ??? Some compiler-generated variables (like SAVE_EXPRs) could be @@ -5746,7 +5753,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code) { splay_tree_node n2; - if ((octx->region_type & (ORT_TARGET_DATA | ORT_TARGET)) != 0) + if (octx->region_type & ORT_TARGET) continue; n2 = splay_tree_lookup (octx->variables, (splay_tree_key) decl); if (n2 && (n2->value & GOVD_DATA_SHARE_CLASS) != GOVD_SHARED) @@ -5899,7 +5906,7 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate) || (!copyprivate && lang_hooks.decls.omp_privatize_by_reference (decl))); - if ((ctx->region_type & (ORT_TARGET | ORT_TARGET_DATA)) != 0) + if (ctx->region_type & ORT_TARGET) continue; n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl); @@ -6456,7 +6463,9 @@ gimplify_adjust_omp_clauses (tree *list_p) if (!DECL_P (decl)) break; n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl); - if ((ctx->region_type & ORT_TARGET) && !(n->value & GOVD_SEEN)) + if ((ctx->region_type & ORT_TARGET) + && (ctx->region_type & ORT_TARGET_OFFLOAD) + && !(n->value & GOVD_SEEN)) remove = true; else if (DECL_SIZE (decl) && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST @@ -6574,8 +6583,9 @@ gimplify_oacc_parallel (tree *expr_p, gimple_seq *pre_p) tree expr = *expr_p; gimple g; gimple_seq body = NULL; - enum omp_region_type ort = - (enum omp_region_type) (ORT_TARGET | ORT_TARGET_MAP_FORCE); + enum omp_region_type ort = (enum omp_region_type) (ORT_TARGET + | ORT_TARGET_OFFLOAD + | ORT_TARGET_MAP_FORCE); gimplify_scan_omp_clauses (&OACC_PARALLEL_CLAUSES (expr), pre_p, ort); @@ -7031,11 +7041,11 @@ gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p) case OMP_SINGLE: break; case OMP_TARGET: + ort = (enum omp_region_type) (ORT_TARGET | ORT_TARGET_OFFLOAD); + break; + case OMP_TARGET_DATA: ort = ORT_TARGET; break; - case OMP_TARGET_DATA: - ort = ORT_TARGET_DATA; - break; case OMP_TEAMS: ort = ORT_TEAMS; break; @@ -7043,7 +7053,7 @@ gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p) gcc_unreachable (); } gimplify_scan_omp_clauses (&OMP_CLAUSES (expr), pre_p, ort); - if ((ort & ORT_TARGET) || ort == ORT_TARGET_DATA) + if (ort & ORT_TARGET) { push_gimplify_context (); gimple g = gimplify_and_return_first (OMP_BODY (expr), &body); @@ -7051,7 +7061,7 @@ gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p) pop_gimplify_context (g); else pop_gimplify_context (NULL); - if (ort == ORT_TARGET_DATA) + if (!(ort & ORT_TARGET_OFFLOAD)) { gimple_seq cleanup = NULL; tree fn = builtin_decl_explicit (BUILT_IN_GOMP_TARGET_END_DATA); @@ -8697,7 +8707,9 @@ gimplify_body (tree fndecl, bool do_parms) { gcc_assert (gimplify_omp_ctxp == NULL); if (lookup_attribute ("omp declare target", DECL_ATTRIBUTES (fndecl))) - gimplify_omp_ctxp = new_omp_context (ORT_TARGET); + gimplify_omp_ctxp + = new_omp_context ((enum omp_region_type) (ORT_TARGET + | ORT_TARGET_OFFLOAD)); } /* Unshare most shared trees in the body and in that of any nested functions. diff --git gcc/omp-low.c gcc/omp-low.c index b975dad..9fef4c1 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -10858,8 +10858,8 @@ lower_omp (gimple_seq *body, omp_context *ctx) gimple_stmt_iterator gsi; for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) lower_omp_1 (&gsi, ctx); - /* During gimplification, we have not always invoked fold_stmt - (gimplify.c:maybe_fold_stmt); call it now. */ + /* During gimplification, we haven't folded statments inside offloading + regions (gimplify.c:maybe_fold_stmt); do that now. */ if (target_nesting_level) for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi)) fold_stmt (&gsi);