Grafico dei commit

51 Commit

Autore SHA1 Messaggio Data
Flora Cui a765dd7e94 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>
2025-07-17 21:55:02 +08:00
Honglei Huang 6c87f5b5ce 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>
2025-07-16 13:15:45 +08:00
Honglei Huang ab6bda7e96 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>
2025-07-16 13:15:45 +08:00
Honglei Huang 6c390e32cc 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>
2025-07-16 13:15:45 +08:00
Honglei Huang da8dd9e1e3 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>
2025-07-16 13:15:45 +08:00
Honglei Huang 412e386b50 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>
2025-07-11 16:14:29 +08:00
Honglei Huang 9bc38e2ee6 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>
2025-07-11 16:14:29 +08:00
Honglei Huang 8d077dba3b 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>
2025-07-11 16:14:29 +08:00
Honglei Huang 05b83e72d9 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>
2025-07-11 16:14:29 +08:00
Honglei Huang 837fd044d0 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>
2025-07-11 13:36:45 +08:00
Honglei Huang d874b8003a 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>
2025-06-27 23:32:53 +08:00
Tony Gutierrez 1a339feb1f rocr: Move OpenSMI call to Driver 2025-06-25 15:53:02 -07:00
Yiannis Papadopoulos 2ca4d8f6d4 rocr/aie: Remove redundant and unused functions. 2025-06-25 11:32:42 -04:00
Yiannis Papadopoulos e5125c9d5e rocr/aie: Correct calculation of neural cores and avoid error on invalid queue ID. 2025-06-25 11:32:42 -04:00
Tony Gutierrez e03d44d742 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.
2025-06-23 12:21:01 -07:00
Alysa Liu f6c8cbd293 rocr: Fix inefficient copy operations
Refactor variable assignments to use std::move() where appropriate.
Updat function headers to accept parameters by const& where appropriate.

Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>
2025-06-02 11:18:36 -04:00
Alysa Liu ae6851dbb4 rocr: Fixed inefficient copy operations
Changed variable assignments to use std::move() where appropriate.
Changed function headers to pass string arguments by reference where appropriate.

Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>
2025-06-02 11:18:36 -04:00
Alysa Liu a945b5d493 rocr: Fixed inefficient copy operations
Changed variable assignments to use std::move() where appropriate.
Revert change in amd_kfd_driver.cpp.

Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>
2025-06-02 11:18:36 -04:00
Alysa Liu 369d89ade3 rocr: Fixed inefficient copy operations
Changed variable assignments to use std::move() where appropriate

Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>
2025-06-02 11:18:36 -04:00
David Yat Sin 4bae509296 rocr: Remove deprecated queue doubleMap code 2025-05-28 16:12:02 -04:00
Yiannis Papadopoulos 700078d335 Fix formatting 2025-05-20 13:59:22 -05:00
Yiannis Papadopoulos c80616d807 rocr/aie: Correct operand count 2025-05-20 13:59:22 -05:00
Aaron Liu 0cd4ddd62b rocr/dtif: add DRM APIs wrapper in thunk loader
Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Reviewed-by: David Yat Sin <David.YatSin@amd.com>
2025-05-13 16:44:31 -04:00
Aaron Liu 1b79caa214 rocr/dtif: replace hsakmt interfaces with HSAKMT_CALL(...)
Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Reviewed-by: David Yat Sin <David.YatSin@amd.com>
2025-05-13 16:44:31 -04:00
Yiannis Papadopoulos 7c8fa87160 rocr/aie: Remove redundant cache flushes for already loaded PDIs 2025-04-17 09:48:41 -05:00
Yiannis Papadopoulos c63e01724c rocr/aie: Using PDI address instead of cu_mask for dispatch. Automatic hw ctx reconfiguration upon new PDI addition. 2025-04-03 15:13:20 -05:00
Yiannis Papadopoulos 0bd4acb5d4 rocr/aie: Returning error code if query not recognized 2025-03-27 13:15:13 -04:00
Yiannis Papadopoulos e55503e7f8 rocr/aie: Bundling XDNA BOs and addresses, adding cleanup guard in case of error 2025-03-27 13:15:13 -04:00
Yiannis Papadopoulos b066e0eefa rocr/aie: Resolve parentheses warning 2025-03-27 10:33:40 -04:00
David Yat Sin 947391deac rocr: Release agent resources before pools
Adding a general stage for agents to release their resources on
shutdown. This avoids a circular dependency during shutdown because
we have to delete allocated resources before deleting memory pools, but
we also have to delete memory pools before destroying agents.
2025-03-25 14:25:04 -04:00
Yiannis Papadopoulos 765563b786 rocr: Return success status in IsModelEnabled() 2025-03-25 10:05:16 -04:00
jordans d4b85b6bf5 hsakmt: Initial Commit for the HSA KMT Model
The over arching goal it so provide an API that pre-silicon models can latch into for software bring up.# Please enter the commit message for your changes. Lines starting
2025-03-18 16:22:17 -04:00
Tony Gutierrez d3a4dc9687 rocr: Remove KMT usage from AMD ext
Use the core Driver in AMD's HSA extension API to make it
agnostic to the underlying OS and kernel-mode driver.
2025-02-25 21:51:52 -05:00
Tony Gutierrez a9f6bc8d0e rocr: Remove KMT usage from CPU agent
Use the core Driver object in the CPU agent to make it OS/driver
agnostic.

Implement the GetMemoryProperties() and GetCacheProperties methods
for the KFD driver.
2025-02-21 10:00:38 -05:00
Yiannis Papadopoulos 03bd4c9508 rocr: Changing to a device SVM flag
Change-Id: Ib085801d23604eeef0a17a05cf2b298170fb3d24
2025-01-28 17:06:16 +00:00
Yiannis Papadopoulos 144e7674d1 rocr: Use SVM information to separate dev heap
Use SVM information from user accessible memory

Change-Id: I8fad37eb1a90dc1f5827a096552130a3fd6187f4
2025-01-28 17:05:52 +00:00
Yiannis Papadopoulos 1d8a77db34 rocr/aie: AIE agent memory pools correct size and user data pool
Change-Id: I831711a7d1cdc36cbc9ed30bd74d0dc984228ce7
2025-01-28 10:48:16 -05:00
Yiannis Papadopoulos 26bfa0b8f6 rocr/aie: Add dma-buf import support for AIEAgents via the Driver interface
Change-Id: I70f8d8772dda7c06944d75042cb3034ddd89aff4
2025-01-27 15:22:46 -05:00
Tony Gutierrez 15107afb11 rocr: Generalize driver discovery
Generalize the driver discovery and move driver-specific
functionality to the concrete driver implementations.
Currently, this process is tightly coupled to the hsakmt
which is GPU and OS specific.

Change-Id: Ie1c53fef407a71b5ec4c6eaf3a3ed00871184409
2025-01-23 15:09:14 -05:00
Tony Gutierrez 77fa5af618 rocr: Make Open() and Close() virtual in Driver
Change-Id: Iac054c08383b080ca2b2ec6d65019bf2f083b763
2025-01-23 15:09:06 -05:00
Eddie Richter e9cc839b2b rocr/aie: AIE Queue Processing
Change-Id: I681c971ba7229037ca85d5529838aa7bbe5820e2
2024-12-10 10:50:02 -05:00
Yiannis Papadopoulos 48fdc17179 rocr/aie: Correct reporting of dev heap size
Storing the correct dev heap size in the memory region.

Change-Id: I14b053330c187da1d7d0213256625e50795b9902
2024-09-20 12:44:23 -04:00
David Yat Sin 0af7a54ebe rocr: Return err when freeing invalid pointer
Return false if trying to free a NULL pointer (or invalid size)
internally in ROCr. This is to detect errors within ROCr when trying
to free NULL pointers. If a user of ROCr tries to free a NULL
pointer, this condition should be caught at the beginning of the
Runtime::FreeMemory(...) function and return HSA_STATUS_SUCCESS. This
matches the behavior of the free(...) or delete functions that
silently ignores calls when the passed a NULL pointer.

Change-Id: I84bc26928b35023e19cd9f214b42c6ee9508029c
2024-09-19 19:44:53 +00:00
Tony Gutierrez 4bf102dc6b rocr/aie: Support VMEM handle creation
Adds support for AllocateMemoryOnly inside XDNA driver.

Move the IsLocalMemory() check inside the KFD driver
since the XDNA driver can, and needs to, create handles
on system memory buffer objects.

Changed handle variable name from thunk_handle to user_mode_driver_handle,
which is more representative if we support non-GPU drivers.

Change-Id: I95db9d575afd1ab0ff2de74cea5175d9a12a721b
2024-09-19 19:44:53 +00:00
Tony Gutierrez a851f73da5 rocr/aie: Init mem regions for AIE agents
Change-Id: If180bdbcb3eb659f0d05a710526864494316d7a9
2024-09-19 19:44:53 +00:00
Tony Gutierrez 931733d51a rocr/aie: Add support for creating AIE queue context
Adds support for initialzing the XDNA driver so that
a hardware context can be created for an AIE queue.

Right now this initializes the device heap in the driver,
gets the relevant tile parameters for the AIE agent,
and creates a hardware context that backs the AIE queue.

Change-Id: Ib90e1bc67a8637f6db3ff2bebe34677843796417
2024-09-19 19:44:53 +00:00
Saleel Kudchadker 3baaa6e9c0 rocr: Allocate AQL queue on device memory
- Use HSA_ALLOCATE_QUEUE_DEV_MEM=1 to create AQL queue in device
memory.
- Before writing AQL packet header to the queue use an SFENCE to ensure
that there is no reodering of the writes over PCIE

Change-Id: I5eacdc35108c4a1e245c75ae349b7495451aa60d
2024-09-05 17:48:02 -04:00
Tony Gutierrez 68669f4e1a rocr: Generalize AMD::MemoryRegion Allocate and Free
Remove KFD-specific Allocate/Free calls from the AMD::MemoryRegion.
The KFD-driver-specific Allocate/Free calls are now implemented in
the KfdDriver. Future changes will migrate the remaining KFD-specific
calls out of AMD::MemoryRegion.

This allows the MemoryRegion to be used across AMD drivers like the
XDNA driver.

Change-Id: Ib6a2a9e5e1a15e61644d2592beb3a8e6578c3010
2024-08-28 14:35:07 -07:00
Tony Gutierrez c42ff44a6a rocr/kfd-driver: Add initial KFD driver interface
Adds the initial KFD driver interface and use it to open the
KFD from amd_topology.cpp.

This change is to show the direction of the Driver interface for
initially supporting the KFD and to get feedback on the approach.
For now we wrap relevant ROCt calls behind this generic driver
interface so that we can generalize core ROCr components like
MemoryRegion, Runtime, etc.

Now that ROCt is incorporated into ROCr, we can more fully integrate
ROCt into the Driver interface. Ideally, we get to a point where
the generic Driver interface can support KFD, XDNA, and potential
future drivers.

Change-Id: I4573fd6af1f8398233ee9d3814d9f3139dd0279c
2024-08-28 14:34:54 -07:00
Tony Gutierrez 86f40ae489 rocr/xdna-driver: Initial support for amdxdna driver
Change-Id: I319b55d89dc644e7151228cb6c19d1a633171295
2024-08-28 14:34:39 -07:00