From patchwork Thu Feb 1 11:36:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 195247 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp86198dyb; Thu, 1 Feb 2024 03:39:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsgMS1UB2RJRWUJkkGt1QA9C1NAwXudyBXdf84s8iiK0mJvY5NI+IaXsR95IdAZsZWVCa9 X-Received: by 2002:ac8:5bc1:0:b0:42a:abb2:8190 with SMTP id b1-20020ac85bc1000000b0042aabb28190mr5672480qtb.8.1706787552833; Thu, 01 Feb 2024 03:39:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706787552; cv=pass; d=google.com; s=arc-20160816; b=zXdyZ9kfYglilHNtZ08MHj8m1ailGbMxpCp+TBSA9QTnGcz1DgCZKrZ84Bhg5khlh6 Fgq6dDApS1dzrWaqg5RwJTl8uVy4Mui5Jsyx015EY3iRIgErYaVQ+zNIdq5K06qkFTef RBV+c9gvqQf53SJV6Zqr4GRp2SQx9MxS+h7gGmYD5ol8G+egTSjPAEIjqAZkoAIpLbvk ECD6fuAh30C7G2urWy2SfcVHnp4z7S0Vh2hWgI0d8muFhngMAWWJGIzl2BanLvOk8XsX iBkGqoLScmc+Gz91ROKburXVypjJVYzUMNUN8ScdyX4/xvYSkxix0IxY8RpIY9Kmo2zW JFjw== 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:mime-version:message-id:date :user-agent:references:in-reply-to:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Wc/Uo3Rs2Pe51Ud+b/+zRaHKGs3T39YlngzOiGcoYi8=; fh=gVOWbGSRqLDoFL/jDrqW7poGKfYIjeCtgMAruvyRl98=; b=op4Ib4Y/XCIJn14pYoMwD3UZXUs3DTqB098S8mb7rH5TmVio3EUlNceLJUOiurrmgh rkwhjDvUNqxkBYNfuUBApxJ+pBLVvt6/+dEdNGHIhlEnR6Ou8gd/GqS5TZ61322Tp30+ IMyADy3TYzrsSPN/dkVvi69Y82MjNfucFWrRo4oWpfAxTwET1cK8MtPOxcAQXW+rCxuV ACr3iH7xxQSei2tcb7z2p1r2BfrM7OY9MeyglCcrGIBdcIu4MRzQ2YBgKFNwz9TQQ7mp mPw2rhFlhRK2eoAh/Y0Nc6SmHQqhU6PXeWPxozXEEFthFZRT819m46WWLZi5mjxwQttF EMpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MU0rqruK; 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" X-Forwarded-Encrypted: i=1; AJvYcCWMqZUoLTH6PP8EMHgPiJ86V4GC+l0C3tP1acEt7ZkWnoIxySCiQz5aRmMPfxx6NnO3y1Kp88GUYXM0YRYXaiEux93dRg== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h6-20020ac87d46000000b0042bf0456560si1919072qtb.70.2024.02.01.03.39.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 03:39:12 -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; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=MU0rqruK; 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 4DB323858296 for ; Thu, 1 Feb 2024 11:39:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id DC2713858D33 for ; Thu, 1 Feb 2024 11:37:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC2713858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC2713858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706787428; cv=none; b=v9ydGXxXsoHz82TczRCYxD2DYt7nXQO/2PhRH/PhiInzoYyRSGi4Vzdn9LJbwmvRN/LsORN+e+wBChseWIRuR1FxBouJBmygX5WRI7r7i5Mkf/2CQKuyY/6YPZy+mVQNIImMv/foWL89n7ZR93obnnGwZdeWlgV0WNHEEWMN/q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706787428; c=relaxed/simple; bh=zE5lIUXT8H4AEkmE3iyNJxtE36KpTiDQ96UgheuUGVs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v2xhA256ADVh+I4uKwUWBT0qIzLw6GGBI5Pxe/m3cqqC/kz4kDbpemL/srXV6vUTlzv77+A1JKjY0ta3HeC5xXnhEpBulaIoYXfL5jwf8dfuDW2sMnZaaqcish+gTsPySWTRFrxFSxU2eWCdNUWnwF/6GaHCJlzB4iqAOH28wmc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a364b5c5c19so130074466b.1 for ; Thu, 01 Feb 2024 03:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1706787421; x=1707392221; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Wc/Uo3Rs2Pe51Ud+b/+zRaHKGs3T39YlngzOiGcoYi8=; b=MU0rqruKMPj20sob7R2PAYb1If6rNC6lqklcKvZA+OGM7aQlMMYnS7nUCh1RfWU4Jk ySrnh94SfNAFp0fztu3/C6uo761TexSjItZWvvhkgUQ6CK97mGU06CpGxU5G7cmNlaKl E3M3H8RQJCr2KHDnVSD8oVmuoM5fPqaJayAA+5JTbj5gTUFoppgdW8m5XyVHyyTlJHpH L2Z8j1zGf9o7/fwi87vzS0/da86XYhybI3RuGXKp8J/0qwd1CpZ0L9HlVIKmwCkHae3d uZ3bqwSlxHXa04KOQzc198gnq3xw0pE/mFaE3casSGSEHF/vZ4EDBOTTxCuShxjUizUY sSIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706787421; x=1707392221; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Wc/Uo3Rs2Pe51Ud+b/+zRaHKGs3T39YlngzOiGcoYi8=; b=effwDcZUfIOfjZeSAPUr21Fdi/2+/HiHmXuZvUrctbJSjysCC7NxNXahfSdGJ0YQlb CnBWzPr9OJDbgmFC4HXb4QzeOw02TUImCBvSPrHbcdMJSPRiSe0XnxK56OIn/Udwy5Sl RTkO8RejuZtgmqdQHji1Fjmrc/6fsrb31kmEr2BJFLNK0p4pbWpfMz3/+oMtrVFQ3ry/ vfIsAf8pMzPFGoXMyaZVhvn25riJrDxUWtZbLNusTDCXTrSmwJMvcrit/NOx8d+N4Gta IcK/eBSsqhZwl9aBwlGaZ3pYDrr9F93YCqHMM4P6k7+IyMgS0R2ryRkUIuI5/3BwCr6V 9+nA== X-Gm-Message-State: AOJu0YxnBOBmm2MGaZ7YJPCCDBRBNBXoWVazImakUy8YEMVbFffN4lHd pq86hndQhdVNjEWNxJDJrP4BUeVX/W85JqPF0zvEY+ouQLoVC27ceyqYgin29xk= X-Received: by 2002:a17:906:481b:b0:a36:2e11:1458 with SMTP id w27-20020a170906481b00b00a362e111458mr3522685ejq.32.1706787421282; Thu, 01 Feb 2024 03:37:01 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV6W/f/SkugZze00bZ80eRvVDkOMqcP7IMa38nEpGlyYy/lWTR7kt9Pw2dC52UUQPV0sRwstGO4hGFjeiE0viVjG5QTIZc/hQ== Received: from euler.schwinge.homeip.net (p200300c8b7344200b5efa23283b9f09b.dip0.t-ipconnect.de. [2003:c8:b734:4200:b5ef:a232:83b9:f09b]) by smtp.gmail.com with ESMTPSA id y9-20020a170906070900b00a35a3e2b90asm4712470ejb.149.2024.02.01.03.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 03:37:00 -0800 (PST) From: Thomas Schwinge To: Andrew Stubbs , gcc-patches@gcc.gnu.org Subject: GCN, RDNA 3: Adjust 'sync_compare_and_swap_lds_insn' In-Reply-To: <4ebcbae0-1d49-4226-aee8-192c9c738b4b@baylibre.com> References: <87plxhlrgr.fsf@euler.schwinge.ddns.net> <4ebcbae0-1d49-4226-aee8-192c9c738b4b@baylibre.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/29.1 (x86_64-pc-linux-gnu) Date: Thu, 01 Feb 2024 12:36:55 +0100 Message-ID: <87plxga014.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: 1789602021934924261 X-GMAIL-MSGID: 1789696465359869681 Hi! On 2024-01-31T11:31:00+0000, Andrew Stubbs wrote: > On 31/01/2024 10:36, Thomas Schwinge wrote: >> OK to push "GCN, RDNA 3: Adjust 'sync_compare_and_swap_lds_insn'", >> see attached? >> >> In pre-RDNA 3 ISA manuals, there are notes for 'DS_CMPST_[...]', like: >> >> Caution, the order of src and cmp are the *opposite* of the BUFFER_ATOMIC_CMPSWAP opcode. >> >> ..., and conversely in the RDNA 3 ISA manual, for 'DS_CMPSTORE_[...]': >> >> In this architecture the order of src and cmp agree with the BUFFER_ATOMIC_CMPSWAP opcode. >> >> Is my understanding correct, that this isn't something we have to worry >> about at the GCC machine description level; that's resolved at the >> assembler level? > > Right, the IR uses GCC's operand order and has nothing to do with the > assembler syntax; the output template does the mapping. > >> --- a/gcc/config/gcn/gcn.md >> +++ b/gcc/config/gcn/gcn.md >> @@ -2095,7 +2095,12 @@ >> (match_operand:SIDI 3 "register_operand" " v")] >> UNSPECV_ATOMIC))] >> "" >> - "ds_cmpst_rtn_b %0, %1, %2, %3\;s_waitcnt\tlgkmcnt(0)" >> + { >> + if (TARGET_RDNA3) >> + return "ds_cmpstore_rtn_b %0, %1, %2, %3\;s_waitcnt\tlgkmcnt(0)"; >> + else >> + return "ds_cmpst_rtn_b %0, %1, %2, %3\;s_waitcnt\tlgkmcnt(0)"; >> + } >> [(set_attr "type" "ds") >> (set_attr "length" "12")]) > > I think you need to swap %2 and %3 in the new format. ds_cmpst matches > GCC operand order, but ds_cmpstore has "cmp" and "src" reversed. OK, thanks. That was my actual question -- so, we do need to swap, and indeed, most of the affected libgomp OpenACC test cases then PASS their execution test. With that changed, I've pushed to master branch commit 6c2a40f4f4577f5d0f7bd1cfda48a5701b75744c "GCN, RDNA 3: Adjust 'sync_compare_and_swap_lds_insn'", see attached. Grüße Thomas From 6c2a40f4f4577f5d0f7bd1cfda48a5701b75744c Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 31 Jan 2024 10:19:00 +0100 Subject: [PATCH] GCN, RDNA 3: Adjust 'sync_compare_and_swap_lds_insn' For OpenACC/GCN '-march=gfx1100', a lot of libgomp OpenACC test cases FAIL: /tmp/ccGfLJ8a.mkoffload.2.s:406:2: error: instruction not supported on this GPU ds_cmpst_rtn_b32 v0, v0, v4, v3 ^ In RDNA 3, 'ds_cmpst_[...]' has been replaced by 'ds_cmpstore_[...]', and the notes for 'ds_cmpst_[...]' in pre-RDNA 3 ISA manuals: Caution, the order of src and cmp are the *opposite* of the BUFFER_ATOMIC_CMPSWAP opcode. ..., have been resolved for 'ds_cmpstore_[...]' in the RDNA 3 ISA manual: In this architecture the order of src and cmp agree with the BUFFER_ATOMIC_CMPSWAP opcode. ..., and therefore '%2', '%3' now swapped with regards to GCC operand order. Most of the affected libgomp OpenACC test cases then PASS their execution test. gcc/ * config/gcn/gcn.md (sync_compare_and_swap_lds_insn) [TARGET_RDNA3]: Adjust. --- gcc/config/gcn/gcn.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 1f3c692b7a67..925e2cea4895 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -2074,7 +2074,12 @@ (match_operand:SIDI 3 "register_operand" " v")] UNSPECV_ATOMIC))] "" - "ds_cmpst_rtn_b %0, %1, %2, %3\;s_waitcnt\tlgkmcnt(0)" + { + if (TARGET_RDNA3) + return "ds_cmpstore_rtn_b %0, %1, %3, %2\;s_waitcnt\tlgkmcnt(0)"; + else + return "ds_cmpst_rtn_b %0, %1, %2, %3\;s_waitcnt\tlgkmcnt(0)"; + } [(set_attr "type" "ds") (set_attr "length" "12")]) -- 2.43.0