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: 192512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp568517dyb; Fri, 26 Jan 2024 02:32:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyVJevVbrw2Mx/04HnlRGW6XPQqd79wxMCS2tK8frkF1MyoozDLGCaxzdGJ/1PEPhzZsAM X-Received: by 2002:a05:6214:124e:b0:686:9f4d:16aa with SMTP id r14-20020a056214124e00b006869f4d16aamr1352319qvv.82.1706265165897; Fri, 26 Jan 2024 02:32:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706265165; cv=pass; d=google.com; s=arc-20160816; b=M6csSooJ+axGWARabdSy0C2vuxMzaeJBytaoLmMwx/rGNq+xw4revBCmKRsesN4db+ 0vcZEcAjt5gwcviTI2BwkLRQt6LX6bHiGZo7g71ZyGKRZ2zj1S18nnIH6Il3RTd3sELy 8XH1MEug8pTI5Cktz/gfN8+pidK4aBUsMRv3RRP5jlJE7zmgSs5dgRypHtq3YQBt5lQ0 U4HDBPZVKY+c3HRn0MrXYGLXgWzjhORJ3pM1ltf8sIKjIyFNPX0TnIU/UaEJP/zhBcfP K38mgh5fMsVz+QLw9mrrYCdF8B6QoHSk1EOlOTR6PBRV5vCw2hVTat47CfKdawLkLfqG TpHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :subject:cc:to:from:date:dkim-signature:dkim-signature :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=P+jfLADDL+H0JMotYnOL8rDwGK2ffzTmJQ8c0plfqqs=; fh=WafaRBu98zStSTLJ3F2+0jkIRrCdRYw9kz8Gxtj95sk=; b=U2k5H/AQRngFm9+TdCwSZdr0TpzMeQnuQUi7KFP736sJtBLpw25GCiXbt22Jkzg4KO 1t4vzCEr/OxYXsb7h4KdPSm13AsZDA90qLmTSou/Ag34Hzria31NFYPH68DMw6twQh4N 4v+RZ6FjnIyUKAfHQhl3UpUvyr4RhCtCaKBzcNTh+Nx4V0qF3xk/tMhxGPg+KK3g7gHf iJvhLjrXtjgnEfKCVAPBAO3ZSLuSW7+CYTo+A2mBxRP9iQyS2JKd8yswIyK4DlZBfQbB qqxmFciTNKWynOtocljbKCeAm/GyQlo8CiOHpscvCbIMGG4N6ByzEBMwSSrXX0KC5Vaa hYPg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="jDjpRN/K"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="jDjpRN/K"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gu4-20020a056214260400b00681a94d005asi1061193qvb.108.2024.01.26.02.32.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 02:32:45 -0800 (PST) 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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="jDjpRN/K"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="jDjpRN/K"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D575385828D for ; Fri, 26 Jan 2024 10:32:45 +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+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20240126103245.8D575385828D@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789148702692918625 X-GMAIL-MSGID: 1789148702692918625 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;