From patchwork Wed Aug 4 14:39:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1513509 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 ozlabs.org (Postfix) with ESMTPS id 4GfvXg15R5z9sS8 for ; Thu, 5 Aug 2021 00:40:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 558A03945C26 for ; Wed, 4 Aug 2021 14:39:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id AEF553851C29 for ; Wed, 4 Aug 2021 14:39:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AEF553851C29 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: SYUzAfs6Z7g9dK7BUybnGu557b3+Ne5lxrX4xAcunfJRrHTUV9GMRD1+/1DGQ06u9A5mxRMK4f DF0H+gD2EGxF0XHzM8j1J5sUOQFiuthY+HXmN7vwfnmZneMy2y3/8BSYWqZmoJ4O+TqsSi8AHv 94oAyRyVxrTd3pi4Cg4mdWWJgtdTPX5TTNl9VMODPbegal1AEDPQTFEctREP0Hiy/a+gDYkjE9 +pTAmokaZrUQ4wzpwzCocvvXxKdZW2yD0TY4fGoQxIxfEdzHBCKsmjgtFfGYkqM3cLzwR9+Jyd /Jnj41exIbKf2uGrHllzBu/V X-IronPort-AV: E=Sophos;i="5.84,294,1620720000"; d="scan'208";a="64281045" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 04 Aug 2021 06:39:33 -0800 IronPort-SDR: +ti3QOa9je6Bt1HAumlaNU2/IoUYzuiCK8cCOtQRNXCDgBFlyJWUdknBAtP/RajvYI2tWsVG5j wxmq89tQl3/ZibgEc+/70+LfcrEtD3jEc+gGHMF7/3NT/AOoxvLflRFiViijzsceORFjnHF1ZP BeM4SvJ95Q/Rzfd1+A4cb5a3buQsnud2tQ5jgYP6mZ2Pxmaw9SeavhG18qke7dE8B079v8JQo7 o2mbZvuOMK33BOH4l92F+PKvbKXHSKMtbcAJzlo6PAQ/zXT16lZ6uj/RmfdX23VQ8eBuTDk5ny vWo= To: "gcc-patches@gcc.gnu.org" From: Andrew Stubbs Subject: [OG11, committed] libgomp amdgcn: Fix issues with dynamic OpenMP thread scaling Message-ID: <1013b924-a33e-2968-5116-1cce90dd85f3@codesourcery.com> Date: Wed, 4 Aug 2021 15:39:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 Content-Language: en-GB X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.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 Schwinge Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch fixes a bug in which testcases using thread_limit larger than the number of physical threads would crash with a memory fault. This was exacerbated in testcases with a lot of register pressure because the autoscaling reduces the number of physical threads to compensate for the increased resource usage. Committed to devel/omp/gcc-11. @ Thomas, this should probably be folded into another patch when upstreaming OG11 to mainline. Andrew libgomp amdgcn: Fix issues with dynamic OpenMP thread scaling libgomp/ChangeLog: * config/gcn/bar.h (gomp_barrier_init): Limit thread count to the actual physical number. * config/gcn/team.c (gomp_team_start): Don't attempt to set up threads that do not exist. diff --git a/libgomp/config/gcn/bar.h b/libgomp/config/gcn/bar.h index bbd3141837f..63e803bd72b 100644 --- a/libgomp/config/gcn/bar.h +++ b/libgomp/config/gcn/bar.h @@ -55,6 +55,9 @@ typedef unsigned int gomp_barrier_state_t; static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) { + unsigned actual_thread_count = __builtin_gcn_dim_size (1); + if (count > actual_thread_count) + count = actual_thread_count; bar->total = count; bar->awaited = count; bar->awaited_final = count; diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c index 627210ea407..6aa74744315 100644 --- a/libgomp/config/gcn/team.c +++ b/libgomp/config/gcn/team.c @@ -187,6 +187,10 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, if (nthreads == 1) return; + unsigned actual_thread_count = __builtin_gcn_dim_size (1); + if (nthreads > actual_thread_count) + nthreads = actual_thread_count; + /* Release existing idle threads. */ for (unsigned i = 1; i < nthreads; ++i) {