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: 185886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp923902dyq; Mon, 8 Jan 2024 02:02:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIGn0k0vdAJ6sqJOXGeQ6I6CT2vXR0lSsWAG0BAyLA5teIZqq+TMY6nN4ietkHR9KTEmAg X-Received: by 2002:a05:6870:c087:b0:204:2d91:b155 with SMTP id c7-20020a056870c08700b002042d91b155mr4753297oad.80.1704708142523; Mon, 08 Jan 2024 02:02:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704708142; cv=pass; d=google.com; s=arc-20160816; b=Za8c8gxe26DmSYTDfmiiNzjm+R9k6UiTLcloKTYL3WPEGcBymQU58z3+FJ4vuRYElf dvdaadgGfKgZTNM9UZFJyFXIzxaN/fhlfh+8TaE/g/1Ay008OaDA6Kmqds9AuaJnjkYl 1MlylvptevnRcJ1H8kCIvldA71gXJ9vnEq4Cf7xCE1k5AQMHrq9qYNnFlDqZaY/4bGWh +FnpV/akEHY4m31Hl9fgqm7AkYDX2p3mRTXRtceO3iwZhe1D84r4Os5VZ9HLHBOkngrF oFL0Ka/MPb/7qNFnxG3yT9njgkCTVeC2Hnd5J5R9OvaQAwxxyx0NCq2QidAsYdRYSBeM WSTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:arc-filter:dmarc-filter:delivered-to; bh=OpiBbOJda28l+zBbLlZo3vcUagDqBIeOn0easYl1lOE=; fh=XNn3asQvIblazGK92GBt13dVv+YmGV3pBS0JC29ZQco=; b=oLKLZIJmGEslg6BFRMmQ8yS0b/M0LB8gRpegbTbw0XdYjoiP5DQH2bDyIYMIP6KV04 BYh4x3XNU8pSEKsWg1Cs4whpHPdMeMGodIU/wnQ34A6WP+DkqdEB5IzfdLOhVq4TMuiO TJH3ib/I850kk/ioy1+begImXCpgmTl/FvO8bJo2KzPhivyQAq+TVV/VvgTpqI86g/8d s+cKZlMZajRUNm0K+cvjISeZno0HmwgD3Pwknzk2S/sXF2lL0KvbOlfWztL5GGUrFKa0 lFWGf2qauRwf50ZHR1IhJ5S3ikknF3BSDS10cgj3rLtHijmKMzfgfmWIWQY+CChGs1nd S+3g== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u8-20020a05622a010800b004298788574csi4204303qtw.706.2024.01.08.02.02.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:02:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3431B385EC57 for ; Mon, 8 Jan 2024 10:02:22 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787516044804586490 X-GMAIL-MSGID: 1787516044804586490 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; }