From patchwork Tue Jun 6 15:33:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 103936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3483374vqr; Tue, 6 Jun 2023 08:34:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oU0K2nwHslaBOsJg1spllMukYpYF/P964zzjGOGjhr8E2YPQ0kqn39xz8dVtHwb9Q8r/Q X-Received: by 2002:a05:6402:1adc:b0:514:95d5:3994 with SMTP id ba28-20020a0564021adc00b0051495d53994mr2559670edb.32.1686065682586; Tue, 06 Jun 2023 08:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686065682; cv=none; d=google.com; s=arc-20160816; b=veyHOyWWVWHrW9o5isTlh0+hRrMw/BjKBIYKSPqD4jpwvArD/6Qr6T6ULooHM9I36W VJ1hp4yNR9phR+53ipFQT4SAHfql22UNFW/Nm9aaN9coprkxexAO8AmJpJSPTZpCvPRB c8p5aBQmdLqrx1dZ4BhhWr1giPHwjd4fg8r5NY9wPeXFg16bgckb7fgA9l4fHGJb0z5X cILtYBFGDHOfosjVyBhpx0i5nKA5N+XWnq2er8g+Y+Yp6gbAc1O94NCydxQ49ShMVs5n QmZJQtCnK6fg5mCrqkbfOukpmqVtL4rWyVUUVHTaIZZYdl5z/NhI7kt6cmqv7Rovz2XG zawA== 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:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=2m5/e0VpTTNnHAE2ha5x95MRItoOII455wUxc8tnOEY=; b=X1nreXwIG+hIkp5+u/9MaLNmSFmTiEoBGpGUl4Id5RAYXDtAl4CZjF4Rtuur1InWF4 JfKoe4uvT49Shz6ul0apdtkzzV8re11Z9jnlwmECedaZSkq7lBi8iFcPq9FD5tmTUGxz uDC2LWVI7FbA8+MLaxJ5KpOPF3NUWsD8aFXHyCnyzniZ2DSkF9lZDtSWs/a1mWxCoWUM etlt+nsG4jPTiyo54ZSDXsDB3wsB1cuJHP2AmZ2UAIA99p7qIpyQ7g8qc/TRrPNuFn7f IHViiMb023ecp1iMkz+lkfgWb71hHfa6RJYCIwc7I2qm025VUK9wzqJALTEJSG2BRnlC sqOw== 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 b22-20020aa7df96000000b00514b39763f0si6878252edy.672.2023.06.06.08.34.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 08:34:42 -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 E8B43385773C for ; Tue, 6 Jun 2023 15:34:35 +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 309463857722 for ; Tue, 6 Jun 2023 15:33:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 309463857722 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="6.00,221,1681200000"; d="diff'?scan'208";a="8968539" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 06 Jun 2023 07:33:36 -0800 IronPort-SDR: lVkN621fHYJGCl8Q7uxBP740IKuJyjKNS86ZY+iSMnBaengduCQDoRRJDVCfiVgM4mO6/WnRzn A9YXTkNNOPBimCpsYy6VQWdojxV3Jcd/EOASAHEDyF2YXqIfg3grwYk2A8pBUjx7+iMCIjiJez vhTEvNUGU+r6biwSfki8SjKBRulEbOvEEcTvtLCfrvB0a5oSY7D3IlF78cXc+2KwbI3r3Vn+OT nYFRThBv9sp9POBAEHjlpZ3uGjsrUJheumhBaMv4xw3PcJYDeXGmx1XCyklJ6mcqFiOZg7w8Ni ibE= Message-ID: Date: Tue, 6 Jun 2023 17:33:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Content-Language: en-US To: gcc-patches , Andrew Stubbs From: Tobias Burnus Subject: [Patch] libgomp: plugin-gcn - support 'unified_address' X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, 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?1767968009215981749?= X-GMAIL-MSGID: =?utf-8?q?1767968009215981749?= Andrew: Does the GCN change look okay to you? This patch permits to use GCN devices with 'omp requires unified_address' which in principle works already, except that the requirement handling did disable it. (It also updates libgomp.texi for this change and likewise for an older likewise nvptx change.) I will later add a testcase → https://gcc.gnu.org/PR109837 However, the patch was tested with the respective sollve_vv testcase with an additional fix applied on top → https://github.com/SOLLVE/sollve_vv/pull/737 (I do note that with the USM patches for OG12/OG13, unified_address is accepted, cf. OG13 https://gcc.gnu.org/g:3ddf3565faee70e8c910d90ab0c80e71813a0ba1 , but USM itself goes much beyond what we need here.) Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 libgomp: plugin-gcn - support 'unified_address' Effectively, for GCN (as for nvptx) there is a common address space between host and device, whether being accessible or not. Thus, this commit permits to use 'omp requires unified_address' with GCN devices. (nvptx accepts this requirement since r13-3460-g131d18e928a3ea.) libgomp/ * plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Regard unified_address requirement as supported. * libgomp.texi (OpenMP 5.0, AMD Radeon, nvptx): Remove 'unified_address' from the not-supported requirements. libgomp/libgomp.texi | 9 ++++----- libgomp/plugin/plugin-gcn.c | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 76c56a73969..a3d370a0fb3 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -192,8 +192,7 @@ The OpenMP 4.5 specification is fully supported. env variable @tab Y @tab @item Nested-parallel changes to @emph{max-active-levels-var} ICV @tab Y @tab @item @code{requires} directive @tab P - @tab complete but no non-host devices provides @code{unified_address} or - @code{unified_shared_memory} + @tab complete but no non-host devices provides @code{unified_shared_memory} @item @code{teams} construct outside an enclosing target region @tab Y @tab @item Non-rectangular loop nests @tab P @tab Full support for C/C++, partial for Fortran @item @code{!=} as relational-op in canonical loop form for C/C++ @tab Y @tab @@ -4460,7 +4459,7 @@ The implementation remark: @code{device(ancestor:1)}) are processed serially per @code{target} region such that the next reverse offload region is only executed after the previous one returned. -@item OpenMP code that has a requires directive with @code{unified_address} or +@item OpenMP code that has a @code{requires} directive with @code{unified_shared_memory} will remove any GCN device from the list of available devices (``host fallback''). @item The available stack size can be changed using the @code{GCN_STACK_SIZE} @@ -4522,8 +4521,8 @@ The implementation remark: Per device, reverse offload regions are processed serially such that the next reverse offload region is only executed after the previous one returned. -@item OpenMP code that has a requires directive with @code{unified_address} - or @code{unified_shared_memory} will remove any nvptx device from the +@item OpenMP code that has a @code{requires} directive with + @code{unified_shared_memory} will remove any nvptx device from the list of available devices (``host fallback''). @end itemize diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index 2181bf0235f..ef22d48da79 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -3231,7 +3231,9 @@ GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask) /* Return -1 if no omp_requires_mask cannot be fulfilled but devices were present. */ if (hsa_context.agent_count > 0 - && (omp_requires_mask & ~GOMP_REQUIRES_REVERSE_OFFLOAD) != 0) + && ((omp_requires_mask + & ~(GOMP_REQUIRES_UNIFIED_ADDRESS + | GOMP_REQUIRES_REVERSE_OFFLOAD)) != 0)) return -1; return hsa_context.agent_count; }