From patchwork Mon Jan 8 10:01:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1883597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T7qNN5qLbz1yP7 for ; Mon, 8 Jan 2024 21:01:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A36B6385EC54 for ; Mon, 8 Jan 2024 10:01:54 +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 D538D3858430 for ; Mon, 8 Jan 2024 10:01:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D538D3858430 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D538D3858430 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704708091; cv=none; b=RGhZxzlxdppVLAvTDzoEJkiVgzExG/8PEzlGDO+OV6dZd3I/IKPgcmbnqtk5nGz07QB76UyBZku5f0ayD58OxPdUvvRyp+zyS1q1yhJzAMqOeh1HrxGNZrZzQh96kQ1eXFGl8dxerIQZk+DHgttD4/Evce7/MraLxdYIsC7HGPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704708091; c=relaxed/simple; bh=kS5pPHUeoF9eJeLik1L+0ch2D67IvbBHyJhYsiNOIyg=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=xVxph3hnyofOtsJ/0lMqd37xv1LZrsXCZXKLTN9/ppIcvErkvU5vhSvcPJ/6OLcV7MlBoaga3hfqD8bVSusexWAjyXjY93LAHQ+W+2hmWpNABZsMx+GdP65Cz5kBqIjsaCfkPdA4PxAlpkasNSRvsEoS3jVao7oK6ue8e0fo72Y= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: JEaA3SZkTqKD6+gcXHvpsQ== X-CSE-MsgGUID: tPSrNF2mQmeMuUBduujNfg== X-IronPort-AV: E=Sophos;i="6.04,340,1695715200"; d="scan'208";a="30597245" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 08 Jan 2024 02:01:27 -0800 IronPort-SDR: FV+5kX2cIwZWxTTlWN/bmqXdjlakLepHfAP83P4StpVwtKI4awQSHmDC6jqi7gJCgjI50nlJ5O e5O7LJrF/J/TXJWqXb1v3cGmA/nvBEzHH6VQ0Qb80y9PiJ7hWmgQfN7Uw2077L2jzGxbkyXMtd nqSsrc4vcuFzW78WJpoXWsTstvYItESdmV7pl3FFIK+X+S6ARkTYLKAxPQUCbtDGTqYBGzK+GC aRWyaf/OZIn8Wpg/fZOZqHfkZjYWIomYswWTIGl/cBAgPqNhDy44gXL9OIhi/Vx3EV3QZtYX9+ VVw= Message-ID: <49e7bf47-f67b-4db0-b2d6-b3a121a363a1@codesourcery.com> Date: Mon, 8 Jan 2024 10:01:23 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "gcc-patches@gcc.gnu.org" From: Andrew Stubbs Subject: [committed] amdgcn: Don't double-count AVGPRs X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This patch fixes a runtime error with offload kernels that use a lot of registers, such as libgomp.fortran/target1.f90. Committed to mainline. Andrew amdgcn: Don't double-count AVGPRs CDNA2 devices have VGPRs and AVGPRs combined into a single hardware register file (they're seperate in CDNA1). I originally thought they were counted separately in the vgpr_count and agpr_count metadata fields, and therefore mkoffload had to account for this when passing the values to libgomp. However, that wasn't the case, and this code should have been removed when I corrected the calculations in gcn.cc. Fixing the error now. gcc/ChangeLog: * config/gcn/mkoffload.cc (isa_has_combined_avgprs): Delete. (process_asm): Don't count avgprs. diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc index 3341c0d34eb..03cd040dbd2 100644 --- a/gcc/config/gcn/mkoffload.cc +++ b/gcc/config/gcn/mkoffload.cc @@ -471,26 +471,6 @@ copy_early_debug_info (const char *infile, const char *outfile) return true; } -/* CDNA2 devices have twice as many VGPRs compared to older devices, - but the AVGPRS are allocated from the same pool. */ - -static int -isa_has_combined_avgprs (int isa) -{ - switch (isa) - { - case EF_AMDGPU_MACH_AMDGCN_GFX803: - case EF_AMDGPU_MACH_AMDGCN_GFX900: - case EF_AMDGPU_MACH_AMDGCN_GFX906: - case EF_AMDGPU_MACH_AMDGCN_GFX908: - case EF_AMDGPU_MACH_AMDGCN_GFX1030: - return false; - case EF_AMDGPU_MACH_AMDGCN_GFX90a: - return true; - } - fatal_error (input_location, "unhandled ISA in isa_has_combined_avgprs"); -} - /* Parse an input assembler file, extract the offload tables etc., and output (1) the assembler code, minus the tables (which can contain problematic relocations), and (2) a C file with the offload tables @@ -516,7 +496,6 @@ process_asm (FILE *in, FILE *out, FILE *cfile) { int sgpr_count; int vgpr_count; - int avgpr_count; char *kernel_name; } regcount = { -1, -1, NULL }; @@ -564,12 +543,6 @@ process_asm (FILE *in, FILE *out, FILE *cfile) gcc_assert (regcount.kernel_name); break; } - else if (sscanf (buf, " .agpr_count: %d\n", - ®count.avgpr_count) == 1) - { - gcc_assert (regcount.kernel_name); - break; - } break; } @@ -712,8 +685,6 @@ process_asm (FILE *in, FILE *out, FILE *cfile) { sgpr_count = regcounts[j].sgpr_count; vgpr_count = regcounts[j].vgpr_count; - if (isa_has_combined_avgprs (elf_arch)) - vgpr_count += regcounts[j].avgpr_count; break; }