From patchwork Fri Mar 8 10:16:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 86964 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F10B8385DC0F for ; Fri, 8 Mar 2024 10:16:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 32A5E3858D35 for ; Fri, 8 Mar 2024 10:16:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32A5E3858D35 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 32A5E3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709892993; cv=none; b=sjRqvKeJnipNNCoqTw4hGI8390ZcgCpftIWT2cdgCe/JaI5mlqRLZSqz+LF0m92/Hpl7mFSbcDNfxkRGKkwFacXzGXDmadJZPL/5bdFdPkOQ/DNMPcvqACfDRnDU/rsWldocmKoAJs4LOY5i4MtrfTWeWKeaRs0BoRMmmkUj+DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709892993; c=relaxed/simple; bh=3QQ3+K+6TT0bjPT9xlnUokOdBff7skq5jMu8XqMWGEw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hbcmpJ+epux9Nhudo7ALAUO0/3G++fT4IJyasopZQMotrzILide+/bvynnBlxsFniyptiPU9S9q9+6PLwPF/pXBJXYcxGzGq3rO7h124WxobEVtxEIwfHTwQuxBUoTVeeMZhBPFZItRA2BUT0zI9QS09bgEnBTOWQFmKD5I4s6E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a4467d570cdso77505766b.3 for ; Fri, 08 Mar 2024 02:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1709892990; x=1710497790; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=NAmnbNM61ZFEP5nNBVMcegDMpa/Jtpyx0CQ8RhCAQTA=; b=DZsYtMmE7P/006LuObEpLLlYdeewEVFCX+GEEPq6Mb34W1kHZ7wX+Jv+5DMPoGZBrT FW8yAMO7AHlfgvp0BVoBRt+rJF/6jglq83lYajFF0Dt7gVXVPWg7iutfTweCakhnOG7F eqbJVVUUow2BSMfLC/kyO282YQrF8IkEdPMHYQ5xdPViwCm+ZZb5YTwok2CXPlbN/Xmf Xi/rd/NUmQ7+Xuy55M78V8KTx6cHos9Mkf7CTlmK7jwBNn1bmsYJ/jc9gNFdKtkNR/zJ 0BH0IJ2luVoLvX2Pbn+XwoJg/FiTVlJSkNuXeddbZwgAeut6P0C6vLZH7LMhmkmbPE4n JfVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709892990; x=1710497790; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NAmnbNM61ZFEP5nNBVMcegDMpa/Jtpyx0CQ8RhCAQTA=; b=RJCT/y8/WmizRAFPTtOg7AhEI8LRFh7cIZtpNLfX8UjDR1yZ83nTV9euCR8AsdNUSQ /qgwNTuB1Kzjab4ePnku8IQNHuip628j84XLgDrubYkMxLnovibx5n3ONrxYzuaq9h5A B5rDFt5emSsgodzJ9jsx3354nLo8SGF4UDHM45s0bLcUHMxIQ7lRqSl8pYjPHI/MZ+zV CVmJLjHPdPeKcbRlKbX/n6pcPV4yClYdaJJHNbM7nAVJg6q6xQDB1ktNXFlV7T3/m44W je3WBMI1Ql2fd+EwqFe4iW+GuJ1s5BJuFKjBuAe056uI09R2zOAuem5/vtrCz0bmnmvR hk2w== X-Forwarded-Encrypted: i=1; AJvYcCXdrYSPko4adEcxJMqo1I//RU3vfH6Z7ZDMsKdomH6hu9u8e8CxAWyqwyiHjyAzLtwTRWbu5wxeBwiqXWBUgc2oVEBduDFRxg== X-Gm-Message-State: AOJu0YwfoFCOhz/8W5MoyioEWAEe61cbCbDS6z/AfVaC+bOaRCHxSKG+ Sw4KBn+U66f1BLqCnpYRnbJ9Xvg2TKNoC9I0JC36QWLYAVqqLy96micPEh2231m4bKf831kN1a6 Y6Jo= X-Google-Smtp-Source: AGHT+IEqEfwd5M4lYArkZPbk3vXYlvn6afs60gJallc9DG7gHj7hlZhTtbM34Qw4P9HGl7KUS3vhVQ== X-Received: by 2002:a17:906:e099:b0:a3e:7e1f:449e with SMTP id gh25-20020a170906e09900b00a3e7e1f449emr13132639ejb.16.1709892989784; Fri, 08 Mar 2024 02:16:29 -0800 (PST) Received: from euler.schwinge.homeip.net (p200300c8b70336000b0134869109dcb1.dip0.t-ipconnect.de. [2003:c8:b703:3600:b01:3486:9109:dcb1]) by smtp.gmail.com with ESMTPSA id sa20-20020a1709076d1400b00a4432543b21sm9082802ejc.198.2024.03.08.02.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 02:16:29 -0800 (PST) From: Thomas Schwinge To: Andrew Stubbs , gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Tobias Burnus Subject: GCN: The original meaning of 'GCN_SUPPRESS_HOST_FALLBACK' isn't applicable (non-shared memory system) (was: GCN: Even with 'GCN_SUPPRESS_HOST_FALLBACK' set, failure to 'init_hsa_runtime_functions' is not fatal) In-Reply-To: <87cys66u49.fsf@euler.schwinge.ddns.net> References: <8c5112624e3cd17dd478d0ca5a59b2d24d1b16a5.1573560401.git.ams@codesourcery.com> <87y1aue0vd.fsf@euler.schwinge.ddns.net> <87cys66u49.fsf@euler.schwinge.ddns.net> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/29.1 (x86_64-pc-linux-gnu) Date: Fri, 08 Mar 2024 11:16:27 +0100 Message-ID: <877cid6nb8.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 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+patchwork=sourceware.org@gcc.gnu.org Hi! So, attached here is now a different patch "GCN: The original meaning of 'GCN_SUPPRESS_HOST_FALLBACK' isn't applicable (non-shared memory system)", that takes a different approach re clarifying the two orthogonal aspects that the 'GCN_SUPPRESS_HOST_FALLBACK' environment variable controls: (a) the *original* meaning via 'HSA_SUPPRESS_HOST_FALLBACK', and (b) the *additional*/*new* meaning to report as fatal certain errors during device probing. As you requested, (b) remains as it is (with just the diagnostic message clarified). Re (a): On 2024-03-07T14:37:10+0100, I wrote: > On 2024-03-07T12:43:07+0100, Tobias Burnus wrote: >> Thomas Schwinge wrote: >>> [...] libgomp GCN plugin 'GCN_SUPPRESS_HOST_FALLBACK' [...] >>> >>> [...] originates in the libgomp HSA plugin, where the idea was -- in my >>> understanding -- that you wouldn't have device code available for all >>> 'fn_ptr's, and in that case transparently (shared-memory system!) do >>> host-fallback execution. Or, with 'GCN_SUPPRESS_HOST_FALLBACK' set, >>> you'd get those diagnosed. >>> >>> This has then been copied into the libgomp GCN plugin (see above). >>> However, is it really still applicable there; don't we assume that we're >>> generating device code for all relevant functions? > And, one step back: how is (the original meaning of) > 'suppress_host_fallback = false' even supposed to work on non-shared > memory systems as currently implemented by the libgomp GCN plugin? > [...] this whole concept of dynamic plugin-level > host-fallback execution being in conflict with our current non-shared > memory system configurations? I therefore suggest to get rid of (a). OK to push? Grüße Thomas From 2a188021ca70fc1956ba78707fdec9dcca4f734d Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 7 Mar 2024 15:51:54 +0100 Subject: [PATCH] GCN: The original meaning of 'GCN_SUPPRESS_HOST_FALLBACK' isn't applicable (non-shared memory system) 'GCN_SUPPRESS_HOST_FALLBACK' originated as 'HSA_SUPPRESS_HOST_FALLBACK' in the libgomp HSA plugin, where the idea was -- in my understanding -- that you wouldn't have device code available for all functions that may be called, and in that case transparently (shared memory system!) do host-fallback execution. Or, with 'HSA_SUPPRESS_HOST_FALLBACK' set, you'd get those diagnosed. This has then been copied into the libgomp GCN plugin as 'GCN_SUPPRESS_HOST_FALLBACK'. However, the original meaning isn't applicable for the libgomp GCN plugin anymore: we assume that we're generating device code for all relevant functions, and we're implementing a non-shared memory system, where we cannot transparently do host-fallback execution for individual functions. However, 'GCN_SUPPRESS_HOST_FALLBACK' has gained an additional meaning, to enforce a fatal error in case that 'libhsa-runtime64.so.1' can't be dynamically loaded; keep that meaning. libgomp/ * plugin/plugin-gcn.c (GOMP_OFFLOAD_can_run): Don't consider 'GCN_SUPPRESS_HOST_FALLBACK' anymore (assume always-'true'). (init_hsa_context): Adjust 'GCN_SUPPRESS_HOST_FALLBACK' error message. --- libgomp/plugin/plugin-gcn.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index 4b7ab5e83c5..7e141a85f31 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -1524,9 +1524,11 @@ init_hsa_context (void) init_environment_variables (); if (!init_hsa_runtime_functions ()) { - GCN_WARNING ("Run-time could not be dynamically opened\n"); + const char *msg = "Run-time could not be dynamically opened"; if (suppress_host_fallback) - GOMP_PLUGIN_fatal ("GCN host fallback has been suppressed"); + GOMP_PLUGIN_fatal ("%s\n", msg); + else + GCN_WARNING ("%s\n", msg); return false; } status = hsa_fns.hsa_init_fn (); @@ -3855,15 +3857,9 @@ GOMP_OFFLOAD_can_run (void *fn_ptr) init_kernel (kernel); if (kernel->initialization_failed) - goto failure; + GOMP_PLUGIN_fatal ("kernel initialization failed"); return true; - -failure: - if (suppress_host_fallback) - GOMP_PLUGIN_fatal ("GCN host fallback has been suppressed"); - GCN_WARNING ("GCN target cannot be launched, doing a host fallback\n"); - return false; } /* Allocate memory on device N. */ -- 2.34.1