From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mfgbEr85RWoVVyEAWB0awg (envelope-from ) for ; Wed, 01 Jul 2026 12:01:03 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=TH1m+nc1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 433C01E024; Wed, 01 Jul 2026 12:01:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 35A491E024 for ; Wed, 01 Jul 2026 12:01:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3038C4BA23D7 for ; Wed, 1 Jul 2026 16:01:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3038C4BA23D7 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=TH1m+nc1 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azlp170100005.outbound.protection.outlook.com [IPv6:2a01:111:f403:c005::5]) by sourceware.org (Postfix) with ESMTPS id D1E124BA540B for ; Wed, 1 Jul 2026 16:00:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1E124BA540B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D1E124BA540B Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c005::5 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1782921634; cv=pass; b=Zj4+0YyVmQ7XR3Y1uGCSql/NsjcUwlMvXQhYD9DPLQVSi+TN8P4yqoorP+ddu5p51+Ah3Y0bh/ObvvguksHBQMqMolUkGfMPMBqQ8FMP7KuEztUHFzIR6AQGmVXJZDV3zu51BMWqeZskTEeRbQDBQr8IR+0d/MtDefW7+aKDVng= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1782921634; c=relaxed/simple; bh=+6UFVjHAP4GXhPJZ4dzDAUs0nVwyhnw+s0SugaFGTxo=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=I0cqJMOv3oHcnoHHZTnadshFsO7SUFgBxvBewqUdIJJSuEXHtNDT9Z7hvogyJCiyDqczw6xCg3QGrLg/GNhZ3u0XKxG8W4qE4yaJdafFVsHAUpe5mAYGCrwbyy0kjXeof3cEQ9rTNo5ai6Rtf4FZdWrqeklWkj0ZNubYt6t55tY= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=TH1m+nc1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1E124BA540B ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kNOdxZI7iS8Nm4Hw1XP+L8iCWa+fIXnPPly5Wjzaj4aAiAE9R0qPhT6bn8J4oEYmsbOqriN4c8vP8PD7wT0K625VeohINIROXnNaNFK4ob5aQ7CKmiYa1QiaFI+c/PlYR/p4ekTZQM4Lq/O7R0lHaEyJnBWZTghFE4zsF2l0c77rT3KaE65soyx14XmNbYcF/dCRm6+fu5rUuP6PDLM+LPy2HZMfMW9nMBSQ3PM+371Zi2QE7fO+orNPHrZa5R2a1bBh5JPkArF8wB+7J/iA5wOkJ5o5sh+/GYalvcf74kCZKyH+nGK+QQmoYyS9cBiSdmkB1jF3dTTjxGedbQI7zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n1IK8DaJvPRws4l2Q5rdIltNKkHsrXqelrtpaeY3S80=; b=yZ4cjURkay4AJI+kqVh7LbFF89A+XxTWo8axMH7EddRw/RGJznQLRncN/UZY3SYb8C+caSBZUok/lttZ/fYL8Qb+XI04AKJXjQiLCmkNQwQzBIXDa3DG3tCn1bJuLRvKPeF/HSTiR8RcNJ0CYDv96kNjSy8d8pbBgX2rID7sHGuGHQVw90mPA+XUCl4tSdqPEziU5hmMTCVdmd/nE+jX+t8Jorr4lBhCT5JHX9uT/ESfKKdvXD/Ltxlzj9rQpeLjoheiQe5S02KZX+Yf276lujwgMCixgncKiDpOIE/1IT0KI8cxAUJzGg+aN+gmn2LUyApq/R/uPX9evEsA40kBeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n1IK8DaJvPRws4l2Q5rdIltNKkHsrXqelrtpaeY3S80=; b=TH1m+nc1YkSpT/a84vCz4QY4OcnrkKIZ7grtTS4yUD9ojxTcOfIbc3ffyAv03s1vUm28JtlPcub33T+vo7L2F8XwLN3mPjysmEMXPhOWKZKcRfFhkGd5W3S6pOVtSmHteVfUiM5ibKcktHIzqUGxhmNpV0NgeuEXuPukeApjebM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) by SA1PR12MB6946.namprd12.prod.outlook.com (2603:10b6:806:24d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.8; Wed, 1 Jul 2026 16:00:27 +0000 Received: from CH3PR12MB9079.namprd12.prod.outlook.com ([fe80::5a7a:2adf:1862:35c3]) by CH3PR12MB9079.namprd12.prod.outlook.com ([fe80::5a7a:2adf:1862:35c3%5]) with mapi id 15.21.0181.008; Wed, 1 Jul 2026 16:00:25 +0000 Message-ID: <0cc2ad49-8ced-4f1b-a236-5f0efff00ddf@amd.com> Date: Wed, 1 Jul 2026 17:00:20 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb/testsuite: deduplicate --offload-arch targets in hcc_amdgpu_targets To: Luis Machado , gdb-patches@sourceware.org References: <20260629135613.2738058-1-luis.machado@amd.com> Content-Language: en-US From: Lancelot SIX In-Reply-To: <20260629135613.2738058-1-luis.machado@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0170.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::18) To CH3PR12MB9079.namprd12.prod.outlook.com (2603:10b6:610:1a1::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB9079:EE_|SA1PR12MB6946:EE_ X-MS-Office365-Filtering-Correlation-Id: 60462d4f-4dff-4fdf-c69c-08ded789dcf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|1800799024|376014|366016|18002099003|22082099003|5023799004|11063799006|6133799003|56012099006; X-Microsoft-Antispam-Message-Info: 5sOUYXy3EeDSsEKMO2Om9G+K6Xgc+L//in8jxM2u5PtgQ9zEC+knwQ6U23XxpHRTBNQtH+efxihZYMQN9eLC0u3mCyBFkHqy+IINiv0xEzNgp7MzxaaaXTM7Skc+4u1bVla4QQemTFLuiugbfyPQpswzWC2SJ07n3Xz51sD+e/bVe/A9Vy7qc6FsL7EdeNgZEcwd0mnhzduZ3mRxymJAWD9QXW+oQKvUbf/4KYy5IscNOLZod79RizmBjRVilXOSLGnWv0ZoMDyAilBf0W24JxJMOQVtCMIX+fXd5DIJZUjXgxBAZ6c46+uurk1Z7B8K9LU0QCMrsH3tB74TnfAYYth1k0juymzLRgpbY/2ee7n+DGHH5miKsZcwty0wfSWyKxBvCgIae2fD6jawNxQ9nDZaKt7my4y6RiZLtcM82JU4cwe2bD55i1nMa/C//0rI9vkZeysBgkeL3rugLt1JbycGEhJtgx8J6+rnOvMIjR7Ig2NqmVhdKGoQ+BjqZacujDjCEXSf9ShUj3WrCcO2ZKvExRqHgive/CLyXXxeKa2IF01vVb2xDHIsh4oB8qz+9XTeVQ5Tk6bIXSEv6+bLs5oNYUq/mtae+m+/gtgZVRs3IxboMNPYO5ToUCQaNIUI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR12MB9079.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(1800799024)(376014)(366016)(18002099003)(22082099003)(5023799004)(11063799006)(6133799003)(56012099006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?clJ6MzhSUVZncW5BLzl1ZHN1cTJrWWR5ekljTnRmYWxtZHNFUXI3eFVBYlhV?= =?utf-8?B?dUtQKzJjUWkxYTc2WjN6OFJVTDBLYmlXUGxh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M?= =?utf-8?B?UFc0ZEhncis1bkMxQk9kS0tYTTRVdXVIMEhNUndzSWhLS0Z0UWNyb3Nnaldy?= =?utf-8?B?UTN1amN3em9sZTdkWnFTcUtHWU1SL0V6TFBxbW1TQlhkS2l0ZXNRMjByVDRk?= =?utf-8?B?akN0V2xuazBDSHUvN0luNHdBd0pmTHkzdTRTZ3lhTFBDR2VBQ1RZZTloQk9u?= =?utf-8?B?VC9pUWVpZERHNy9lSkJZdUNOcmpudVR6NklIYWVqdVhWUU9HYTRyRHlBRVVr?= =?utf-8?B?dThNQmtqL3NmejI3SHdrUHFxZWM0RytnQ1k0K3lsUTIrdVBhcG5DUXUrT0RT?= =?utf-8?B?TzNaOFlnL0l5eFRxK05lMERXc0FLK2VFaTNEdVJuOGhEcW0yRGUrZU9TVGJs?= =?utf-8?B?TndVN0F2ZHlYMnVZa1FLZ2ZFTjJFNk9wdzRTY0cybUNjdzl5YVFmQXcvSHEy?= =?utf-8?Q?W/AsriNmePMSOmlY+N?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60462d4f-4dff-4fdf-c69c-08ded789dcf2 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB9079.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2026 16:00:25.3534 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: L6JUNYNUVxXQzkA08YmVpRGI0YN0f34JSjF4THHeNKki0i6xR0+uSymvwnlH/7V6eMdspJqHoVogDFFuH/UIZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6946 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 29/06/2026 14:56, Luis Machado wrote: > On systems with multiple identical GPUs, find_amdgpu_devices returns one > entry per device, causing hcc_amdgpu_targets to emit redundant > --offload-arch flags when compiling HIP test programs (e.g. eight > --offload-arch=gfx942 flags on an 8-GPU MI300 system). > > Deduplicate the target list in hcc_amdgpu_targets, preserving order, so > each unique architecture appears exactly once regardless of how many > physical devices share it. The same deduplication is applied when the > list comes from the HCC_AMDGPU_TARGET environment variable. An array > is used for the seen-set to give O(1) membership tests. > > Add gdb.rocm/hcc-amdgpu-targets.exp to unit-test the deduplication > logic across both the env-var and device-enumeration code paths, without > requiring a GPU. Hi Luis, This LGTM. Thanks for doing this. Best, Lancelot. Approved-by: Lancelot Six (amdgpu) > --- > gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp | 80 +++++++++++++++++++ > gdb/testsuite/lib/rocm.exp | 20 ++++- > 2 files changed, 97 insertions(+), 3 deletions(-) > create mode 100644 gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp > > diff --git a/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp b/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp > new file mode 100644 > index 00000000000..8f04cca7981 > --- /dev/null > +++ b/gdb/testsuite/gdb.rocm/hcc-amdgpu-targets.exp > @@ -0,0 +1,80 @@ > +# Copyright (C) 2026 Free Software Foundation, Inc. > + > +# This file is part of GDB. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > + > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > + > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# Unit tests for hcc_amdgpu_targets. These exercise the deduplication > +# logic across both the env-var and device-enumeration code paths, and > +# do not require a GPU or a running GDB instance. > + > +load_lib rocm.exp > + > +# Run BODY with find_amdgpu_devices stubbed to return DEVICES, then > +# restore the original proc. > +proc with_stub_devices {devices body} { > + rename find_amdgpu_devices __saved_find_amdgpu_devices > + # tclint-disable-next-line command-args > + proc find_amdgpu_devices {} [list return $devices] > + set code [catch {uplevel 1 $body} result] > + rename find_amdgpu_devices {} > + rename __saved_find_amdgpu_devices find_amdgpu_devices > + return -code $code $result > +} > + > +# Tests using find_amdgpu_devices (no HCC_AMDGPU_TARGET env var). > + > +save_vars { env(HCC_AMDGPU_TARGET) } { > + unset -nocomplain ::env(HCC_AMDGPU_TARGET) > + > + with_stub_devices {gfx942 gfx942 gfx942} { > + set result [hcc_amdgpu_targets] > + verbose -log "hcc_amdgpu_targets: got $result" > + gdb_assert {$result eq {gfx942}} "duplicates removed: 3x gfx942 produces single entry" > + } > + > + with_stub_devices {gfx942 gfx942 gfx1100 gfx1100 gfx942} { > + set result [hcc_amdgpu_targets] > + verbose -log "hcc_amdgpu_targets: got $result" > + gdb_assert {$result eq {gfx942 gfx1100}} "duplicates removed, order preserved: mixed list" > + } > + > + with_stub_devices {gfx906 gfx90a} { > + set result [hcc_amdgpu_targets] > + verbose -log "hcc_amdgpu_targets: got $result" > + gdb_assert {$result eq {gfx906 gfx90a}} "no duplicates: distinct devices unchanged" > + } > + > + with_stub_devices {} { > + set result [hcc_amdgpu_targets] > + verbose -log "hcc_amdgpu_targets: got $result" > + gdb_assert {$result eq {}} "empty device list returned as-is" > + } > +} > + > +# Tests using HCC_AMDGPU_TARGET env var. > + > +save_vars { env(HCC_AMDGPU_TARGET) } { > + set ::env(HCC_AMDGPU_TARGET) "gfx942,gfx942,gfx942" > + set result [hcc_amdgpu_targets] > + verbose -log "hcc_amdgpu_targets: got $result" > + gdb_assert {$result eq {gfx942}} "env var: duplicates removed" > +} > + > +save_vars { env(HCC_AMDGPU_TARGET) } { > + set ::env(HCC_AMDGPU_TARGET) "gfx906,gfx90a,gfx906" > + set result [hcc_amdgpu_targets] > + verbose -log "hcc_amdgpu_targets: got $result" > + gdb_assert {$result eq {gfx906 gfx90a}} "env var: order preserved when deduplicating" > +} > diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp > index 15ee22dad26..ca1ae3f1a8b 100644 > --- a/gdb/testsuite/lib/rocm.exp > +++ b/gdb/testsuite/lib/rocm.exp > @@ -80,20 +80,34 @@ gdb_caching_proc find_amdgpu_devices {} { > return $hip_gpu_devices > } > > -# Get the list of GPU targets to compile for. > +# Get the list of unique GPU targets to compile for. > # > # If HCC_AMDGPU_TARGET is set in the environment, use it. > # Otherwise, consider the devices available on the system. > +# > +# Duplicates are removed so that systems with multiple identical > +# GPUs do not produce redundant --offload-arch flags. > > proc hcc_amdgpu_targets {} { > # First, look for HCC_AMDGPU_TARGET (same env var hipcc uses). > if {[info exists ::env(HCC_AMDGPU_TARGET)]} { > # We don't verify the contents of HCC_AMDGPU_TARGET. > # That's the toolchain's job. > - return [split $::env(HCC_AMDGPU_TARGET) ","] > + set targets [split $::env(HCC_AMDGPU_TARGET) ","] > + } else { > + set targets [find_amdgpu_devices] > } > > - return [find_amdgpu_devices] > + # Remove duplicates while preserving order. > + array set seen {} > + set unique {} > + foreach t $targets { > + if {![info exists seen($t)]} { > + set seen($t) 1 > + lappend unique $t > + } > + } > + return $unique > } > > gdb_caching_proc allow_hipcc_tests {} {