提交图

1371 次代码提交

作者 SHA1 备注 提交日期
Yiannis Papadopoulos 54933a3db2 rocr: DmaBufExport support for other agent types
[ROCm/ROCR-Runtime commit: f5120bfe68]
2025-07-25 21:49:35 -04:00
Yiannis Papadopoulos 91895208f8 rocr/aie: XdnaDriver::ExportDMABuf implementation
[ROCm/ROCR-Runtime commit: ccaac9045b]
2025-07-25 21:49:35 -04:00
Yat Sin, David 90153e90e1 Update runtime/hsa-runtime/core/runtime/amd_blit_sdma.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yat Sin, David <David.YatSin@amd.com>

[ROCm/ROCR-Runtime commit: 0dec2ab43b]
2025-07-25 14:50:40 -04:00
David Yat Sin 7114e098d6 rocr: Remove SDMA code for gfx7 and gfx8
Remove deprecated SDMA code for gfx7 and gfx8 asics


[ROCm/ROCR-Runtime commit: d3f70910e1]
2025-07-25 14:50:40 -04:00
Tony Gutierrez 36072821a8 rocr: Remove unused member of GPUAgent
The ape1_size_ member was leftover after the removal
of KV and is no longer used.

Remove it to remove some compiler warnings.

Signed-off-by: Tony Gutierrez <anthony.gutierrez@amd.com>


[ROCm/ROCR-Runtime commit: 5285c24657]
2025-07-25 10:43:28 -04:00
Honglei Huang 8f91cd2b03 rocr: support multiple driver types in agent initialization
Modify agent initialization to support different driver types,
to enable KFD_VIRTIO dirver for CPU and GPU agent here.

1. Add driver_type parameter to CpuAgent and GpuAgent constructors
2. Update topology discovery to handle multiple driver types
3. Fix MakeMemoryResident return value check in VirtioDriver
4. Add helper function IsGPUDriver to check driver types
5. Update agent discovery to iterate through all available drivers

This change makes the runtime more flexible by removing hardcoded KFD
driver assumptions and properly handling different driver backends.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 20806577ce]
2025-07-24 23:20:36 +08:00
Honglei Huang 8d7d06a867 rocr/driver: add virtio driver support for ROCm runtime
This commit adds virtio driver support to the ROCm runtime by:

1. Implementing KfdVirtioDriver class that inherits from core::Driver
2. Adding KFD_VIRTIO to DriverType enum
3. Registering virtio driver discovery function in topology
4. Adding virtio driver source files to CMake build

The virtio driver implementation provides basic memory management and
queue operations for virtualized GPU environments. Some advanced features
like PC sampling and SMI are currently not supported.

Key changes:
- Add new files: amd_kfd_virtio_driver.h/cpp
- Update CMakeLists.txt to include virtio driver
- Add VIRTIO to DriverType enum in driver.h
- Register virtio driver in amd_topology.cpp

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: d36cb195da]
2025-07-24 23:20:36 +08:00
Honglei Huang 5e68bd163a libhsakmt/virtio: add virtio support for libhsakmt
This patch adds VirtIO support to the libhsakmt library, enabling communication
 with AMD GPUs via VirtIO.

Details
- CMakeLists.txt: Added a new CMakeLists.txt file for the VirtIO component
of libhsakmt.
- hsakmt_virtio.c/h: Implemented the core VirtIO functionality, including
VirtIO GPU device initialization, command execution, and memory management.
- virtio_gpu.c/h: Contains the implementation of the VirtIO GPU device,
including ioctl handling, shared memory management, and command execution.
- hsakmt_virtio_events.c: Implements event handling for VirtIO, such as event
creation, destruction, setting, resetting, and querying event states.
- hsakmt_virtio_memory.c: Manages memory operations for VirtIO, including memory
allocation, freeing, mapping, and unmapping.
- hsakmt_virtio_queues.c: Implements queue management for VirtIO, including
queue creation, destruction, and updating.
- hsakmt_virtio_topology.c: Handles system and node properties for VirtIO.
- hsakmt_virtio_vm.c: Manages VM-related operations for VirtIO, such as
reserving and dereserving VA space.
- include/linux/virtgpu_drm.h: Contains DRM definitions for VirtIO GPU.

Key Features
- VirtIO GPU Initialization: The library can now initialize a VirtIO GPU device
and communicate with it.
- Command Execution: Supports executing commands on the VirtIO GPU device.
- Memory Management: Provides functions for allocating, freeing, mapping, and
unmapping memory for VirtIO operations.
- Event Handling: Implements a comprehensive event system for VirtIO.
- Queue Management: Allows for creating, destroying, and updating queues
on the VirtIO GPU device.
- System and Node Properties: Retrieves and manages system and node
properties for VirtIO.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 48d3719dba]
2025-07-24 23:20:36 +08:00
Shweta Khatri 2bd0f85f80 rocr: GFX12 - Enable host trap PC Sampling
[ROCm/ROCR-Runtime commit: 6015ad1016]
2025-07-23 06:51:53 -04:00
Yiannis Papadopoulos 6ebc5bd4e4 rocr: Fix warnings
[ROCm/ROCR-Runtime commit: eb3d45d300]
2025-07-21 12:55:46 -04:00
Flora Cui 6bb53e88c5 rocr: add specific flag for blit kernel object
so that aql-to-pm4 conversion could verify the validity of the kernel
object.

Signed-off-by: Flora Cui <flora.cui@amd.com>


[ROCm/ROCR-Runtime commit: a765dd7e94]
2025-07-17 21:55:02 +08:00
Honglei Huang 7c29c36f7e rocr/driver: add memory residency management interface in driver
This commit introduces MakeMemoryResident and MakeMemoryUnresident
functions to KfdDriver and XdnaDriver classes.

- Added implementations in amd_kfd_driver.cpp
- Added stubs in amd_xdna_driver.cpp returning HSA_STATUS_ERROR
- Updated header files amd_kfd_driver.h and amd_xdna_driver.h
- Removed MakeKfdMemoryResident/Unresident from amd_memory_region.cpp

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 6c87f5b5ce]
2025-07-16 13:15:45 +08:00
Honglei Huang b61df004ff rocr/driver: add memory registration and deregistration into driver
This commit completes the memory register/deregister interface change.

Removed static RegisterMemory and DeregisterMemory from MemoryRegion class

- Added pure virtual methods to base Driver interface in driver class
- Added implementation in KFD driver
- Modified MemoryRegion Lock and Unlock to use driver interface

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: ab6bda7e96]
2025-07-16 13:15:45 +08:00
Honglei Huang 724c9b9803 rocr/driver: add AvailableMemory API to driver
This commit introduces a new AvailableMemory API to the KfdDriver and
 XdnaDriver classes.

- Implemented AvailableMemory in KfdDriver to return the available memory size
  using hsaKmtAvailableMemory.
- Added a stub implementation of AvailableMemory in XdnaDriver that returns an error.
- Updated the GpuAgent class to use the new AvailableMemory API instead of
  directly calling hsaKmtAvailableMemory.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 6c390e32cc]
2025-07-16 13:15:45 +08:00
Honglei Huang a509e93393 rocr: add const version of driver() method to Agent class
This change adds a const-qualified version of the driver() method to the Agent
class, allowing const Agent objects to access their associated driver without
modifying the object's state.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 9c18618847]
2025-07-16 13:15:45 +08:00
Honglei Huang e81be86a31 rocr: use driver interface for scratch memory deallocation
Replace direct hsaKmtFreeMemory call with driver's FreeMemory interface
in GpuAgent::ReleaseResources(). This change improves code abstraction
by handling memory deallocation through the unified driver interface.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 8216787d4c]
2025-07-16 13:15:45 +08:00
Honglei Huang 1ad79f04d0 rocr/driver: add scratch memory allocation into driver interface
Add AllocateScratchMemory interface to Driver base class and implement it
in both KFD and XDNA drivers. This change encapsulates the low-level
scratch memory allocation details within driver implementations, making
the code more maintainable and the interface cleaner.

The main changes include:
- Add AllocateScratchMemory virtual method to Driver interface
- Implement the interface in KfdDriver with existing allocation logic
- Add stub implementation in XdnaDriver
- Update GpuAgent to use the new interface instead of direct KMT calls

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: da8dd9e1e3]
2025-07-16 13:15:45 +08:00
Yiannis Papadopoulos a0ef6f6473 rocr: Using MemoryRegion::GetInfo(HSA_REGION_INFO_ALLOC_MAX_SIZE) for HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE
[ROCm/ROCR-Runtime commit: bfe76cf94e]
2025-07-15 14:22:56 -05:00
zichguan-amd 0c698557a0 rocr: check _SC_LEVEL1_DCACHE_LINESIZE before use
Support musl
Fixes ROCm/ROCR-Runtime#318

Signed-off-by: zichguan-amd <zichuan.guan@amd.com>


[ROCm/ROCR-Runtime commit: 7946ddb647]
2025-07-14 14:44:31 -04:00
Chris Freehill c5faafeb25 rocr: Ensure AqlQueue can exit on memory error
A hang would occur when a memory error occurs because the
AQLQueue destructor would be waiting for a signal that
wouldn't come. This change allows it to break out of the
wait loop.


[ROCm/ROCR-Runtime commit: c065d9a7e2]
2025-07-11 12:58:21 -05:00
Honglei Huang 3fb4c8d3d7 rocr/driver: move wallclock frequency query to driver layer
Move the wallclock frequency query from GpuAgent to driver layer to improve
code organization and support multiple driver types. This change:

1. Add GetWallclockFrequency API to KFD/XDNA drivers
2. Move libdrm GPU info query from GpuAgent to driver implementation
3. Update GpuAgent to use the new driver API

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 412e386b50]
2025-07-11 16:14:29 +08:00
Honglei Huang 309e8b1a9f rocr/driver: add support for getting GPU tile configuration
- Implemented GetTileConfig in KfdDriver to retrieve tile configuration for
a specific node.
- Added a stub implementation of GetTileConfig in XdnaDriver.
- Updated driver.h to include a virtual GetTileConfig method.
- Extended hsa_internal.h with a new hsa_get_tile_config function.
- Integrated hsa_get_tile_config into hsa.cpp to call the driver-specific
  implementation.
- Updated driver headers to declare the new GetTileConfig method.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 9bc38e2ee6]
2025-07-11 16:14:29 +08:00
Honglei Huang e459cc0c3b rocr/driver: add GetClockCounters API to driver interface
This commit introduces a new GetClockCounters API to the driver interface.

- Implemented GetClockCounters in KfdDriver to fetch clock counters
  using hsaKmtGetClockCounters.
- Added a stub implementation of GetClockCounters in XdnaDriver that
  returns HSA_STATUS_ERROR.
- Modified GpuAgent to use driver().GetClockCounters instead of
  directly calling hsaKmtGetClockCounters.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 8d077dba3b]
2025-07-11 16:14:29 +08:00
Honglei Huang bacf61dde9 rocr/driver: add GetDeviceHandle to driver interface
This commit introduces a new GetDeviceHandle API to the driver
interface, allowing retrieval of the device handle for a
specific node.

- Implemented GetDeviceHandle in KfdDriver to fetch the AMD GPU
  device handle using hsaKmtGetAMDGPUDeviceHandle.
- Added a stub implementation of GetDeviceHandle in XdnaDriver
  that returns HSA_STATUS_ERROR.
- Modified GpuAgent::InitLibDrm to use driver().GetDeviceHandle
  instead of directly calling hsaKmtGetAMDGPUDeviceHandle.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 05b83e72d9]
2025-07-11 16:14:29 +08:00
Honglei Huang d675a9e3a0 rocr: replace DMABuf export paths by driver interface
This change improves code maintainability and error handling by
centralizing DMABuf export functionality in the driver interface.

- Replace direct hsaKmtExportDMABufHandle calls with driver's ExportDMABuf method
- Improve error handling with more specific error status returns
- Add explicit invalid parameter checks and assertions
- Consolidate DMABuf export logic in IPC and VMemory paths
- Propagate detailed error status from driver layer

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 837fd044d0]
2025-07-11 13:36:45 +08:00
Tony Gutierrez a99b7358ea rocr: Remove driver usage from filter device
Slightly refactor the RvdFilter so it doesn't need to call into the driver.


[ROCm/ROCR-Runtime commit: cb7b0c8d9f]
2025-07-10 09:41:34 -07:00
David Yat Sin 4e069fe72b doc: Fix doxygen comments for in-out params
[ROCm/ROCR-Runtime commit: 4c2dec5bb8]
2025-07-10 08:21:01 -04:00
Chris Freehill ad3985af1c rocr: Fix isa entries for gfx906/sramecc
Some of the entries for gfx906 in the ISA table in isa.cpp
had "any" for "sramecc-" instead of "disabled". This fixes
that.


[ROCm/ROCR-Runtime commit: 12430fe25a]
2025-07-02 08:40:30 -05:00
Chris Freehill 0e860e73b0 rocr/rocrtst: Update to c++17
[ROCm/ROCR-Runtime commit: f1bd89bd0d]
2025-06-30 14:02:24 -05:00
Honglei Huang 4fea8ea1fd rocr/driver: add SetTrapHandler API to driver interface
This commit introduces a new SetTrapHandler API to the driver interface

- Implemented SetTrapHandler in KfdDriver to set trap handlers using
  hsaKmtSetTrapHandler.
- Added a stub implementation of SetTrapHandler in XdnaDriver that returns
  HSA_STATUS_ERROR.
- Updated the driver interface in driver.h to include the new SetTrapHandler
  method.
- Modified GpuAgent to use driver().SetTrapHandler instead of directly calling
  hsaKmtSetTrapHandler.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: d874b8003a]
2025-06-27 23:32:53 +08:00
Honglei Huang 5e7fd3b5ba rocr: replace direct libhsakmt calls with driver interfaces
Replace direct hsakmt API calls with calls through the driver abstraction layer
in queue management related functions. This includes:
- CreateQueue/DestroyQueue operations
- Queue update and GWS allocation
- CU masking configuration

Also update the corresponding error status types from HSAKMT_STATUS to
hsa_status_t and adjust error handling accordingly.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: dee5bdc679]
2025-06-26 15:53:01 +08:00
Honglei Huang 75a7da05be rocr: use driver interface for memory and cache properties query
Replace direct libhsakmt calls with driver interface methods
in GpuAgent initialization:
- Replace hsaKmtGetNodeMemoryProperties with driver().GetMemoryProperties
- Replace hsaKmtGetNodeCacheProperties with driver().GetCacheProperties

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>


[ROCm/ROCR-Runtime commit: 046591419f]
2025-06-26 15:53:01 +08:00
Honglei Huang 97992b809f rocr: remove unused agent properties reference in scratch initialization
The agent properties variable `agent_props` was declared but never used
in the `InitScratchSRD()` function. Which casued compile warning:

runtime/core/runtime/amd_aql_queue.cpp:1880:15: warning:
unused variable ‘agent_props’ [-Wunused-variable]
 1880 |   const auto& agent_props = agent_->properties();

No functional changes, purely a code cleanup commit.


[ROCm/ROCR-Runtime commit: ffa07e28e7]
2025-06-26 13:05:40 +08:00
Tony Gutierrez 8daec0261f rocr: Move OpenSMI call to Driver
[ROCm/ROCR-Runtime commit: 1a339feb1f]
2025-06-25 15:53:02 -07:00
Yiannis Papadopoulos 47093a7f73 rocr/aie: Remove redundant and unused functions.
[ROCm/ROCR-Runtime commit: 2ca4d8f6d4]
2025-06-25 11:32:42 -04:00
Yiannis Papadopoulos 9ca5405b74 rocr/aie: Correct calculation of neural cores and avoid error on invalid queue ID.
[ROCm/ROCR-Runtime commit: e5125c9d5e]
2025-06-25 11:32:42 -04:00
Ken O'Brien 24d10e5c76 rocr: Fixes memory allocation issue
Fixes a bug in memory allocation in which dmabuf export only works on
GPU 0 in a multi-GPU environment.


[ROCm/ROCR-Runtime commit: 7b8a6f8ca2]
2025-06-24 14:53:14 -04:00
Sunday Clement 315b1abaf9 rocr: Add hsa-agent Queries for Clock Counters
Support has been added to query the following
HSA_AMD_INFO_GET_CLOCK_COUNTERS agent info exposed through the hsa api
in rocr, rather than the user having to make a direct IOCTL call
through the kernel driver.

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>


[ROCm/ROCR-Runtime commit: e97d06530e]
2025-06-23 18:45:09 -04:00
Tony Gutierrez a62368e2ba rocr: Update Driver queue-related APIs
Update the user-mode driver queue APIs to leverage KMT types.

Move queue-related calls to the core::Driver API.


[ROCm/ROCR-Runtime commit: e03d44d742]
2025-06-23 12:21:01 -07:00
David Yat Sin 39bddd8b9d rocr: support reserving non-registered VA
Extend hsa_amd_vmem_address_reserve/hsa_amd_vmem_address_reserve_align
to support HSA_AMD_VMEM_ADDRESS_NO_REGISTER flag. This allocation can be
used to reserve virtual address ranges that can later be used by
hsa_amd_svm_attributes_set for SVM based memory allocations.


[ROCm/ROCR-Runtime commit: b3c48cc68c]
2025-06-18 18:21:11 -04:00
Chris Freehill 14b5faf333 rocr: Add missing close of dmabuf after import
[ROCm/ROCR-Runtime commit: 24f36de037]
2025-06-17 20:22:34 -04:00
David Yat Sin e3b013b208 rocr: Always send free scratch notifications
Always send notification to profiler tools when scratch memory is freed.


[ROCm/ROCR-Runtime commit: 488cfd467c]
2025-06-16 17:39:33 -04:00
Alysa Liu a36892da4d rocr: Fix wrong sizeof argument
Update size calculation from 2 * sizeof(void*) to 2 * sizeof(uint64_t)

Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>


[ROCm/ROCR-Runtime commit: 3b450397d6]
2025-06-16 13:11:07 -04:00
Sunday Clement 90e35e8486 rocr: Remove Recursive Include
Removed unnecessary header inlude in file to prevent circular include.

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>


[ROCm/ROCR-Runtime commit: 31b6474801]
2025-06-13 12:29:52 -04:00
Sunday Clement 76dbfc159c rocr: Fix Recursive Include in header files
scratch_cache.h includes amd_gpu_agent.h which then again includes
scratch_cache.h, this has now been fixed removing the unecessary
header include.

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>


[ROCm/ROCR-Runtime commit: 06efa50c09]
2025-06-13 12:29:52 -04:00
David Yat Sin b66b6991b0 rocr: Remove scratch_backing_memory_byte_size
scratch_backing_memory_byte_size was originally removed, and then put
back in e130172218. This was because it
was used by rocgdb. rocgdb code has been updated to not use this field.
Bumped _amdgpu_r_debug for the ABI change.


[ROCm/ROCR-Runtime commit: 3c0af843e3]
2025-06-12 15:33:47 -04:00
David Yat Sin 10b8b00193 cmake: Remove unused file
[ROCm/ROCR-Runtime commit: 17b8f9b24d]
2025-06-12 10:38:58 -04:00
David Yat Sin 37afa1c0eb rocr: Remove support for Kaveri GPUs
Kaveri GPUs are EoL


[ROCm/ROCR-Runtime commit: 24ce840732]
2025-06-12 10:38:58 -04:00
David Yat Sin 8982f2c2c6 rocr: Fix compile warning when using clang
[ROCm/ROCR-Runtime commit: 96d0f07b15]
2025-06-12 10:38:58 -04:00
Alysa Liu ab747b1ffd rocr: Prevent int overflow in arithmetic operation
Cast range->x and range->y to uint64_t before performing multiplication

Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>


[ROCm/ROCR-Runtime commit: 77b86ca908]
2025-06-11 19:36:36 -04:00