From patchwork Wed Dec 15 15:54:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederik Harwath X-Patchwork-Id: 1568402 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JDgJ12jT0z9sXS for ; Thu, 16 Dec 2021 03:12:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E83D03858001 for ; Wed, 15 Dec 2021 16:12:30 +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 5CEBF3858439 for ; Wed, 15 Dec 2021 15:56:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CEBF3858439 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: 5Rr22kLpTPqLi9/gjBCQvXcMEdNeunpAHB0XJMB5r61m7Nx2Zb3yxJ/QTCef6l9/xpEIffXmxm ps+Dct2txVE/cSuL1TEMLnrMPhZn3DITAgDbl4/QUyt821y2H7i4PcvIiDqZSYBnNdkLIHXzFt MiOJtlZx0vlOg/jBuQutu0qlXgGDzUluj8VuWZxSFQZ3so1/fU5ecltxs+xpyNTuZ9Q3vK2D8G KvEIhG6pePxHqTNXfgd3VjtZwZ7gh0wNXcX3/fh0podsH+8NXfMiz4f4MmzBpLx5q6iv461oUg hRDXAmLhxyA6i6K99Jtm1t8r X-IronPort-AV: E=Sophos;i="5.88,207,1635235200"; d="scan'208";a="72258711" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 15 Dec 2021 07:56:42 -0800 IronPort-SDR: 7iMKgjJivqEjZ6h71BwdcxUEoc8/zshTQto09JU4jTU7+pw7UUzazptf8Uq68hQaqRtjdIYTbk 4xHLjn3acr7h1TKifN0Xf08L4F/eZvQKkcIVG0Xhp41MPjexf4I8Mqy7W5abxVhtCUJtFyiXEC 8X1YjVCJdFnJWfBrMovOQxwYNENLAx1SOz96LGEJstFP/Hdq9efUuhy5cqgaKRTUk5tuoKiOrt z5dE7IqFhNkyGzK9kgk5Wqxk2+Z2/yknzClu/VuPk9rASW1/WqKeXTZoOTSfECbWqRakosJO0Z 73o= From: Frederik Harwath To: Subject: [PATCH 26/40] openacc: Warn about "independent" "kernels" loops with data-dependences Date: Wed, 15 Dec 2021 16:54:33 +0100 Message-ID: <20211215155447.19379-27-frederik@codesourcery.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211215155447.19379-1-frederik@codesourcery.com> References: <20211215155447.19379-1-frederik@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: thomas@codesourcery.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This commit concerns loops in OpenACC "kernels" region that have been marked up with an explicit "independent" clause by the user, but for which Graphite found data dependences. A discussion on the private internal OpenACC mailing list suggested that warning the user about the dependences woud be a more acceptable solution than reverting the user's decision. This behavior is implemented by the present commit. gcc/ChangeLog: * common.opt: Add flag Wopenacc-false-independent. * omp-offload.c (oacc_loop_warn_if_false_independent): New function. (oacc_loop_fixed_partitions): Call from here. --- gcc/common.opt | 5 +++++ gcc/omp-offload.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) -- 2.33.0 ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 diff --git a/gcc/common.opt b/gcc/common.opt index b6c46ab63e34..ec76a88f14e3 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -850,6 +850,11 @@ Wtsan Common Var(warn_tsan) Init(1) Warning Warn about unsupported features in ThreadSanitizer. +Wopenacc-false-independent +Common Var(warn_openacc_false_independent) Init(1) Warning +Warn in case a loop in an OpenACC \"kernels\" region has an \"independent\" +clause but analysis shows that it has loop-carried dependences. + Xassembler Driver Separate diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c index 3458a1acbceb..36dde11f5955 100644 --- a/gcc/omp-offload.c +++ b/gcc/omp-offload.c @@ -1900,6 +1900,51 @@ oacc_loop_transform_auto_into_independent (oacc_loop *loop) return true; } +/* Emit a warning if LOOP has an "independent" clause but Graphite's + analysis shows that it has data dependences. Note that we respect + the user's explicit decision to parallelize the loop but we + nevertheless warn that this decision could be wrong. */ + +static void +oacc_loop_warn_if_false_independent (oacc_loop *loop) +{ + if (!optimize) + return; + + if (loop->routine) + return; + + /* TODO Warn about "auto" & "independent" in "parallel" regions? */ + if (!oacc_parallel_kernels_graphite_fun_p ()) + return; + + if (!(loop->flags & OLF_INDEPENDENT)) + return; + + bool analyzed = false; + bool can_be_parallel = oacc_loop_can_be_parallel_p (loop, analyzed); + loop_p cfg_loop = oacc_loop_get_cfg_loop (loop); + + if (cfg_loop && cfg_loop->inner && !analyzed) + { + if (dump_enabled_p ()) + { + const dump_user_location_t loc + = dump_user_location_t::from_location_t (loop->loc); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc, + "'independent' loop in 'kernels' region has not been " + "analyzed (cf. 'graphite' " + "dumps for more information).\n"); + } + return; + } + + if (!can_be_parallel) + warning_at (loop->loc, 0, + "loop has \"independent\" clause but data dependences were " + "found."); +} + /* Walk the OpenACC loop hierarchy checking and assigning the programmer-specified partitionings. OUTER_MASK is the partitioning this loop is contained within. Return mask of partitioning @@ -1951,6 +1996,10 @@ oacc_loop_fixed_partitions (oacc_loop *loop, unsigned outer_mask) } } + /* TODO Is this flag needed? Perhaps use -Wopenacc-parallelism? */ + if (warn_openacc_false_independent) + oacc_loop_warn_if_false_independent (loop); + if (maybe_auto && (loop->flags & OLF_INDEPENDENT)) { loop->flags |= OLF_AUTO;