From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) by sourceware.org (Postfix) with ESMTPS id 5F777385840C for ; Thu, 9 Feb 2023 11:26:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F777385840C Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O1wZ9gnz6aqB4cjQJKQp/KzOTcDtDctq0MiFG4GPaQG97vB1Ndrnyvcq9uOxXrPFCLbZLb72XykBH0AC+FL0w9E0nBLX0Xrkl4LgtJr2hbVP7gNn+ZBNAUzLyLRqrLB4b49IIPEEOJnjOZ6FWNKq9I4+YcjxuSMUHwd/CCNaon7FD9AF1vSxrKLsVTjZAcFJS2Yjaz0iJYPNmm3AmIlXQ8KuLEmAUKYgfIGg3a6qvWz7xG2vlr8S9/zwy0sgMQ8LxGarUEBr8jYCiz08pOf0lO+kgUGgcWD/Nuq/vDPGir6Q4c47FoHi7le36ISPmmkjeZSG5aHSXbn1wy5nKHu9Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=475aSExXxF7McgW7XYg5Irg5GR/rqsObNUyqs38BaB0=; b=munc0KvdHytbFR01DaZ/FL06G+z2zDFCSAYbfSUxTYqcIE95RrBjaLmo2snqXYle9nGBo8jznQyCPQ8Q7W3GhojMTy8lHQA828KBE5vogJo28EpnVUIu1bnfbGM9SLwrABEFRttPoVrxjjV7TZLdR9XCOGBGFTiloPzTnBy/jDFfYoV1Z80RraT+BJNCbpWUMfObgoo3VCKNFuCxLpf6dGWCk+XTc3KWO5oJ92o+hQohMAqLk/JIzJuM/s5fm9drHQ/hUBrg5uhbLyiAV+upr27FtCtsd+UydH+U4ovEc1vtot4VsgAo6viljLhhhYPWlX9Xb4+wyBXX8TnXnwxdKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=475aSExXxF7McgW7XYg5Irg5GR/rqsObNUyqs38BaB0=; b=N0rgtD3pcRfHsM1SuOa+BnyuIx7TGNqNaxoFUoPab3L/7FBG8HMKt820I4XCpQtWsdGbfq3cK/AhdIJQcjZ4iLS0RMSTI3l99vtfL8XK1NBxSf2YFyKyZ0j2u6p9Jg1GeqNsRxe93Rb7q1KyO7GbN8sNSJww55WM1DPq96rxGUU= Received: from BLAPR03CA0126.namprd03.prod.outlook.com (2603:10b6:208:32e::11) by MN2PR12MB4534.namprd12.prod.outlook.com (2603:10b6:208:24f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Thu, 9 Feb 2023 11:26:37 +0000 Received: from BL02EPF00010208.namprd05.prod.outlook.com (2603:10b6:208:32e:cafe::d) by BLAPR03CA0126.outlook.office365.com (2603:10b6:208:32e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Thu, 9 Feb 2023 11:26:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF00010208.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6064.21 via Frontend Transport; Thu, 9 Feb 2023 11:26:36 +0000 Received: from khazad-dum.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 9 Feb 2023 05:26:35 -0600 From: Lancelot SIX To: CC: , Lancelot SIX Subject: [PATCH v2 4/5] gdb/testsuite: allow_hipcc_tests tests the hipcc compiler Date: Thu, 9 Feb 2023 11:26:12 +0000 Message-ID: <20230209112613.922098-5-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209112613.922098-1-lancelot.six@amd.com> References: <20230209112613.922098-1-lancelot.six@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00010208:EE_|MN2PR12MB4534:EE_ X-MS-Office365-Filtering-Correlation-Id: e59a7d33-5cf3-4aea-f009-08db0a9081a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HPAsULmCrH3+KYVbtuw2BdZFLtcRcN1nsZSjgKaf3SLs9taE+f20vlmy45n8oI0C1Mp9uS06icPCkWDHeHV72LaT9PqngK7n6ITUl29JfanfAY9AUDKC4zacvDlrKf0N2VCXPSobUnh2fokgCRFln1OFHwtNbN0TwN9S39lf6cuG451Fr7hBDg0sdfj8s0NekfdpcqiC5MsNFdgOOMKvlYVLr6RP1HvG6s6PVl60+IeVWoPeeI/+ykS5yGmxW+z2i63TgjHRMihtFFzn8hFHf17qjlLJzm8LvgUh2kh8r7TWOO6MMh0FAqUgUEJ7BTpYXKWsGjb/M1rwYngPm8sp8ta5qaLHGwIB8gMH8Ha4QqfI5XCNKWOZ1ZB6EbMtVQ2jqRg9z0A5wE5Whun7IBk2wewDy3Tp1uXuZHv0TjD9CBA92lLT7Pbg37k7V92nWmsHIBI8DlptngQiM3KVZtK9ztSrS+keVdYjzhqfHnsoeDEZ5UiiRYQ4u+lPHmdXZD9VaR6hXIBJbQ9V+coxdJKn0znvmVtNT5MvHdxOebCPO4GbgGYALhXjUmmbk0F1VKeioyPDdHoEeBrKgQWJZMBYqhmcGbIOppXnhXA/r6EPP+WkbW6lpFP58wwoI/DnC718vH3WS/iTpnyNNrHItyNr8naDzo4OkLyzept0AKpQOqpVvsCL5RKq4pqlKoMk3Yk5MO8pH0vvCE7t9PHIk5ul6GRtmu6rw/lqOU0BxEPDNG0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199018)(36840700001)(46966006)(40470700004)(478600001)(36860700001)(70586007)(40480700001)(54906003)(70206006)(82310400005)(316002)(2906002)(356005)(5660300002)(8936002)(40460700003)(26005)(4326008)(41300700001)(86362001)(8676002)(1076003)(6916009)(6666004)(186003)(16526019)(7696005)(81166007)(82740400003)(36756003)(47076005)(426003)(83380400001)(2616005)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2023 11:26:36.9645 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e59a7d33-5cf3-4aea-f009-08db0a9081a8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00010208.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4534 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Update allow_hipcc_tests so all gdb.rocm tests are skipped if we do not have a working hipcc compiler available. To achieve this, adjust gdb_simple_compile to ensure that the hip program is saved in a ".cpp" file before calling hipcc otherwise compilation will fail. One thing to note is that it is possible to have a hipcc installed with a CUDA backend. Compiling with this back-end will successfully result in an application, but GDB cannot debug it (at least for the offload part). In the context of the gdb.rocm tests, we want to detect such situation where gdb_simple_compile would give a false positive. To achieve this, this patch checks that there is at least one AMDGPU device available and that hipcc can compile for this or those targets. Detecting the device is done using the rocm_agent_enumerator tool which is installed with the all ROCm installations (it is used by hipcc to detect identify targets if this is not specified on the comand line). This patch also makes the allow_hipcc_tests proc a cached proc. --- gdb/testsuite/lib/gdb.exp | 4 +++ gdb/testsuite/lib/rocm.exp | 69 +++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index faa0ac05a9a..6333728f71e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4581,6 +4581,10 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj} set ext "go" break } + if { "$flag" eq "hip" } { + set ext "cpp" + break + } } set src [standard_temp_file $name-[pid].$ext] set obj [standard_temp_file $name-[pid].$postfix] diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp index a78b9f63353..125fa000170 100644 --- a/gdb/testsuite/lib/rocm.exp +++ b/gdb/testsuite/lib/rocm.exp @@ -15,7 +15,51 @@ # # Support library for testing ROCm (AMD GPU) GDB features. -proc allow_hipcc_tests { } { +# Get the list of gpu targets to compile for. +# +# If HCC_AMDGPU_TARGET is set in the environment, use it. Otherwise, +# try reading it from the system using the rocm_agent_enumerator +# utility. + +proc hcc_amdgpu_targets {} { + # Look for HCC_AMDGPU_TARGET (same env var hipcc uses). If + # that fails, try using rocm_agent_enumerator (again, same as + # hipcc does). + if {[info exists ::env(HCC_AMDGPU_TARGET)]} { + return [split $::env(HCC_AMDGPU_TARGET) ","] + } + + set rocm_agent_enumerator "rocm_agent_enumerator" + + # If available, use ROCM_PATH to locate rocm_agent_enumerator. + if { [info exists ::env(ROCM_PATH)] } { + set rocm_agent_enumerator \ + "$::env(ROCM_PATH)/bin/rocm_agent_enumerator" + } + + # If we fail to locate the rocm_agent_enumerator, just return an empty + # list of targets and let the caller decide if this should be an error. + if { [which $rocm_agent_enumerator] == 0 } { + return [list] + } + + set result [remote_exec host $rocm_agent_enumerator] + if { [lindex $result 0] != 0 } { + error "rocm_agent_enumerator failed" + } + + set targets [list] + foreach target [lindex $result 1] { + # Ignore gfx000 which is the host CPU. + if { $target ne "gfx000" } { + lappend targets $target + } + } + + return $targets +} + +gdb_caching_proc allow_hipcc_tests { # Only the native target supports ROCm debugging. E.g., when # testing against GDBserver, there's no point in running the ROCm # tests. @@ -29,6 +73,29 @@ proc allow_hipcc_tests { } { return 0 } + # Check we have a working hipcc compiler available. + set targets [hcc_amdgpu_targets] + if { [llength $targets] == 0} { + return 0 + } + + set flags [list hip additional_flags=--offload-arch=[join $targets ","]] + if {![gdb_simple_compile hipprobe { + #include + __global__ void + kern () {} + + int + main () + { + kern<<<1, 1>>> (); + hipDeviceSynchronize (); + return 0; + } + } executable $flags]} { + return 0 + } + return 1 } -- 2.34.1