76333 커밋

작성자 SHA1 메시지 날짜
Lancelot Six 123b2c080a rocr/trap_handler_gfx12: Properly ignore HOST_TRAP and debug_trap
The current trap handler has 2 limitations:
1) If it receives a HOST_TRAP, it clears the corresponding bit
   and notifies the host, when it should not.
2) When it is entered because of a debug trap (s_trap 3) and the
   debugger is not attached, it returns unconditionally.  However,
   if another exception is reported at the same time as the trap
   handler is entered for the debug trap (a memory violation for
   example), that other exception ends-up being ignored.

This patch addresses both of those issues.  It makes it so host traps
and debug traps are ignored when necessary.  If any other exception is
reported to the wave, we halt the wave and notify the host, and if no
other exception is reported (i.e. we entered the trap handler because of
host trap or debug trap), we return to shader code.

Other minor defects are also fixed during this refactor:
- Fixed SQ_WAVE_EXCP_FLAG_PRIV_XNACK_ERROR_SHIFT which had an incorrect
  value
- Host traps can be sent at any time, including after we have halted a
  wave.  In such case, the old approach would have:
  1) cleared the trap ID saved in ttmp6
  2) clobbered ttmp10 where part of the actual wave's PC is saved.

Change-Id: I9ecd341f4967e686233dec182b3e5b0388ef19bd
2024-08-19 21:22:13 -04:00
Lancelot Six 36a7120662 rocr/trap_handler_gfx12: Properly ignore HOST_TRAP and debug_trap
The current trap handler has 2 limitations:
1) If it receives a HOST_TRAP, it clears the corresponding bit
   and notifies the host, when it should not.
2) When it is entered because of a debug trap (s_trap 3) and the
   debugger is not attached, it returns unconditionally.  However,
   if another exception is reported at the same time as the trap
   handler is entered for the debug trap (a memory violation for
   example), that other exception ends-up being ignored.

This patch addresses both of those issues.  It makes it so host traps
and debug traps are ignored when necessary.  If any other exception is
reported to the wave, we halt the wave and notify the host, and if no
other exception is reported (i.e. we entered the trap handler because of
host trap or debug trap), we return to shader code.

Other minor defects are also fixed during this refactor:
- Fixed SQ_WAVE_EXCP_FLAG_PRIV_XNACK_ERROR_SHIFT which had an incorrect
  value
- Host traps can be sent at any time, including after we have halted a
  wave.  In such case, the old approach would have:
  1) cleared the trap ID saved in ttmp6
  2) clobbered ttmp10 where part of the actual wave's PC is saved.

Change-Id: I9ecd341f4967e686233dec182b3e5b0388ef19bd


[ROCm/ROCR-Runtime commit: 123b2c080a]
2024-08-19 21:22:13 -04:00
Jonathan R. Madsen 82a089ac0a Add kernel profiling time info to counter collection records (#1000)
* Add kernel profiling time info to counter collection records

- lib/rocprofiler-sdk/kernel_dispatch
  - added profiling_time.{hpp,cpp}
  - restructured tracing.cpp
- updated queue.cpp AsyncSignalHandler
  - gets kernel dispatch profiling time and passes to dispatch_complete and signal callbacks
- structured some header includes to reduce cyclic include probability
  - originally, including kernel_dispatch/tracing.hpp in hsa/queue.hpp created a lot of cyclic includes

* Fix kernel_dispatch.cpp includes

* Fix kernel_dispatch.cpp

- include <cstring>
- replace use of ROCPROFILER_HSA_AMD_EXT_API_ID_NONE with ROCPROFILER_KERNEL_DISPATCH_LAST

[ROCm/rocprofiler-sdk commit: b15e498945]
2024-08-19 20:05:04 -05:00
Jonathan R. Madsen b15e498945 Add kernel profiling time info to counter collection records (#1000)
* Add kernel profiling time info to counter collection records

- lib/rocprofiler-sdk/kernel_dispatch
  - added profiling_time.{hpp,cpp}
  - restructured tracing.cpp
- updated queue.cpp AsyncSignalHandler
  - gets kernel dispatch profiling time and passes to dispatch_complete and signal callbacks
- structured some header includes to reduce cyclic include probability
  - originally, including kernel_dispatch/tracing.hpp in hsa/queue.hpp created a lot of cyclic includes

* Fix kernel_dispatch.cpp includes

* Fix kernel_dispatch.cpp

- include <cstring>
- replace use of ROCPROFILER_HSA_AMD_EXT_API_ID_NONE with ROCPROFILER_KERNEL_DISPATCH_LAST
2024-08-19 20:05:04 -05:00
Maisam Arif 9253a941ca Merge amd-dev into amd-master 20240819
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Change-Id: I124d1e5d0896ae539636f72dcc8cc2182cac6954
2024-08-19 17:21:24 -05:00
Maisam Arif f0bfe32f29 Merge amd-dev into amd-master 20240819
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Change-Id: I124d1e5d0896ae539636f72dcc8cc2182cac6954


[ROCm/amdsmi commit: 9253a941ca]
2024-08-19 17:21:24 -05:00
Maisam Arif c934291940 Revert "Do not automatically download kernel header amd_hsmp.h"
This reverts commit f3cb51c08e.

Change-Id: I48ef2a6df69e7b8bc4e66009e6ee2987af8448fc
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
2024-08-19 17:20:20 -05:00
Maisam Arif 5013af7398 Revert "Do not automatically download kernel header amd_hsmp.h"
This reverts commit 18bb65a5cd.

Change-Id: I48ef2a6df69e7b8bc4e66009e6ee2987af8448fc
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>


[ROCm/amdsmi commit: c934291940]
2024-08-19 17:20:20 -05:00
David Yat Sin 88eaa834d0 Separate AsyncEventsLoop into two separate threads
This fixes an issue for missing HW events when out of HW events.

We cannot determine whether a HW event has occurred unless we call the
underlying drivers with hsaKmtWaitOnMultipleEvents_Ext. Previous logic
in Signal::WaitAny would switch to ACTIVE_WAIT state if we run out of
hardware events (signal->EopEvent() == NULL) and this would cause the
hsaKmtWaitOnMultipleEvents_Ext call to be skipped. But also, when we
have some signals without hardware events, calling
hsaKmtWaitOnMultipleEvents_Ext with a timeout of 0 so that we can poll
for remaining signals adds overhead with an IOCTL call and may cause
extra delay. Separating AsyncEventLoop into two separate threads so
that:

1. We can have a new Signal::WaitAnyExceptions to wait for HW events
This function can be simpler as it does not have to perform all the
timer calculations because it is expected to be always waiting on
hsaKmtWaitOnMultipleEvents_Ext through the lifetime of a process.

2. Signal::WaitAny does not need to have extra code to check for HW
exceptions as it only needs to handle HSA_EVENTTYPE_SIGNAL events. It
can also skip the calls to hsaKmtWaitOnMultipleEvents_Ext if needed.

Change-Id: I52ba99fd6e483e0cb477b7931a0dcc03520aa523
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 17:54:11 -04:00
David Yat Sin a3a775c944 Separate AsyncEventsLoop into two separate threads
This fixes an issue for missing HW events when out of HW events.

We cannot determine whether a HW event has occurred unless we call the
underlying drivers with hsaKmtWaitOnMultipleEvents_Ext. Previous logic
in Signal::WaitAny would switch to ACTIVE_WAIT state if we run out of
hardware events (signal->EopEvent() == NULL) and this would cause the
hsaKmtWaitOnMultipleEvents_Ext call to be skipped. But also, when we
have some signals without hardware events, calling
hsaKmtWaitOnMultipleEvents_Ext with a timeout of 0 so that we can poll
for remaining signals adds overhead with an IOCTL call and may cause
extra delay. Separating AsyncEventLoop into two separate threads so
that:

1. We can have a new Signal::WaitAnyExceptions to wait for HW events
This function can be simpler as it does not have to perform all the
timer calculations because it is expected to be always waiting on
hsaKmtWaitOnMultipleEvents_Ext through the lifetime of a process.

2. Signal::WaitAny does not need to have extra code to check for HW
exceptions as it only needs to handle HSA_EVENTTYPE_SIGNAL events. It
can also skip the calls to hsaKmtWaitOnMultipleEvents_Ext if needed.

Change-Id: I52ba99fd6e483e0cb477b7931a0dcc03520aa523
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 88eaa834d0]
2024-08-19 17:54:11 -04:00
Ioannis Assiouras 8649197dc9 SWDEV-470372 - Un-deprecate hipHostAlloc, comply with cuda and introduce hipHostAlloc flags
Change-Id: Ic7cdb10ebd3f736fe87c643bce90a28a1190f7c8


[ROCm/hip commit: e73376be0b]
2024-08-19 17:37:00 -04:00
Ioannis Assiouras e73376be0b SWDEV-470372 - Un-deprecate hipHostAlloc, comply with cuda and introduce hipHostAlloc flags
Change-Id: Ic7cdb10ebd3f736fe87c643bce90a28a1190f7c8
2024-08-19 17:37:00 -04:00
David Yat Sin 56ba584a22 rocr: Delete internal CP queues in GPU agent destructor
Delete queues used internally in agent destructor to make sure any
memory allocated by the queue objects are freed before the agent memory
regions are destroyed.

Change-Id: I4768c9cf66f77ac00a5a355f373f7f22dc266e47
2024-08-19 17:16:46 -04:00
David Yat Sin 1e51a6f56f rocr: Delete internal CP queues in GPU agent destructor
Delete queues used internally in agent destructor to make sure any
memory allocated by the queue objects are freed before the agent memory
regions are destroyed.

Change-Id: I4768c9cf66f77ac00a5a355f373f7f22dc266e47


[ROCm/ROCR-Runtime commit: 56ba584a22]
2024-08-19 17:16:46 -04:00
David Yat Sin 4ffa325c08 libhsakmt: Add two symbols to global symbols
For users still using non-static hsakmt

Change-Id: I12b1c25f0d952ed9178529cadc518c57c1aeb06d
2024-08-19 14:56:00 -04:00
David Yat Sin db39e99e5a libhsakmt: Add two symbols to global symbols
For users still using non-static hsakmt

Change-Id: I12b1c25f0d952ed9178529cadc518c57c1aeb06d


[ROCm/ROCR-Runtime commit: 4ffa325c08]
2024-08-19 14:56:00 -04:00
David Yat Sin 921471bd94 Raise system error when memory free is denied
If user application tries to free memory that is currently being used by
the underlying HW device, the hsaKmtFreeMemory function call will fail.

This would be caused by an incorrect call by the user application. A
system memory error is raised and the user application is expected to
abort when this happens.

Note: This leaves the allocation_map_ table in an inconsistent state as
this address entry is removed from it while the pointer is not actually
free'd. But re-organising the FreeMemory() function would require the
memory_lock_ to be held for much longer and may affect performance.
Since this is a very unlikely and invalid use case, we prefer to leave
the FreeMemory() function as is.

Change-Id: I24279eb98620c32d34f4c5ad1b7a0a30cb65835d
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 14:03:12 -04:00
David Yat Sin 9b4cb6bd9a Raise system error when memory free is denied
If user application tries to free memory that is currently being used by
the underlying HW device, the hsaKmtFreeMemory function call will fail.

This would be caused by an incorrect call by the user application. A
system memory error is raised and the user application is expected to
abort when this happens.

Note: This leaves the allocation_map_ table in an inconsistent state as
this address entry is removed from it while the pointer is not actually
free'd. But re-organising the FreeMemory() function would require the
memory_lock_ to be held for much longer and may affect performance.
Since this is a very unlikely and invalid use case, we prefer to leave
the FreeMemory() function as is.

Change-Id: I24279eb98620c32d34f4c5ad1b7a0a30cb65835d
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 921471bd94]
2024-08-19 14:03:12 -04:00
David Yat Sin aae4dab88e Do not generate coredump on VM fault signal event
Skip coredump generation when receiving HSA_STATUS_ERROR_MEMORY_FAULT.
We also receive a system error of type HSA_EVENTTYPE_MEMORY and generate
the coredump there. Trying to generate coredump from 2 places sometimes
causes unnecessary error message because both places try to create a
coredump file with the same name.

Change-Id: If3f03bab2c24ad71dfeff39ab411bb9ac08b337e
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 13:21:26 -04:00
David Yat Sin e7b2f765ac Do not generate coredump on VM fault signal event
Skip coredump generation when receiving HSA_STATUS_ERROR_MEMORY_FAULT.
We also receive a system error of type HSA_EVENTTYPE_MEMORY and generate
the coredump there. Trying to generate coredump from 2 places sometimes
causes unnecessary error message because both places try to create a
coredump file with the same name.

Change-Id: If3f03bab2c24ad71dfeff39ab411bb9ac08b337e
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: aae4dab88e]
2024-08-19 13:21:26 -04:00
David Yat Sin 5f943dc44e Fix compile warnings
Removing unused variables

Change-Id: I3a9811e40c9bc735d13a0330b2015576ed112026
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 13:21:08 -04:00
David Yat Sin a1e7a9f6a6 Fix compile warnings
Removing unused variables

Change-Id: I3a9811e40c9bc735d13a0330b2015576ed112026
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 5f943dc44e]
2024-08-19 13:21:08 -04:00
Shweta.Khatri fda2a395a3 PC-Sampling - gfx94x Hosttrap method support
Supports PC-Sampling on gfx94x in both CPX and SPX mode

Change-Id: Ife1e50ab08155678ea4aa2b80475b9974812c40e
2024-08-19 13:20:42 -04:00
Shweta.Khatri ce616cce30 PC-Sampling - gfx94x Hosttrap method support
Supports PC-Sampling on gfx94x in both CPX and SPX mode

Change-Id: Ife1e50ab08155678ea4aa2b80475b9974812c40e


[ROCm/ROCR-Runtime commit: fda2a395a3]
2024-08-19 13:20:42 -04:00
Lancelot Six 3646064a0e coredump: Print diagnostic in stderr when errors are detected
This patch adds output (to stderr) to indicate step in the core dump
creation failed to improve debuggability.

Change-Id: I349692e278c2d744136d7fba7f7c2e5a7ada0c06
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 13:20:20 -04:00
Lancelot Six 84135d4f49 coredump: Print diagnostic in stderr when errors are detected
This patch adds output (to stderr) to indicate step in the core dump
creation failed to improve debuggability.

Change-Id: I349692e278c2d744136d7fba7f7c2e5a7ada0c06
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 3646064a0e]
2024-08-19 13:20:20 -04:00
kjayapra-amd 457e46551d SWDEV-439234 - set access for vmm memory on graph/mempool path.
Change-Id: Idfb740dcfe6c7fe0f18231de3074a81d06e6886e


[ROCm/clr commit: e72d5a4443]
2024-08-19 13:16:30 -04:00
kjayapra-amd e72d5a4443 SWDEV-439234 - set access for vmm memory on graph/mempool path.
Change-Id: Idfb740dcfe6c7fe0f18231de3074a81d06e6886e
2024-08-19 13:16:30 -04:00
Lancelot Six 3e0d3d6d61 coredump: Improve error handling when reading VRAM
It is possible for the runtime to receive an interrupt while trying to
access VRAM data using /proc/self/mem.  In such case, pread(2) would
return -1 and set errno to -EINTR.  This is not an error case, the
pread(2) call just need to be restarted, however current implementation
would tread it as an error.

This patch changes the the implementation to correctly retry on EINTR.
While at it, this patch also handles cases where pread(2) reads less
data than originally requested.

Change-Id: I6a72fc5eda4afd90319f0d24b35c9eac6d1ff41c
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 12:20:22 -04:00
Lancelot Six 96545e914b coredump: Improve error handling when reading VRAM
It is possible for the runtime to receive an interrupt while trying to
access VRAM data using /proc/self/mem.  In such case, pread(2) would
return -1 and set errno to -EINTR.  This is not an error case, the
pread(2) call just need to be restarted, however current implementation
would tread it as an error.

This patch changes the the implementation to correctly retry on EINTR.
While at it, this patch also handles cases where pread(2) reads less
data than originally requested.

Change-Id: I6a72fc5eda4afd90319f0d24b35c9eac6d1ff41c
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 3e0d3d6d61]
2024-08-19 12:20:22 -04:00
David Yat Sin 1d1d402dcc Do not allow default mem_flags
Force mem_flags to be explicit passed in then calling Queue constructor
to avoid ambiguity with calls to Queue constructor trying to only pass
the agent_node_id.

Change-Id: Ib6fedcb9e52d6c9f35f9051dfa989343456ca368
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 12:19:32 -04:00
David Yat Sin d7a0c72661 Do not allow default mem_flags
Force mem_flags to be explicit passed in then calling Queue constructor
to avoid ambiguity with calls to Queue constructor trying to only pass
the agent_node_id.

Change-Id: Ib6fedcb9e52d6c9f35f9051dfa989343456ca368
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 1d1d402dcc]
2024-08-19 12:19:32 -04:00
Swati Rawat 4cb5c509f9 Tagging APIs from hsa_ext_amd.h for Doxygen
Change-Id: I2ab2358985442647cedbd99eca5b1140cb0b0680
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 12:17:20 -04:00
Swati Rawat 68d697cb63 Tagging APIs from hsa_ext_amd.h for Doxygen
Change-Id: I2ab2358985442647cedbd99eca5b1140cb0b0680
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 4cb5c509f9]
2024-08-19 12:17:20 -04:00
Shweta.Khatri 8176a8830f Adjusted indentation with tabs
No functional change

Change-Id: Ibe97b03f62c4affcb60d3469312c8a0b6eb11391
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
2024-08-19 12:16:58 -04:00
Shweta.Khatri 73197d1dff Adjusted indentation with tabs
No functional change

Change-Id: Ibe97b03f62c4affcb60d3469312c8a0b6eb11391
Signed-off-by: David Yat Sin <David.YatSin@amd.com>


[ROCm/ROCR-Runtime commit: 8176a8830f]
2024-08-19 12:16:58 -04:00
Chris Freehill 2722be7fa9 Add CONTRIBUTING.md file
Change-Id: I8f31240d485aa1cfc259e5882de5d73d55c95409


[ROCm/rocminfo commit: 08693587d6]
2024-08-19 16:12:31 +00:00
Chris Freehill 08693587d6 Add CONTRIBUTING.md file
Change-Id: I8f31240d485aa1cfc259e5882de5d73d55c95409
2024-08-19 16:12:31 +00:00
Ranjith Ramakrishnan 8df83d6dd6 Removed kmod dependency from rocminfo
kmod dependency is not at all required for rocminfo. Removing the same from the package dependency list

Change-Id: I58f9c4305585c5dd770ea3c6a6298c30c89c31b5


[ROCm/rocminfo commit: 63ff6a4b30]
2024-08-19 16:12:31 +00:00
Ranjith Ramakrishnan 63ff6a4b30 Removed kmod dependency from rocminfo
kmod dependency is not at all required for rocminfo. Removing the same from the package dependency list

Change-Id: I58f9c4305585c5dd770ea3c6a6298c30c89c31b5
2024-08-19 16:12:31 +00:00
James Xu a621bca303 Fix compile errors with musl>=1.2.3
Patch submitted on behalf of user AngryLoki:

The fix repeats common pattern, used for musl, 
e.g: https://github.com/void-linux/void-packages/blob/5ccf1c66a1df2d644e1a0db0a68fca321469c57e/srcpkgs/MangoHud/patches/0001-elfhacks-d_un.d_ptr-is-relative-on-non-glibc-systems.patch#L90.

Quoting:
d_un.d_ptr is relative on non glibc systems

elf(5) documents it this way, glibc diverts from this documentation

Change-Id: I815f88f127ef00c88ae827a8ad48df0d33c92467
2024-08-19 11:02:29 -04:00
James Xu e5d7121245 Fix compile errors with musl>=1.2.3
Patch submitted on behalf of user AngryLoki:

The fix repeats common pattern, used for musl, 
e.g: https://github.com/void-linux/void-packages/blob/5ccf1c66a1df2d644e1a0db0a68fca321469c57e/srcpkgs/MangoHud/patches/0001-elfhacks-d_un.d_ptr-is-relative-on-non-glibc-systems.patch#L90.

Quoting:
d_un.d_ptr is relative on non glibc systems

elf(5) documents it this way, glibc diverts from this documentation

Change-Id: I815f88f127ef00c88ae827a8ad48df0d33c92467


[ROCm/ROCR-Runtime commit: a621bca303]
2024-08-19 11:02:29 -04:00
Julia Jiang d0e10ef592 SWDEV-478511 - Create deprecated memory management section for related APIs
Change-Id: I6d802f61fe787a423e2ef65e645c6395e715fd55


[ROCm/hip commit: 0facebc71d]
2024-08-16 16:45:38 -04:00
Julia Jiang 0facebc71d SWDEV-478511 - Create deprecated memory management section for related APIs
Change-Id: I6d802f61fe787a423e2ef65e645c6395e715fd55
2024-08-16 16:45:38 -04:00
Julia Jiang 7cfa620319 SWDEV-436608 - Un-deprecate hipHostAlloc()
Change-Id: Iad319e8acb13a293911bbd9242fc9ba52ebe7fbb


[ROCm/hip commit: 9f1d4625d2]
2024-08-16 16:37:44 -04:00
Julia Jiang 9f1d4625d2 SWDEV-436608 - Un-deprecate hipHostAlloc()
Change-Id: Iad319e8acb13a293911bbd9242fc9ba52ebe7fbb
2024-08-16 16:37:44 -04:00
kjayapra-amd 30609c2e65 SWDEV-465509 - Save the handle type during import function.
Change-Id: If069abb6cd474a7b071617757041402b53575414


[ROCm/clr commit: 8ddb023512]
2024-08-16 10:55:36 -04:00
kjayapra-amd 8ddb023512 SWDEV-465509 - Save the handle type during import function.
Change-Id: If069abb6cd474a7b071617757041402b53575414
2024-08-16 10:55:36 -04:00
Ioannis Assiouras 16aaab2ab3 SWDEV-470372 - Un-deprecate hipHostAlloc, comply with cuda and introduce hipHostAlloc flags
Change-Id: I0c6910306ff98d97e9f8a6ccf467be6189e1ca86


[ROCm/hipother commit: 335bb33f1b]
2024-08-16 06:33:28 -04:00
Ioannis Assiouras 335bb33f1b SWDEV-470372 - Un-deprecate hipHostAlloc, comply with cuda and introduce hipHostAlloc flags
Change-Id: I0c6910306ff98d97e9f8a6ccf467be6189e1ca86
2024-08-16 06:33:28 -04:00