1371 Commit-ok

Szerző SHA1 Üzenet Dátum
David Yat Sin 48cb61f378 rocr: Separate Linux coredump implementation (#1588)
Remove libamdhsacode/win32/elf.h due to license restrictions.

Separate Linux coredump implementation because we do not have the ELF
definitions on Windows.

Co-authored-by: JeniferC99 <150404595+JeniferC99@users.noreply.github.com>
2025-11-07 14:52:08 -05:00
Yiannis Papadopoulos 30785f8d18 rocr: Assume KFD in hsa_amd_interop functions (#1138) 2025-11-07 09:38:06 -06:00
Xie, AlexBin c877be2afe rocr: make sure the member variable is conctructed (#1387)
Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
2025-11-05 17:19:33 -05:00
MachineTom 3b1c0c3464 SWDEV-558845 - Support image in rocr on Windows (#1582)
Enable image build in Windows.
Remove some useless codes that fail building in Windows.
Some minor improvement.
Temporarily exclude mipmap test files.
Prevent negative tests affect some tests.
Move some catch info log codes into failed cases.
2025-11-05 09:33:41 -05:00
German Andryeyev ee1158b7b8 rocr: Fix Windows build and Ctz implementation (#1634) 2025-11-03 12:07:11 -05:00
arvindcheru fb1d32c15c SWDEV-530465 Update share/doc/<pkgnm> License Folder for hsa-rocr (#923)
* SWDEV-530465 Update share/doc/<pkgnm> License Folder for hsa-rocr
* Review Comments Updated - reverted to usage of DOCDIR
2025-10-31 23:21:22 -04:00
Yiannis Papadopoulos 37bbc9062a rocr/aie: Detect AIE architecture and marketing name (#1459)
* rocr/aie: Detect AIE architecture and marketing name

* rocr/aie: Modernize code, update comments
2025-10-31 09:10:18 -05:00
David Yat Sin 6497fa0339 rocr: Fix wrong args in memory copy functions (#1520)
Fix incorrect arguments passed into system_region->Lock
2025-10-27 14:12:06 -05:00
David Yat Sin f7b180ee7d rocr: SW workaround for gfx90x SDMA poll (#1469)
Workaround for rare issue on gfx90x asics when SDMA_OP_POLLREGMEM
returns before polled memory has value of 0.
Removing previous SW workaround to double-poll as it was not reliable.
2025-10-27 09:33:20 -04:00
David Yat Sin db01d95ebc Users/dayatsin/swdev 519413 hsa amd pointer info return err shutdown (#1509)
* rocr: hsa_amd_pointer_info return err on shutdown

Decrement ref count before starting to unload to make sure API
calls during shutdown return error.

Delete blit objects during agent destructor.

* Add support for HSA_AMD_SYSTEM_SHUTDOWN_EVENT

Add support for new event to indicate shut down within the
hsa_amd_register_system_event_handler API.
2025-10-27 09:32:52 -04:00
Rahul Manocha 4f075902fc SWDEV-555347 - Remove lock contention in async events loop (#878)
* SWDEV-555347 - Remove lock contention in async events loop

* SWDEV-555347 - Introduce Pool of AsyncEventItems

* create generic mempool for AsyncEventItem

* Use BaseShared allocate and free for async event pool

---------

Co-authored-by: Rahul Manocha <rmanocha@amd.com>
2025-10-24 08:43:00 -07:00
systems-assistant[bot] bebe65f104 rocr: fix nullptr dereference (#262)
* rocr: fix nullptr dereference

Return early in the case that malloc fails to avoid dereferencing of a
null pointer on eventDescrp.

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

* rocr: Fix potential nullptr dereference

returns early if sym->section() fails to properly acquire the object.

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

---------

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>
Co-authored-by: Sunday Clement <Sunday.Clement@amd.com>
2025-10-21 13:49:01 -04:00
David Yat Sin e2f3bd2429 Changes for RDMA with VMM (#801)
* rocr: Add support for VMM and RDMA

Add extra CPU mapping so that kernel-mode drivers can look up the memory
mapping by virtual address.

* Update projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp

Co-authored-by: Yiannis Papadopoulos <102817138+ypapadop-amd@users.noreply.github.com>

* Update projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h

Co-authored-by: Yiannis Papadopoulos <102817138+ypapadop-amd@users.noreply.github.com>

* rocr: Honor uncache flag in memory_lock_to_pool()

Also, combined several flag options used in apis into a
single integer.

Signed-off-by: Chris Freehill <cfreehil@amd.com>

* rocr: Fix hsa_amd_pointer_info on CPU agents

Fix hsa_amd_pointer_info query returning allowd on VMM pointers for CPU
agents when CPU mapping was mapped with PROT_NONE.

---------

Signed-off-by: Chris Freehill <cfreehil@amd.com>
Co-authored-by: Yiannis Papadopoulos <102817138+ypapadop-amd@users.noreply.github.com>
Co-authored-by: Chris Freehill <cfreehil@amd.com>
Co-authored-by: cfreeamd <166262151+cfreeamd@users.noreply.github.com>
2025-10-21 12:19:02 -04:00
randyh62 fd5ad25615 Add note for setting the HSA_SCRATCH_SINGLE_LIMIT (#1391) 2025-10-19 17:38:06 -07:00
cfreeamd 911a2f42c1 Revert "rocr: Don't assert in hsa_shut_down when no agents (#1115)" (#1312)
This reverts commit fb8ab442b6.
2025-10-17 08:36:06 -07:00
Sunday Clement c23c320b4d rocr: Make IPC Handles Unique (#795)
Query IPC handles on shared memory export/import for any metadata as a
means to uniquely identify handles that happen to be backed by buffers
that point to the same memory.
2025-10-16 14:37:02 +05:30
axie_amdeng dde482d224 rocr: unitialized size variable caused huge memory/space allocation (#1232)
Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
2025-10-14 16:57:10 -04:00
David Yat Sin 7f79d0febc rocr: Set signal memory allocations to NonPaged (#1219)
Set memory allocation to non-paged to avoid issues caused when CP tries
to access signals after page has been migrated.
2025-10-10 17:35:15 -04:00
David Yat Sin 7f2ef6a602 rocr: Return error on signal alloc failure (#1310)
Return HSA_STATUS_ERROR_OUT_OF_RESOURCES when signal allocation fails.
2025-10-10 14:06:31 -04:00
German Andryeyev 7ca2497378 rocr: Add AQL queue support under Windows (#1211)
Add 2 extra caps into the thunk interface to indicate
the queue object creation and PM4 emulation
2025-10-07 17:55:08 -04:00
cfreeamd fb8ab442b6 rocr: Don't assert in hsa_shut_down when no agents (#1115)
* rocr: Don't assert in hsa_shut_down when no agents

Instead, print error message and return an error. Prior to
this patch, the assertion would occur when hsa_shut_down() is
called more than once.

* rocr: Reorder Unload  ASAN clean-up on shut down
2025-10-02 17:20:53 -07:00
cfreeamd 402aa7e253 rocr: Support batching in InterceptQueue store (#1194)
* rocr: Support batching in InterceptQueue store

* Fix comment, loop bounds
2025-10-02 10:37:40 -07:00
cfreeamd 55feeefcff Revert "rocr: Remove QueueProxy (#700)" (#1167)
This reverts commit c34c9826c3,
which was causing test failures.
2025-10-01 18:24:43 -07:00
hkasivis 5e7210980e Users/hkasivis/add ais support v2.1 (#928)
* libhsakmt: Update hsakmt_fmm_get_handle to support address range

Currently, hsakmt_fmm_get_handle works only if the address is allocated
(staring) value. Update it so it can find the handle if address falls in
the valid allocated range. This is useful for AMD infinity storage
feature where data needs to be transferred to any memory within in the
allocated range

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>

* libhsakmt: Introduce AMD Infinity Storage (AIS) API

Add hsaKmtAisReadWriteFile() API to support AMD Infinity Storage. The
API moves data directly from GPU VRAM to a file.

v2: Add in/out ioctl arguments to provide more status information to
user space. Modify hsaKmt API also accordingly.

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>

* rocr: Initial implementation of AMD Infinity Storage (AIS)

Implement first two API: hsa_amd_ais_file_write and hsa_amd_ais_file_read

v2: Change API from hsa_amd_ to hsa_amd_ais_
    Change API to take in handle instead of fd for compatibility accross
     different platforms

Original Author: Chris Freehill <Chris.Freehill@amd.com>
Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>

---------

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
2025-09-20 11:30:05 -04:00
Tony G c34c9826c3 rocr: Remove QueueProxy (#700)
Because the base QueueWrapper class copies the wrapped queue's
amd_queue_v2_t queue descriptor struct the QueueProxy seems
superfluous as it will have the same effect as calling the
underlying methods on the wrapped queue itself.

Additionally, because the QueueProxy needs to access the wrapped
queue's queue descriptor it breaks the Queue API which is meant
to abstract the underlying agent's queue implementation.

This makes it easier to generalize the core::Queue as well as
the InterceptQueue.

Signed-off-by: Tony Gutierrez <anthony.gutierrez@amd.com>
2025-09-19 09:07:28 -07:00
German Andryeyev 913743d433 Add windows build support into ROCr (#912)
Make sure ROCR can be compiled under windows. Extra setup for the windows build environment is required. The change should not have any functional changes under Linux.
2025-09-19 10:10:17 -04:00
David Yat Sin 96a0d16eda rocr: Fix hsa_amd_pointer_info regression (#719)
Fix for hsa_amd_pointer_info returning only
HSA_EXT_POINTER_TYPE_RESERVED_ADDR for SVM allocations.
2025-09-19 10:09:22 -04:00
Sunday Clement 7c8e575f5d Fix Undefined behavior from signed bit shifts (#871)
* libhsakmt: fix UB due to signed integer literal in 1 << 31

Bit shift operations on signed numbers should not shift into or beyond
the signed bit as this results in Undefined Behaviour.

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

* libhsakmt: Fix UB due to signed integer literal in 1 << x

Bit Shifting an unsigned integer is undefined behavior.

BUG: SWDEV-532853

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

* rocr: Fix UB in various places due signed integer in bit shift

Bit shifting signed integers into or beyond the sign bit is undefined.

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

* rocr: Change signed integer literals to unsigned

Changing the signed integers in the macro expressions throughout the file
to avoid overflow.

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

---------

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>
Co-authored-by: Flora Cui <flora.cui@amd.com>
2025-09-18 09:09:30 -04:00
systems-assistant[bot] f1fabcfd64 rocr: Error Handling Issues (#264)
* rocr: Fix Incorrect Assertion Check

The wrong variable is used in the assertion statement, should be error
checking for the value of paramEndLoc after it is modified by the call
to find().

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

* rocr: Fix Potential Undefined Behaviour

In the event that the SvmProfileControl destructor is called and
event == -1 is true then the call to close(event) is effectively
close(-1) which is undefined behaviour. This has been changed to only
call close() on valid file descriptors.

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

* rocr: Add Error Check on Bytes Read

In the case that there is an incomplete read the call to copyTo() will
now return an error.

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

* rocr: Fix Exception Error

Destructors are implicitly marked with noexcept being true by default
so if its not explicitly marked false in the destructor or the
functions it calls, any thrown exceptions will cause the program to
crash.

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

---------

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>
Co-authored-by: Sunday Clement <Sunday.Clement@amd.com>
2025-09-16 09:43:45 -04:00
Alysa Liu 2b2b8329b5 rocr: Add copyright for new files (#886)
Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>
2025-09-11 10:56:31 -04:00
Benjamin Welton ed5b2ac165 Fix deadlock in InterceptQueue::Submit when packet count exceeds queue capacity (#855)
InterceptQueue::Submit had an "all-or-nothing" packet submission policy that
could cause infinite retry loops when the number of packets to submit exceeded
the available queue slots. When 504+ packets needed submission to a ~500-slot
queue, the system would:
1. Set submitted_count=0 (submit nothing)
2. Add retry barrier packet
3. Trigger async handler via StoreRelaxed
4. Attempt to submit overflow packets
5. Fail again due to same space constraints
6. Repeat

Solution:
Added partial packet submission capability during overflow processing while
preserving the original "all-or-nothing" behavior for normal operations.
When processing overflow packets and insufficient space exists for all packets,
the system now submits as many packets as possible rather than none.

The fix:
- Detects overflow processing via !overflow_.empty()
- Allows partial submission: submitted_count = free_slots - barrier_reservation
- Maintains atomicity guarantees for normal packet rewrites
- Prevents infinite retry loops by ensuring forward progress

This resolves deadlocks in high-throughput scenarios while maintaining
backward compatibility and the original design intent for packet rewrite
atomicity.
2025-09-09 14:06:29 -07:00
Flora Cui e7cb108a5e [rocr-runtime] Add support for WSL DXG devices (#854)
* rocr/rocdxg: add rocdxg support

* rocr/dxg: set flags for dxg env

* rocr: ring doorbell for dtif/dxg

* rocr/dxg: sdma changes

1. align command size to 64
2. call hsaKmtQueueRingDoorbell
3. disable gcr && hdp flush


Signed-off-by: Flora Cui <flora.cui@amd.com>
Signed-off-by: Horatio Zhang <Hongkun.Zhang@amd.com>
Signed-off-by: tiancyin <tianci.yin@amd.com>
Signed-off-by: Longlong Yao <Longlong.Yao@amd.com>
2025-09-09 10:16:57 +08:00
estewart08 bc35beafbf rocr: Remove extra LibElf find_package (#767)
This should have been removed when the libelf config search
was added.
2025-09-03 20:04:05 -04:00
systems-assistant[bot] 83a10986a4 SWDEV-539130 - Log blit copy duration (#258)
Co-authored-by: Pengda Xie <pengda.xie@amd.com>
2025-09-03 10:01:47 -07:00
SaleelK 230a22b395 rocr: Workaround for peak SDMA b/w on gfx94x (#626)
* Ideally SDMA0/1/2 are the engines to use for H2D/D2H due to physical
  PCIE proximity
* Allow using same src/dst agent for SDMA query apis
2025-09-03 09:33:29 -04:00
shwetakhatri-amd 79400a1f23 rocr: GFX12+ - Fix trap handler to process SW trap ID correctly (#736)
When stochastic sampling is not active, the trap handler is incorrectly
branching to .check_exceptions, bypassing the software trap ID checks
and inturn not advancing the PC. Fixed the issue to always check software
traps regardless of PC sampling state.

Co-authored-by: Shweta Khatri <shweta.khatri@amd.com>
2025-08-25 19:20:37 -04:00
cfreeamd a013e141b7 Revert "rocr: river interface changes" (#724)
This commit reverts the following related commits which cause
test failures:

6d15779b3e rocr/driver: add PC sampling support to driver interface
56cb9390ff rocr/driver: add PC sampling support to driver interface
76bf829f09 rocr/driver: add ASAN header page management to Driver class
a47c060d6a rocr/driver: add ASAN header page management to Driver class
02d7eaf3b7 rocr: add memory sharing call to Driver interface
9312468655 rocr: add memory sharing call to Driver interface
2025-08-25 12:44:26 +05:30
David Yat Sin a1597a358a rocr: Expose flag to allocate uncached memory (#674)
Add new flag for clients to directly request uncached memory
2025-08-22 09:52:39 -04:00
David Yat Sin 87b348c51d rocr: Fix hsa_amd_pointer_info regression (#638)
Fix regression when hsa_amd_pointer_info is called on a pointer that was
allocated using non-VMM APIs. The helper function VMemoryPtrInfo should
return error when the address is not found so that PtrInfo does the
lookup via Thunk.
2025-08-21 10:25:50 -04:00
jokim-amd 700afd2d17 Re-Enable IPC DMA Bufs by default
Let ROCr use the new IPC-DMA bufs path.
2025-08-14 18:49:09 -04:00
systems-assistant[bot] 3fd8af5974 rocr: SvmPrefetch to a particular node (#294)
Previously regardless of hsa_agent passed the prefetch is always driven
to node 0, now the agent of interest may be properly prefetched.

Signed-off-by: Sunday Clement <Sunday.Clement@amd.com>
Co-authored-by: Sunday Clement <Sunday.Clement@amd.com>
Co-authored-by: systems-assistant[bot] <systems-assistant[bot]@users.noreply.github.com>
2025-08-14 09:52:45 -04:00
David Yat Sin 875fb40a03 Dayatsin/develop vmm pointer info (#305)
* rocr: hsa_amd_pointer_info to support VMEM pointers

Extend hsa_amd_pointer_info to support virtual memory addresses.

If hsa_amd_pointer_info is called on an address that is reserved but not
mapped to memory, then the pointer type will be reported as
HSA_EXT_POINTER_TYPE_RESERVED_ADDR.

If hsa_amd_pointer_info is called on an address that is mapped, then the
pointer type will be reported as HSA_EXT_POINTER_TYPE_HSA_VMEM

* rocrtst: VirtMemory_Basic_Test test for pointer info

Extend rocrtstFunc.VirtMemory_Basic_Test to test for
hsa_amd_pointer_info

* rocrtst: Add SVM Memory Test
2025-08-13 14:21:47 -04:00
mat3ix c41050d01f rocr: SDMA improvements (#326)
- When SDMA queue gets full when copying 2GB or more it blocks async
copy api
- Improve/format logging
2025-08-13 10:25:29 -04:00
systems-assistant[bot] d0a18e0eb9 [cmake] - Update search for LibElf (#256)
There is an issue with TheRock build currently. They have
a local source build of elfutils they want to use instead
of a system package. Currently, rocr uses it's own
FindLibElf.cmake module and this is inhibiting the build
from finding the libelf config built by TheRock.

Now we will first search in config mode and fallback to
module mode if nothing is found.

Authored-by: Ethan Stewart <ethan.stewart@amd.com>
Co-authored-by: systems-assistant[bot] <systems-assistant[bot]@users.noreply.github.com>
2025-08-13 09:13:45 -04:00
Alysa Liu cd5cd88d0d rocr: Fix type mismatch in printf
Format packet.workgroup_size_x correctly as a size_t.
Format packet.workgroup_size_y correctly as a size_t.
Format packet.workgroup_size_z correctly as a size_t.

Format packet.grid_size_x correctly as a size_t.
Format packet.grid_size_y correctly as a size_t.
Format packet.grid_size_z correctly as a size_t.

Format packet.group_segment_size correctly as a size_t.
Format packet.private_segment_size correctly as a size_t.

Format barrier_packet.completion_signal correctly as an address using %zx.
Format barrier_packet.dep_signal[0] correctly as an address using %zx.
Format barrier_packet.dep_signal[1] correctly as an address using %zx.
Format barrier_packet.dep_signal[2] correctly as an address using %zx.
Format barrier_packet.dep_signal[3] correctly as an address using %zx.
Format barrier_packet.dep_signal[4] correctly as an address using %zx.
Format packet.kernarg_address correctly as an address using %zx.
Format completion_signal correctly as an address using %zx.

Format this->queue_->public_handle()->id correctly as an unsigned long.
Format this->queue_->LoadReadIndexRelaxed() correctly as an unsigned long.
Format write_index correctly as an unsigned long.
Format index correctly as an unsigned long.

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


[ROCm/ROCR-Runtime commit: 53873e32f3]
2025-08-08 11:59:48 -04:00
Honglei Huang 6d15779b3e rocr/driver: add PC sampling support to driver interface
Add PC sampling functionality to the driver interface:

1. Add new PC sampling methods to Driver base class:
   - PcSamplingQueryCapabilities
   - PcSamplingCreate
   - PcSamplingDestroy
   - PcSamplingStart
   - PcSamplingStop

2. Implement PC sampling methods in KfdDriver using HSAKMT APIs:
   - Map HSAKMT status codes to HSA status codes
   - Handle resource busy conditions
   - Proper error handling for all operations

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


[ROCm/ROCR-Runtime commit: 56cb9390ff]
2025-07-31 21:48:25 +08:00
Honglei Huang 76bf829f09 rocr/driver: add ASAN header page management to Driver class
Add ASAN header page management to Driver

- Add ReplaceAsanHeaderPage and ReturnAsanHeaderPage to Driver interface
- Implement ASAN functions in KfdDriver using hsaKmt calls

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


[ROCm/ROCR-Runtime commit: a47c060d6a]
2025-07-31 21:48:25 +08:00
Honglei Huang 02d7eaf3b7 rocr: add memory sharing call to Driver interface
This change improves the abstraction of memory sharing operations by moving them
to the driver layer and adds safety checks for cross-driver operations.

- Add ShareMemory and RegisterSharedHandle methods to support memory sharing
  between processes
- Add IsDifferentDriver utility methods to check driver compatibility across
  agents/nodes
- Refactor IPC memory handling to use driver-based memory sharing instead of
  direct HSAKMT calls
- Improve error handling for memory sharing operations across different drivers

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


[ROCm/ROCR-Runtime commit: 9312468655]
2025-07-31 21:48:25 +08:00
Shweta Khatri ec6ed9586b rocr: Remove ISA check to disable stochastic support for GFX12.0 in ROCR
Feature support should be determined by KFD via the query-capabilities
IOCTL, not in ROCR.


[ROCm/ROCR-Runtime commit: a5de07d1b8]
2025-07-29 11:18:36 -04:00
Yiannis Papadopoulos 9fd770ac78 rocr: Adding conversion function from hsa_amd_vmem_alloc_handle_t to ThunkHandle
[ROCm/ROCR-Runtime commit: b7cd5cc7f1]
2025-07-26 00:55:21 -04:00