From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from CAN01-YT3-obe.outbound.protection.outlook.com (mail-yt3can01on2071.outbound.protection.outlook.com [40.107.115.71]) by sourceware.org (Postfix) with ESMTPS id 3DC3B3858C52 for ; Thu, 14 Sep 2023 15:51:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DC3B3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K8pPd4+DFkatmdyoSW6r3tYr1Plhzp/fou+EJUetHdZsPL/xQU62VicwtnlxE2C7e3MJpzHUDt9JobwIPQuf+PT+aX6Qm9NvqlLAKtQMID+XD2JdzQe9g0pzg8ykXogMG3hvfWg4kCUnG+f//maWRiuS/iIfO9yEh7VzprjNg4ZUmcSSgwmhywrnyCjEA/u3Vo67drYMcHga7I2wrl3WS1MhX4cZspkI06zz18Hv5MlF/o1nLPTLaHxl0E/2MDQywunGZOXIsrvnwDqj+cOtn9oI/AaiUhbcTVtldMnMkF06EAKg+f5EgbPzmOFgStIBVwIYNPvcCX+Nj4R2ydvcDw== 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=xhyYz0zuHY/ECX+x1173Cs+7ntSKxVX9029T/FLsEcY=; b=hiTVLaojuyDTqpSaVSk+PeajA5qa8ssUS4TklOYcA+kS5kyi5xdYKkzGgZj0ixS2Ozg5HJY9Rd8XiA8aHS8n+OU0aqqnyXUgsnzp6o3f1tDEA65WNKc3WYXdkfYekwETz5d+MfqsYEHXbTYtE+7xgblaYxqo08naFtpDeTNzO5eY3mxMqvwV9+J4WDcgI3/LKLWbxibncDUGXsInsSbtCkqWjywdxv/nHbjjejZYENv7yvtrtglae5CYXcU7LXFJsjTVhgouxttvQy1Qn0olS5e3yYTT83rJ/dSPHfRluqWhm2NyeOPNGVYMeUrCkFGZAbh9Oiik4zLOkdAb8iYpdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=efficios.com; dmarc=pass action=none header.from=efficios.com; dkim=pass header.d=efficios.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xhyYz0zuHY/ECX+x1173Cs+7ntSKxVX9029T/FLsEcY=; b=qT3R2t2Nt8RnkQvLiPj4cFYwETGVYY040nD3CkM8mcJHceY0miGNBYcJPPEYepO2ieoZJ9LyURNlUCLo/RDVKaJJRSqSrO516qc6hskxkcVeZ63FzAxHcB2rAHZ/Zf7EX0e5ZfhTQOIYLx7niErzr64s2u9E+KLzpERTyRgy73EW796wS/+rCVuc2kHAV+N5Z7KnhAtmwEGN0yJXHbe1ui0gdWut0tP4JdWDEUEImPVwlKkAYWtgbeaQHVLbLKXc0nJgBpQIpIYOzONIFIrVoPoGPG4lrhNokaWG20NgnuNhHEwhRgePAec1yU59xqNSxbI+mKo/1qsvQO7/+Di1nw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=efficios.com; Received: from YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:a::23) by YQXPR01MB5539.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:2e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Thu, 14 Sep 2023 15:51:43 +0000 Received: from YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM ([fe80::a015:84e9:f0da:66ec]) by YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM ([fe80::a015:84e9:f0da:66ec%4]) with mapi id 15.20.6792.020; Thu, 14 Sep 2023 15:51:43 +0000 Message-ID: <1dbadcb5-908a-41b4-b951-90e795386764@efficios.com> Date: Thu, 14 Sep 2023 11:51:41 -0400 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] gdb/amdgpu: add precise-memory support To: Lancelot SIX Cc: gdb-patches@sourceware.org References: <20230913152845.1540064-1-simon.marchi@efficios.com> <20230913152845.1540064-2-simon.marchi@efficios.com> <20230913213250.cwgwrowfrawelfac@octopus> Content-Language: fr From: Simon Marchi In-Reply-To: <20230913213250.cwgwrowfrawelfac@octopus> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: YQBPR0101CA0082.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:4::15) To YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:a::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YT1PR01MB2828:EE_|YQXPR01MB5539:EE_ X-MS-Office365-Filtering-Correlation-Id: cb3afa3b-5bd8-4ecc-9b3d-08dbb53a7df9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HyrJ2SpVN8A07jKTbW/KUAKDOSGDnb/mNTv2N+F8U7JEr7GliAlXNS5+EOAuZZP+TbKrqTVR9RHVCP6bGZZSeXW5BPzwvphpVDqwNPsHnvjC+UqIbGPASjn72X+BDiQ35XBj3Ykl/pCBfgEnHDZRdvxoqgxxF2D5sAH+KJOkGK210l9P/HXmC9nkw///ldziGkqTqa1HBuVbehiVkVZVwS450FPjPhUu3LWiOaOJDJ0zxu/3lOnPu9MNBOvY5W/oUYd3xQVqD6hfQX/6CbVDq5llvcvWk5Ax5D66d/iAle7xrjCH5MwIpjsQTiWWGdpJVDmQ7mgN7LM7uVBwBWV2rPYnA+stNV14z/xj9aEPRunsOdg00E123N7ZckMNLJJtgwdDKXKZAaplJr9oqCSz+bpTC+VfgL0Xtw9kDJBKrMG1prsOUo5rfQAL6lrWXEZJIC8WjS61u0HSN1jAKthj5KEByWEJqy789eymrpE8U5ImCol4jJ1XFW4a4nsML2CAORrJv0hz9GVZCmX0XCotZ0KDWxfSbZ618sZErhR4R/uFsuvrYjIO4y49QvT+JDoQ38lIII3CV6XrbeEJ6EMPgwQDnZDHVoETTuJtDauMQaBGfqfv1PO9IJlv2xZUMu5gwiwsw4yULiVHDLJdbP5Lzw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(396003)(136003)(366004)(39830400003)(451199024)(186009)(1800799009)(66556008)(66476007)(4326008)(66946007)(41300700001)(31696002)(316002)(8676002)(31686004)(8936002)(6916009)(5660300002)(83380400001)(36756003)(38100700002)(478600001)(26005)(44832011)(2906002)(2616005)(6512007)(6486002)(6506007)(2004002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?R3drdUEwVDRXTzF0M3NBMWFnY0FwT3Q4aGhIRWY5SVk1bDc2UVBVbWFuMUJL?= =?utf-8?B?andwZVVlVGgvZmg5U21vdmdwZVJqNFBWQVN1Z1NHQnFvMlFMWnNvTURlb3l6?= =?utf-8?B?VXZBUkpDS0VDRlNvcGRxWmpVL0hmbmhhS1BLalZwbEpadjdsYUlXb1dlWUtz?= =?utf-8?B?MnY0cFJtQzVpZG90VG1rZlJPL3J1dE5YZHI2R3VidzNvaTk0a0l5dXNndXdu?= =?utf-8?B?UnVTQXFkMDVNZ0phNmtFZTZUUGNzbm9ycjlYbVFzbkJNNXg1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Iy?= =?utf-8?B?M0RZYU4xZ2NVZkhMQzFsQmtVYVBNbzhZM3FmYTZxYUQ1ekV6UFJzTzZNbEZG?= =?utf-8?Q?XgZKoMDBLlK3WxlfAXBcL8DEt?= X-OriginatorOrg: efficios.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb3afa3b-5bd8-4ecc-9b3d-08dbb53a7df9 X-MS-Exchange-CrossTenant-AuthSource: YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2023 15:51:43.4695 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f278736-4ab6-415c-957e-1f55336bd31e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Oe3vMAHaxxZ7tzrNQl9C3vtduStIUk8J2s5x9VnD3McbA9a9IlWkDDGVV9/czLqckKSTvCfC98uSnaQR57rPaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQXPR01MB5539 X-Spam-Status: No, score=-3038.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,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: >> @@ -1326,6 +1338,36 @@ amd_dbgapi_target::stopped_by_hw_breakpoint () >> return false; >> } >> >> +/* Set the process's memory access reporting precision. >> + >> + The precision can be ::AMD_DBGAPI_MEMORY_PRECISION_PRECISE (waves wait for >> + memory instructions to complete before executing further instructions), or >> + ::AMD_DBGAPI_MEMORY_PRECISION_NONE (memory instructions execute normally). >> + >> + Returns true if the precision is supported by the architecture of all agents >> + in the process, or false if at least one agent does not support the >> + requested precision. >> + >> + An error is thrown if setting the precision results in a status other than >> + ::AMD_DBGAPI_STATUS_SUCCESS or ::AMD_DBGAPI_STATUS_ERROR_NOT_SUPPORTED. */ >> + > > Would it be simpler if this helper function received a bool parameter > instead of the amd_dbgapi_memory_precision_t one? This could avoid > repeating this > > amd_dbgapi_memory_precision_t memory_precision > = (info->precise_memory.requested > ? AMD_DBGAPI_MEMORY_PRECISION_PRECISE > : AMD_DBGAPI_MEMORY_PRECISION_NONE); > > before calling it. Indeed. In fact, we can factor out more... I came up with: static void try_set_process_memory_precision (amd_dbgapi_inferior_info &info) { auto mode = (info.precise_memory.requested ? AMD_DBGAPI_MEMORY_PRECISION_PRECISE : AMD_DBGAPI_MEMORY_PRECISION_NONE); amd_dbgapi_status_t status = amd_dbgapi_set_memory_precision (info.process_id, mode); if (status == AMD_DBGAPI_STATUS_ERROR_NOT_SUPPORTED) warning (_("AMDGPU precise memory access reporting could not be enabled.")); else if (status != AMD_DBGAPI_STATUS_SUCCESS) error (_("amd_dbgapi_set_memory_precision failed (%s)"), get_status_string (status)); } ... such that callers just need to do: try_set_process_memory_precision (*info); I'll put that in v2, unless you think it's a bad idea. >> @@ -1785,6 +1873,29 @@ amd_dbgapi_remove_breakpoint_callback >> return AMD_DBGAPI_STATUS_SUCCESS; >> } >> >> +/* signal_received observer. */ >> + >> +static void >> +amd_dbgapi_target_signal_received (gdb_signal sig) >> +{ >> + amd_dbgapi_inferior_info *info >> + = get_amd_dbgapi_inferior_info (current_inferior ()); >> + >> + if (info->process_id == AMD_DBGAPI_PROCESS_NONE) >> + return; >> + >> + if (!ptid_is_gpu (inferior_thread ()->ptid)) >> + return; >> + >> + if (sig != GDB_SIGNAL_SEGV && sig != GDB_SIGNAL_BUS) >> + return; >> + >> + if (!info->precise_memory.enabled) >> + gdb_printf ("\ > > I think there should be a _() surrounding the string. Done. >> +The @code{set amdgpu precise-memory} parameter is per-inferior. When an > ^ > Isn't the parameter name just "amdgpu precise-memory"? Yes, done. >> diff --git a/gdb/testsuite/gdb.rocm/precise-memory-exec.c b/gdb/testsuite/gdb.rocm/precise-memory-exec.c >> new file mode 100644 >> index 000000000000..f0659a63fc5a >> --- /dev/null >> +++ b/gdb/testsuite/gdb.rocm/precise-memory-exec.c >> @@ -0,0 +1,44 @@ >> +/* Copyright 2021-2023 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 . */ >> + >> +#include >> +#include >> +#include >> + >> +static void >> +second (void) >> +{ >> +} >> + >> +int >> +main (int argc, char **argv) >> +{ >> + if (argc == 1) >> + { >> + /* First invocation */ > > Should the comment end with ". "? Done. > >> + int ret = execl (argv[0], argv[0], "Hello", NULL); >> + perror ("exec"); >> + abort (); >> + } >> + else >> + { >> + /* Second invocation */ > > Here also. Done. > >> + second (); >> + } >> + >> + return 0; >> +} >> diff --git a/gdb/testsuite/gdb.rocm/precise-memory-exec.exp b/gdb/testsuite/gdb.rocm/precise-memory-exec.exp >> new file mode 100644 >> index 000000000000..26be6cf72146 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.rocm/precise-memory-exec.exp >> @@ -0,0 +1,62 @@ >> +# Copyright 2021-2023 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 . >> + >> +# Test that the "set amdgpu precise-memory" setting is inherited by an inferior >> +# created following an exec. >> + >> +load_lib rocm.exp >> + >> +require allow_hipcc_tests >> + >> +if { ![istarget "*-linux*"] } then { >> + continue >> +} > > Should this test be integrated in allow_hipcc_test? This would avoid > having to repeat it in multiple testcases (and all testcases do not have > such guard). > > Also, I'm not sure if there is any non-linux configuration which can > satisfy allow_hipcc_tests, which would make this test redundant. Yeah I think we can put it in allow_hipcc_tests. If/when we want to run this test on, let's say, Windows, we will be able to change the check in allow_hipcc_tests. The existing tests in the upstream repo don't have the linux check, I guess there should have been some checks. I'll add a new preparatory patch in v2. >> diff --git a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp >> new file mode 100644 >> index 000000000000..58339e5391a6 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp >> @@ -0,0 +1,33 @@ >> +/* Copyright 2021-2023 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 . */ >> + >> +#include >> + >> +__global__ void >> +kernel () >> +{ >> + int *p = nullptr; >> + *p = 1; >> +} >> + >> +int >> +main (int argc, char* argv[]) >> +{ >> + hipLaunchKernelGGL (kernel, dim3 (1), dim3 (1), 0, 0); > > I think the "modern" way to write this would be: > > kernel<<<1, 1>>> (); > > This is mostly a remark, I don't mind using hipLaunchKernelGGL too much > either. I think we wanted to migrate all to the new form, let's go with the new form. >> diff --git a/gdb/testsuite/lib/rocm.exp b/gdb/testsuite/lib/rocm.exp >> index 98a3b308228d..22b294a5efae 100644 >> --- a/gdb/testsuite/lib/rocm.exp >> +++ b/gdb/testsuite/lib/rocm.exp >> @@ -99,6 +99,56 @@ gdb_caching_proc allow_hipcc_tests {} { >> return 1 >> } >> >> +# ROCM_PATH is used by hipcc as well. >> +if {[info exists env(ROCM_PATH)]} { >> + set rocm_path $env(ROCM_PATH) >> +} else { >> + set rocm_path "/opt/rocm" >> +} >> + >> +# Get the gpu target to be passed to e.g., -mcpu=. >> +# >> +# 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_target {} { > > There is a hcc_amdgpu_targets proc which enumerates the architecture of > each agent present on the system. This is a fairly recent addition, it > might have been introduced after you prepared this series. Oh, that's true, no need to introduce hcc_amdgpu_target. >> @@ -186,3 +236,12 @@ proc hip_devices_support_debug_multi_process {} { >> } >> return 1 >> } >> + >> +# Return true if the device supports precise memory. > > Using hcc_amdgpu_targets, you could have a function which checks that > all agents in the system support precise memory, not just the first one > detected. This will reflect how `set amdgpu precise-memory` works. Oh, right, we have this downstream. I sync'ed the patch with the downstream code. Thanks, will send a v2. Simon