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: 1791278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QbDzj5j3yz20Ty for ; Wed, 7 Jun 2023 01:34:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C4B33857B9B for ; Tue, 6 Jun 2023 15:34:23 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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; }