From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by sourceware.org (Postfix) with ESMTPS id 06C683858D33 for ; Tue, 7 Feb 2023 13:42:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06C683858D33 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=S5Ynup55ehMKUW8/8ffZhMN6bE2wce9rog/9TLNKR6s7Vcc9GV4td8sAC/cp9KhAWKq7+/rlf9j4NcPFjuonq0UObNk7mwOlw8GSKlXL/GBaAui6sbMa+2kDYpYv7lxg7qgd0GUVT1Tzgj0lHQu0dSLmOkbQp8z1ZzrhJsYo6BE/MQqbFjhWG4qqri85AY9qDOYW51Uh8gwkRmv5U6h7wuIYNLkMwbiBEiyaxOyoNKoneTRefSuyCBpE4j0DU+nbOYeb5cZhJTEhl7uojxRMdhxulvOCx5GJKP5dqYX6weJchOOvZUxww3Ds8je0TZY7H0TK40EBKu+uejZR66MlIg== 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=YgH9v6HfUuuEHFbi7mDoOijEVLIIUTf9/1dIuRQmafU=; b=niv3d4HX9wFeq0y4IrGzBOh2XqBuLZKG7DIHBgnj/fu3OIL1/s1nOjYr8aS1mGd2LfW9unoDc+D0q3GHUwBpWYVksMlTuY/ZL6sargKsxQ26D+ep6ZEoR1AEFTlTW+a8iJJkzUhrEy66xtTxwCjMvJwablFU5qvReju5plxGqSv+Enzo6Khir6tQSHvQb2F5/5uG2QdPqKEhFcvqze0FV7iS5syVBv/7CSIRQhbLjON5TeJoSEUAaxYutgfV6GCGqpIF2snZPEXq785cv4D14JHXDksGkyF0euAxujPOnm1FMH7AhsXUoDeYmqPLWpNfwuQlgrol9tft6wEVPFtxww== 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=YgH9v6HfUuuEHFbi7mDoOijEVLIIUTf9/1dIuRQmafU=; b=HM4/O+d9v0m9JGFAC6y1ShmvUTcBWbFWEvJauUNcLjn33bw0HCnLFpCKS8SnPXynXnnsujQRA2L9SWBVer2VkRxTgQr1a4VfLtC0qMUzz3LmzCcXuuU9KNjwmVIjcOjP8RTUi1stMHCGxEudVBQCGPJTNLhdQ1ndtfrGJ7nG/fA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5745.namprd12.prod.outlook.com (2603:10b6:8:5c::7) by CY5PR12MB6060.namprd12.prod.outlook.com (2603:10b6:930:2b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:42:18 +0000 Received: from DM4PR12MB5745.namprd12.prod.outlook.com ([fe80::cc16:a119:c3cf:5236]) by DM4PR12MB5745.namprd12.prod.outlook.com ([fe80::cc16:a119:c3cf:5236%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:42:17 +0000 Message-ID: Date: Tue, 7 Feb 2023 13:42:03 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 4/4] gdb/testsuite: allow_hipcc_tests tests the hipcc compiler Content-Language: en-US To: gdb-patches@sourceware.org Cc: lsix@lancelotsix.com, Pedro Alves References: <20230207132802.223510-1-lancelot.six@amd.com> <20230207132802.223510-5-lancelot.six@amd.com> From: Lancelot SIX In-Reply-To: <20230207132802.223510-5-lancelot.six@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0136.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::10) To DM4PR12MB5745.namprd12.prod.outlook.com (2603:10b6:8:5c::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5745:EE_|CY5PR12MB6060:EE_ X-MS-Office365-Filtering-Correlation-Id: a9a445ca-546a-42c6-b9ba-08db0911210d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qik1wI5e0RYD5vVd5NUo14a5JO8r4IDG54bkMyUhN+7DbzqzhB4I7d3W7UnCdn3VY/QPkMOcys758lICxtPofMzBtNVTewr9GXAg4sKBLGRSk/Ysgwk59g3Va5SZDv3LIQaz6Ro+sYmnZ5SSZD/wi2kRG4nMyKUJArzykeY0tD6g7U49oLHjNdzvAu9nUctwS+M8NdK+RmP4MpOioH+GY/E9UJ5DcLgsSMLeVRo0u9BMIPBEIZf1+0nrFKzPCFvBwll2bdcVyHmsHu+i0E/9FHta4+Q9iNa9zFcjfG7crrmCkMQx86eEWnQF06hxuzc7NKXYEK2RFT8nJDNEyxSPJAwmDTl4Aid6UeOM2ocR7KC+NtplS03NsHUbJ3b93sKU2oSPYUkCwZrhLZbovylAPdTmyDJC6sroyMmzyWP/kqaavcQpIB/6aX1opw770TFIMolWh+ldOiuvwYIFMri8ZuaC6mpMn9zDPEFMI6zP3/rdmnsJDJFJU6LfULPPL6GUL1sKPqdCsVRAvVPzhlziQqhY9JhKWHG3a1wdaMnSXCu95xHkoXfwSYmjEhIauVwLdUslJBpT8oq1u08d9LmIuBVDu+JKmxpBJXre9i1tFEr5M0OfoG6rNMv+WFVLV/dTDI3OKlULH76tpBvlZJuKyPbWN2x5E9xaD5jb9iKA6W3l7Pa9ZaIg4AmiOy+6vboPavZpjVg5VhNcWbByBgWiObcpG8HnWuGXo4haDoztdC7QGIQ4+4wscx6819/cHgyBKHfwnqS3wGqbV32dXZquBA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5745.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199018)(5660300002)(41300700001)(2906002)(66476007)(66556008)(66946007)(316002)(8936002)(966005)(6486002)(478600001)(6506007)(6666004)(26005)(186003)(53546011)(6512007)(2616005)(31686004)(6916009)(4326008)(8676002)(38100700002)(86362001)(31696002)(36756003)(83380400001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WHFYb28rT04rbUJuY29DSnpnRGkwSFhpWm1WdkhkQ0hjSjEyTW4ycWQzcTBt?= =?utf-8?B?UlB5eU5UN2duV1ZQVndoTmRMNGZXeHZWQml1RWhsVW12ODl4UHA1NFMwalJU?= =?utf-8?B?VEZKOVBVbmFuSHFrQnMzV1Y2eVh1ZitQUFAvZGJOOXNKeFR6YXRkSkJsTzNO?= =?utf-8?B?bkJCRkZKY3hLNFlERkNqT2dzdEwxZlRHa2RPNEZBdmlTcHhkOGM2NTVHazBG?= =?utf-8?B?Vy9MdDg5K0RQVFpDRVFscTYvWERyTW9RcEhVSWF1WEE5bVdkRzhvTnJyeTNJ?= =?utf-8?B?aDcrVm5HbVNnb3NJeU96Q2tSTmV0N3F5UVVFU2pvWDgxYk9NbUFhVXFjcE9i?= =?utf-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oi3B3?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9a445ca-546a-42c6-b9ba-08db0911210d X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5745.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:42:17.8260 (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: gTTnxi7bj97rRYRxkqtP+HNWX+GUsFCePcO1HVdQepKEnU2ou5yVp7n9yC9TwVtBNxRP4ENa0OLXqrmu3dyU+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6060 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,NICE_REPLY_A,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: Hi, Some of this patch is based on original work from Pedro in https://github.com/ROCm-Developer-Tools/ROCgdb/commit/031a44b9c6ec2c381030a919b837e5dfc255e688. I just realized that I forgot to give credit where due. I'll add the following tag: Co-Authored-By: Pedro Alves Best, Laneclot. On 07/02/2023 13:28, Lancelot SIX wrote: > 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 b5b59748c27..06d5b3988b8 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 > } >