From patchwork Fri Nov 13 22:14:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1400161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CXt7G1x4pz9sPB for ; Sat, 14 Nov 2020 09:14:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD7943951C2E; Fri, 13 Nov 2020 22:14:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id A77B63951C2E for ; Fri, 13 Nov 2020 22:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A77B63951C2E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Thomas_Schwinge@mentor.com IronPort-SDR: VtrPNPkEpnUEHj5GlY2g1m5YP1z6y/LjcIBoph2HnWvZDeT4/U9rndtitegFcFAX9TU3RtCEvk mpSOWfa4r9l/Lr8t8EWk7qCzBr5ZOTpZG+JmoLvjKTmXn3NF0QIXWWF75hVDGudHW4/Q/obwPi zIFCZIzAIMRLrHb9DHiIs6/j0e/Y+DJ/TZH+FCw1mKx859hH6X4q9csmHScXWfh3DbkLfZ5Qbe 5GpKlR44yJPrTsknKsLDSmqruz4CqooxAWQM3dJwwpYv1KMJimM7Sq4UY/9v+SuJY/AZg/b2hW il8= X-IronPort-AV: E=Sophos;i="5.77,476,1596528000"; d="scan'208,223";a="57351275" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 13 Nov 2020 14:14:43 -0800 IronPort-SDR: 5w0e0TJYIgPnHYL5WXvWuoHd19DIJzzcjiVqI17jxsIB94BdXf/HfBp8aXVVZ7VMJkK8se7Ivx tk4/AmIbn8tfu42Y/SMv91NyFttmrDP46qULo+OEThIpZxT788U1Xbk8HgWQX9NefWVcQEgPGx ZfWqUeBefl4DdHB1Uv4fWpHjwGv4Ud/8gJBUpBeueMzJBMH/kG9DqHL5JZfKXyaiRi66R5u1Cy UYsJwIR3Oj9ekX86obV0/zcip4uT/lWXDhugWLobX5h0cyy1Ll33EjZTJXEcq37IhrsNvEYie3 gn4= From: Thomas Schwinge To: Subject: More explicit checking of which OMP constructs we're expecting User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Fri, 13 Nov 2020 23:14:35 +0100 Message-ID: <87a6vkdhv8.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! I've pushed "More explicit checking of which OMP constructs we're expecting" to master branch in commit bd7885755405bc9947ebe805a53d6100c78c8e82, and backported to releases/gcc-10 branch in commit 00d4aa2128fd73b49e28c8a8c5fcb81150b640fe, see attached. Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter From 00d4aa2128fd73b49e28c8a8c5fcb81150b640fe Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 13 Oct 2020 14:56:59 +0200 Subject: [PATCH] More explicit checking of which OMP constructs we're expecting In particular, more precisely highlight what applies generally vs. the special handling for the current 'parloops'-based OpenACC 'kernels' implementation. gcc/ * omp-low.c (scan_sharing_clauses, scan_omp_for) (lower_oacc_reductions, lower_omp_target): More explicit checking of which OMP constructs we're expecting. (cherry picked from commit bd7885755405bc9947ebe805a53d6100c78c8e82) --- gcc/omp-low.c | 59 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index b03575fefdf..d951c54d154 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1166,9 +1166,16 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) goto do_private; case OMP_CLAUSE_REDUCTION: - if (is_oacc_parallel_or_serial (ctx) || is_oacc_kernels (ctx)) - ctx->local_reduction_clauses - = tree_cons (NULL, c, ctx->local_reduction_clauses); + /* Collect 'reduction' clauses on OpenACC compute construct. */ + if (is_gimple_omp_oacc (ctx->stmt) + && is_gimple_omp_offloaded (ctx->stmt)) + { + /* No 'reduction' clauses on OpenACC 'kernels'. */ + gcc_checking_assert (!is_oacc_kernels (ctx)); + + ctx->local_reduction_clauses + = tree_cons (NULL, c, ctx->local_reduction_clauses); + } /* FALLTHRU */ case OMP_CLAUSE_IN_REDUCTION: @@ -2408,7 +2415,7 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx) { omp_context *tgt = enclosing_target_ctx (outer_ctx); - if (!tgt || is_oacc_parallel_or_serial (tgt)) + if (!(tgt && is_oacc_kernels (tgt))) for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) { tree c_op0; @@ -6710,6 +6717,9 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION) { + /* No 'reduction' clauses on OpenACC 'kernels'. */ + gcc_checking_assert (!is_oacc_kernels (ctx)); + tree orig = OMP_CLAUSE_DECL (c); tree var = maybe_lookup_decl (orig, ctx); tree ref_to_res = NULL_TREE; @@ -6747,10 +6757,11 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner, break; case GIMPLE_OMP_TARGET: - if ((gimple_omp_target_kind (probe->stmt) - != GF_OMP_TARGET_KIND_OACC_PARALLEL) - && (gimple_omp_target_kind (probe->stmt) - != GF_OMP_TARGET_KIND_OACC_SERIAL)) + /* No 'reduction' clauses inside OpenACC 'kernels' + regions. */ + gcc_checking_assert (!is_oacc_kernels (probe)); + + if (!is_gimple_omp_offloaded (probe->stmt)) goto do_lookup; cls = gimple_omp_target_clauses (probe->stmt); @@ -7554,8 +7565,16 @@ lower_oacc_head_mark (location_t loc, tree ddvar, tree clauses, tag |= OLF_GANG_STATIC; } - /* In a parallel region, loops are implicitly INDEPENDENT. */ omp_context *tgt = enclosing_target_ctx (ctx); + if (!tgt || is_oacc_parallel_or_serial (tgt)) + ; + else if (is_oacc_kernels (tgt)) + /* Not using this loops handling inside OpenACC 'kernels' regions. */ + gcc_unreachable (); + else + gcc_unreachable (); + + /* In a parallel region, loops are implicitly INDEPENDENT. */ if (!tgt || is_oacc_parallel_or_serial (tgt)) tag |= OLF_INDEPENDENT; @@ -11574,8 +11593,14 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) break; case OMP_CLAUSE_FIRSTPRIVATE: - if (is_oacc_parallel_or_serial (ctx)) - goto oacc_firstprivate; + gcc_checking_assert (offloaded); + if (is_gimple_omp_oacc (ctx->stmt)) + { + /* No 'firstprivate' clauses on OpenACC 'kernels'. */ + gcc_checking_assert (!is_oacc_kernels (ctx)); + + goto oacc_firstprivate; + } map_cnt++; var = OMP_CLAUSE_DECL (c); if (!omp_is_reference (var) @@ -11600,8 +11625,14 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) break; case OMP_CLAUSE_PRIVATE: + gcc_checking_assert (offloaded); if (is_gimple_omp_oacc (ctx->stmt)) - break; + { + /* No 'private' clauses on OpenACC 'kernels'. */ + gcc_checking_assert (!is_oacc_kernels (ctx)); + + break; + } var = OMP_CLAUSE_DECL (c); if (is_variable_sized (var)) { @@ -11950,7 +11981,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) break; case OMP_CLAUSE_FIRSTPRIVATE: - if (is_oacc_parallel_or_serial (ctx)) + if (is_gimple_omp_oacc (ctx->stmt)) goto oacc_firstprivate_map; ovar = OMP_CLAUSE_DECL (c); if (omp_is_reference (ovar)) @@ -12554,7 +12585,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) gimple_seq fork_seq = NULL; gimple_seq join_seq = NULL; - if (is_oacc_parallel_or_serial (ctx)) + if (offloaded && is_gimple_omp_oacc (ctx->stmt)) { /* If there are reductions on the offloaded region itself, treat them as a dummy GANG loop. */ -- 2.17.1