From patchwork Fri Jan 26 10:30:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1891239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jDjpRN/K; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=DSU1RbTV; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jDjpRN/K; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=DSU1RbTV; dkim-atps=neutral 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=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TLvC2628pz23f9 for ; Fri, 26 Jan 2024 21:32:14 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D614D3858001 for ; Fri, 26 Jan 2024 10:32:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 08F543858299 for ; Fri, 26 Jan 2024 10:31:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08F543858299 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 08F543858299 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706265107; cv=none; b=oOl/VSeX9ZcVm8bPEh6IkjTPt7TMUanPK8TvWzWr/EuiBKF2+WAEaXEHEadNibnaF7Jrg9i2qKZItA4R9lGovbz8VQOF5hpsTsGcvxfEFCCYX5y9Ab7FgBpNK2wEumSNVFhOzCCLYvNxpyVAwKlPnJmVmRjlAgW0wKB/oCmrETQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706265107; c=relaxed/simple; bh=jezppkIh29jDSs9COPt12u52TIDLNP5jGIlZpUX9jw4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=QzqLBiXNPdsMpAHw5gLaAFOPWKHoshFW3cWWvzpFW5qyWUIhklvAymGImTuy+ycHVwzP8wA1UEXuqjWhLx9H/sQ3xvnOdNpEl4YQXyTA4dzcOG097gbcQU4Q/MrTtk0VsX1tcwccEAshrPVLj1sVXYsAj61tYM/zCq7a8tJuaCk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 201611FD38; Fri, 26 Jan 2024 10:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706265105; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=P+jfLADDL+H0JMotYnOL8rDwGK2ffzTmJQ8c0plfqqs=; b=jDjpRN/Ky9iLW4GtB12enzmzISBlAIQk2TvlNJ4NjNB3D74hw9lv/e/DosKWvqXd3ZzoGU IyRLIVaWBW/J1C+r2HPn0lxYBzKQEYPscspPLK3y7EgEYkm6Z4k8aFFlD+amScPeLSgyI2 qG61Me3MIQqR4hoIMtJ4F5l2uao0vaY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706265105; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=P+jfLADDL+H0JMotYnOL8rDwGK2ffzTmJQ8c0plfqqs=; b=DSU1RbTVnrH1xblSCIazdsOj9PNI2Jqg5xY0fh33k+B5M0ATSSY9OI8BeAc9yCPqstqIGI kR75WCV3UggPH4DA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706265105; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=P+jfLADDL+H0JMotYnOL8rDwGK2ffzTmJQ8c0plfqqs=; b=jDjpRN/Ky9iLW4GtB12enzmzISBlAIQk2TvlNJ4NjNB3D74hw9lv/e/DosKWvqXd3ZzoGU IyRLIVaWBW/J1C+r2HPn0lxYBzKQEYPscspPLK3y7EgEYkm6Z4k8aFFlD+amScPeLSgyI2 qG61Me3MIQqR4hoIMtJ4F5l2uao0vaY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706265105; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=P+jfLADDL+H0JMotYnOL8rDwGK2ffzTmJQ8c0plfqqs=; b=DSU1RbTVnrH1xblSCIazdsOj9PNI2Jqg5xY0fh33k+B5M0ATSSY9OI8BeAc9yCPqstqIGI kR75WCV3UggPH4DA== Date: Fri, 26 Jan 2024 11:30:36 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: ams@baylibre.com Subject: [PATCH] Avoid assert for unknown device ISAs in GCN libgomp plugin MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 1.39 X-Spamd-Result: default: False [1.39 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-0.998]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.01)[-0.036]; RCPT_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.01)[45.27%] X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20240126103212.D614D3858001@sourceware.org> When the agent reports a device ISA we don't support avoid hitting an assert, instead report the raw integers as error. I'm not sure whether -1 is special as I didn't figure where that field is initialized. But I guess since agents are not rejected upfront when registering them I might be able to force execution to an unsupported one. An alternative would maybe to change get_agent_info () to return NULL for unsupported ISAs? Tested on x86_64-unknown-linux-gnu -> amdgcn-hsa with gfx1060 OK? Thanks, Richard. libgomp/ * plugin/plugin-gcn.c (isa_matches_agent): Avoid asserting we only get supported device ISAs. Report raw numbers when not. --- libgomp/plugin/plugin-gcn.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index db28781dedb..d8c3907c108 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -2459,13 +2459,15 @@ isa_matches_agent (struct agent_info *agent, Elf64_Ehdr *image) char msg[120]; const char *agent_isa_s = isa_hsa_name (agent->device_isa); const char *agent_isa_gcc_s = isa_gcc_name (agent->device_isa); - assert (agent_isa_s); - assert (agent_isa_gcc_s); - - snprintf (msg, sizeof msg, - "GCN code object ISA '%s' does not match GPU ISA '%s'.\n" - "Try to recompile with '-foffload-options=-march=%s'.\n", - isa_s, agent_isa_s, agent_isa_gcc_s); + if (agent_isa_s && agent_isa_gcc_s) + snprintf (msg, sizeof msg, + "GCN code object ISA '%s' does not match GPU ISA '%s'.\n" + "Try to recompile with '-foffload-options=-march=%s'.\n", + isa_s, agent_isa_s, agent_isa_gcc_s); + else + snprintf (msg, sizeof msg, + "GCN code object ISA '%s' (%d) does not match GPU ISA %d.\n", + isa_s, isa_field, agent->device_isa); hsa_error (msg, HSA_STATUS_ERROR); return false;