From patchwork Mon Jun 29 20:16:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1319165 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49wf1L6QTWz9sR4 for ; Tue, 30 Jun 2020 06:17:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 931E9388E810; Mon, 29 Jun 2020 20:17:30 +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 CBCB9386F037 for ; Mon, 29 Jun 2020 20:17:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CBCB9386F037 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: P2t34DAD/dq5avHqcowE5/Zafw9OkTdsEpjlIoubSQNrOFiQZT9rsh9qZiW5LXIif9G1CTY1Ei Ypv5sERCVjBeaOIOvENlcoToR/xi7qhK4A5aKjuOTp2UeGNa3KOAfVAufru+PilKPzmonhckq8 6r1WEqQLmnE6gyCkL5HWyPF2W2XLj4HOJs81c4KTuxtLAjzjnaKxXKNxRshdRN4YIecf5qSL43 +rW1LP6uvf8bRaIeF/l3LaB2gcnTCTHgW6WyJADS2MUptmWo3xCsyDYqPGwwI8DCdvlM19lImF sko= X-IronPort-AV: E=Sophos;i="5.75,295,1589270400"; d="scan'208";a="50429887" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 29 Jun 2020 12:17:22 -0800 IronPort-SDR: +KvNC9lcknScoOuMgC0gX8KL1yJjZhITUkajPx9nIeINAh2bagz9jX28nUK2YM8y7kDERL5lGZ WGEKF8M8nVML+GKUTtO7IdBxaARGDXXXU4U7AtXL06FVNl/hLjIVG2UcuEhrkOFIQxPSkGTKUp 8lyvkEaAL1ey2ny490M9s/QiNR5nUZntUr54eH+DbdRf6l1vJnfvjb0Dvdz29ZNZ5GxQlZqGiM rKtqmbXqLiFfbyEuTCs+BVqukmAHAnaoIAE9tFPvYM82X0vpr7QenTSuEcUpAUGuc+PtJGTAE2 l7Q= From: Julian Brown To: Subject: [PATCH] [og10] amdgcn: Add waitcnt after LDS write instructions Date: Mon, 29 Jun 2020 13:16:53 -0700 Message-ID: <20200629201653.147326-5-julian@codesourcery.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200629201653.147326-1-julian@codesourcery.com> References: <20200629201653.147326-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Jakub Jelinek , Andrew Stubbs Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Data-share write (ds_write) instructions do not necessarily complete the write to LDS immediately. When a write completes, LGKM_CNT is decremented. For now, we wait until LGKM_CNT reaches zero after each ds_write instruction. This fixes a race condition in the case where LDS is read immediately after being written. This can happen with broadcast operations. OK for og10 branch? Julian ChangeLog gcc/ * config/gcn/gcn-valu.md (scatter_insn_1offset_ds): Add waitcnt. (*mov_insn, *movti_insn): Add waitcnt to ds_write alternatives. --- gcc/config/gcn/gcn-valu.md | 2 +- gcc/config/gcn/gcn.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md index 6d7fecaa12c2..9dfaec1d0645 100644 --- a/gcc/config/gcn/gcn-valu.md +++ b/gcc/config/gcn/gcn-valu.md @@ -923,7 +923,7 @@ { addr_space_t as = INTVAL (operands[3]); static char buf[200]; - sprintf (buf, "ds_write%%b2\t%%0, %%2 offset:%%1%s", + sprintf (buf, "ds_write%%b2\t%%0, %%2 offset:%%1%s\;s_waitcnt\tlgkmcnt(0)", (AS_GDS_P (as) ? " gds" : "")); return buf; } diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 8cfb3a85d256..e58669240c67 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -554,7 +554,7 @@ flat_load_dword\t%0, %A1%O1%g1\;s_waitcnt\t0 flat_store_dword\t%A0, %1%O0%g0 v_mov_b32\t%0, %1 - ds_write_b32\t%A0, %1%O0 + ds_write_b32\t%A0, %1%O0\;s_waitcnt\tlgkmcnt(0) ds_read_b32\t%0, %A1%O1\;s_waitcnt\tlgkmcnt(0) s_mov_b32\t%0, %1 global_load_dword\t%0, %A1%O1%g1\;s_waitcnt\tvmcnt(0) @@ -582,7 +582,7 @@ flat_load%o1\t%0, %A1%O1%g1\;s_waitcnt\t0 flat_store%s0\t%A0, %1%O0%g0 v_mov_b32\t%0, %1 - ds_write%b0\t%A0, %1%O0 + ds_write%b0\t%A0, %1%O0\;s_waitcnt\tlgkmcnt(0) ds_read%u1\t%0, %A1%O1\;s_waitcnt\tlgkmcnt(0) global_load%o1\t%0, %A1%O1%g1\;s_waitcnt\tvmcnt(0) global_store%s0\t%A0, %1%O0%g0" @@ -611,7 +611,7 @@ # flat_load_dwordx2\t%0, %A1%O1%g1\;s_waitcnt\t0 flat_store_dwordx2\t%A0, %1%O0%g0 - ds_write_b64\t%A0, %1%O0 + ds_write_b64\t%A0, %1%O0\;s_waitcnt\tlgkmcnt(0) ds_read_b64\t%0, %A1%O1\;s_waitcnt\tlgkmcnt(0) global_load_dwordx2\t%0, %A1%O1%g1\;s_waitcnt\tvmcnt(0) global_store_dwordx2\t%A0, %1%O0%g0" @@ -667,7 +667,7 @@ # global_store_dwordx4\t%A0, %1%O0%g0 global_load_dwordx4\t%0, %A1%O1%g1\;s_waitcnt\tvmcnt(0) - ds_write_b128\t%A0, %1%O0 + ds_write_b128\t%A0, %1%O0\;s_waitcnt\tlgkmcnt(0) ds_read_b128\t%0, %A1%O1\;s_waitcnt\tlgkmcnt(0)" "reload_completed && REG_P (operands[0])