2
0

SWDEV-465041 - Add support for user events with DD (#321)

* SWDEV-465041 - Add support for user events with DD

User events can be replaced with HSA signals. Add the interface
to allocate HSA signal for user events and update the status on
CL_COMPLETE.
Force pinned path with DD to avoid blocking calls. Pinned memory
can be released only when the command is complete.
Simplify device enqueue path to use generic kernel arg buffer and
signals

* Fix notifyCmdQueue() logic for OCL

* Avoid blocking calls in OCL with DD

* Add event  destruciton in a case of the failure.

[ROCm/clr commit: 2305f8ae56]
Este cometimento está contido em:
Andryeyev, German
2025-08-12 19:04:36 -04:00
cometido por GitHub
ascendente a7ed228997
cometimento 6df9a49437
13 ficheiros modificados com 168 adições e 105 eliminações
+14 -3
Ver ficheiro
@@ -269,7 +269,9 @@ bool Event::notifyCmdQueue(bool cpu_wait) {
ScopedLock l(notify_lock_);
if ((status() > CL_COMPLETE) && (nullptr != queue) &&
// If HW event was assigned, then notification can be ignored, since a barrier was issued
(HwEvent() == nullptr) &&
// @note: Force the marker always in OCL for now, since OCL events require precise
// sequence of the status update
((HwEvent() == nullptr) || !amd::IS_HIP) &&
!notified_.test_and_set()) {
// Make sure the queue is draining the enqueued commands.
amd::Command* command = new amd::Marker(*queue, false, nullWaitList, this, cpu_wait);
@@ -364,8 +366,17 @@ void Command::enqueue() {
// Notify all commands about the waiter. Barrier will be sent in order to obtain
// HSA signal for a wait on the current queue
for (const auto& event : eventWaitList()) {
event->notifyCmdQueue(!kCpuWait);
for (const auto &event: eventWaitList()) {
if (!amd::IS_HIP && event->command().type() == CL_COMMAND_USER) {
if (event->status() >= CL_COMPLETE) {
reinterpret_cast<amd::UserEvent*>(event)->AddDependent(this);
} else {
setStatus(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
return;
}
} else {
event->notifyCmdQueue(!kCpuWait);
}
}
// The batch update must be lock protected to avoid a race condition