From patchwork Thu Apr 20 13:29:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 85911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp337010vqo; Thu, 20 Apr 2023 06:30:29 -0700 (PDT) X-Google-Smtp-Source: AKy350bUKa95gmPIRDHJpDfHmDrEhzo5cHJK0nnAofl2rK04sMcraYnnn64tzGvtb5kB2/Pv+8aw X-Received: by 2002:a17:907:75ce:b0:94e:b3a1:3ed9 with SMTP id jl14-20020a17090775ce00b0094eb3a13ed9mr1577961ejc.49.1681997429386; Thu, 20 Apr 2023 06:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681997429; cv=none; d=google.com; s=arc-20160816; b=xAXH4/SRjgQiXJ6Aqprc6WDbDs77yTdiq9rSaMv5S9qOmlSxVf/aPFg2UZaTVKGL57 8UeJ+yI2zKrRPRRGyzIYilv7xPotACuPejoYffFO5Z9DnsdrAhm3HH4sAxstrXQbnX2q ppMtnFzp0S/t0tDuCW50RALmTCdZbANALVFXwgTMpouh5kHWlc6vaQijtHlkCncRqFFD fCP55/4mRYcjuLThvHdu9OatOoUKnjaHMW4zOeqYT/oMIaidRL9+ffaP1fvqx2LZAVjk WIpsTQorz2lvx5XR1AlENAKoYSJ0I+a7dqoWnNQBbTphEtYcsdnp+ulOi9Ux7vx8envP Y12g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:subject:from :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=qs4LkSVFLEPAjMpdzXiJZ/EqWwxbF4JdzU9CCM0YvRQ=; b=UeJSlNkdW88msJiulOEpajpvdMdGWe/XU4IFKZgi6K2P0rWLDiFM+XjbHssLxiZa/Q EwpoMVVC/6Qa3leE5Qt+STK6dec6SnDlUnLFwd+E31Lo4uXd4djwY1TceJk+YF852bF1 Eqv1ZjEeS+HUCEnSiiRcWTAZxCe0/FLXuz2c16du5ptYyJCrZXS9tcJl+gIQrH9XbTCU KnMUZ3DW23q2fC/qXF3WDpJteW3ulggOfLNAtYwg1R9rYSGbrS39+oyRH7gMNo3mHTB7 1/lMtteAlkFLA9aBkq8weW4nKbE4edX6ZjlAuJQXps2y9qjvm0xXp1g8TG1pKq+eR558 iOqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u13-20020a170906108d00b0094f1305a98esi1704828eju.533.2023.04.20.06.30.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 06:30:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 503B8385734B for ; Thu, 20 Apr 2023 13:30:21 +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 A83AE3858C83 for ; Thu, 20 Apr 2023 13:29:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A83AE3858C83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.99,212,1677571200"; d="scan'208";a="3386646" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 20 Apr 2023 05:29:55 -0800 IronPort-SDR: TP5+5EXqMg7hqjTUQl3or49vi8sdy/nA1eEFT5bE05k780Axzvo9lVIJFgL/wRl0Qz7j9v21Rt hICxbQFZL66dsnSysTjdRDS8B+F15R8ILDgNkBi/Pg0RtH3WebbRHY1Oj8+CrNx3CX82TKX6Xv 595GG8pMAIPUsVlWooaImDeefoMFl4IYGcBrdk6FXtaTahuRpUOwf9XHzryO1gnX9RC2yuv+rQ /z5gk0I9kvWwwYuxxCqRv9Jw56YLpYNPZe/x9HbDr6ON94FXnCoDUF5TcJjulXLmBOETAx9EVS DmQ= Message-ID: Date: Thu, 20 Apr 2023 14:29:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Content-Language: en-GB From: Andrew Stubbs Subject: [committed][OG10] amdgcn, openmp: Fix concurrency in low-latency allocator To: "gcc-patches@gcc.gnu.org" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763702136390308579?= X-GMAIL-MSGID: =?utf-8?q?1763702136390308579?= I've committed this to the devel/omp/gcc-12 branch. The patch fixes a concurrency issue where the spin-locks didn't work well if many GPU threads tried to free low-latency memory all at once. Adding a short sleep instruction is enough for the hardware thread to yield and allow another to proceed. The alloc routine already had this feature, so this just corrects an accidental omission. This patch will get folded into the previous OG12 patch series when I repost it for mainline. Andrew amdgcn, openmp: Fix concurrency in low-latency allocator The previous code works fine on Fiji and Vega 10 devices, but bogs down in The spin locks on Vega 20 or newer. Adding the sleep instructions fixes the problem. libgomp/ChangeLog: * basic-allocator.c (basic_alloc_free): Use BASIC_ALLOC_YIELD. (basic_alloc_realloc): Use BASIC_ALLOC_YIELD. diff --git a/libgomp/basic-allocator.c b/libgomp/basic-allocator.c index b4b9e4ba13a..a61828e48a0 100644 --- a/libgomp/basic-allocator.c +++ b/libgomp/basic-allocator.c @@ -188,6 +188,7 @@ basic_alloc_free (char *heap, void *addr, size_t size) break; } /* Spin. */ + BASIC_ALLOC_YIELD; } while (1); @@ -267,6 +268,7 @@ basic_alloc_realloc (char *heap, void *addr, size_t oldsize, break; } /* Spin. */ + BASIC_ALLOC_YIELD; } while (1);