Skip to content

feat(hsakmt): add event age support on Windows and spin SDMA completion wait - #14978

Merged
mikeqinamd merged 2 commits into
developfrom
users/mqin/win-event-age
Nov 6, 2026
Merged

mikeqinamd merged 2 commits into
developfrom
users/mqin/win-event-age

Conversation

@mikeqinamd

Copy link
Copy Markdown
Contributor

Motivation

Right now we use auto-reset events in Windows for notification, and this can cause deadlocks when multiple threads are waiting on the same event. By design, auto-reset events in Windows wake up one waiter and reset the event, so the other waiters will wait for the next rounds of notification. Currently, this shows up as a wait timeout instead of indefinite wait because we artificially cap the timeout to 6 seconds. Using ROCR_DISABLE_WAIT_TIMEOUT=1 can reproduce the hang when running Geekbench 5.

Technical Details

This PR introduces an event age implementation for Windows. All waiters before the current age will return, and it also shows better performance under Geekbench 5.

However, this alone does not seem sufficient. The SDMA thread can still miss some notifications at the beginning of the run. We do not know the root cause of this, and for this PR, we simply set it to busy waiting. The p99 wait is 11ms, so it has minimal performance impact under Geekbench 5.

Issue Tracking

JIRA ID : AIRUNTIME-2653

Test Plan

Geekbench 5.

Test Result

With ROCR_DISABLE_WAIT_TIMEOUT=1 and GPU_ENABLE_PAL=0

System Information
  Operating System              Microsoft Windows 11 Pro (64-bit)
  Operating System              2009
  Model                         ASUS System Product Name
  Motherboard                   ASUSTeK COMPUTER INC. TUF GAMING X870-PLUS WIFI
  Northbridge                   AMD ID14D8 00
  Southbridge                   AMD Carrizo FCH 51
  BIOS                          American Megatrends Inc. 1644

Processor Information
  Name                          AMD Ryzen 9 9900X 12-Core Processor
  Topology                      1 Processor, 12 Cores, 24 Threads
  Identifier                    AuthenticAMD Family 26 Model 68 Stepping 0
  Base Frequency                4.40 GHz
  Maximum Frequency             5610 MHz
  L1 Instruction Cache          32.0 KB x 12
  L1 Data Cache                 48.0 KB x 12
  L2 Cache                      1.00 MB x 12
  L3 Cache                      32.0 MB x 2

Memory Information
  Size                          126 GB

OpenCL Information
  Platform Vendor               Advanced Micro Devices, Inc.
  Platform Name                 AMD Accelerated Parallel Processing
  Device Vendor                 Advanced Micro Devices, Inc.
  Device Name                   gfx1201
  Board Name                    AMD Radeon RX 9070 XT
  Maximum Frequency             2400 MHz
  Compute Units                 32
  Device Memory                 15.4 GB

Before:

Run 1

OpenCL
  Sobel                        177309         45.9 Gpixels/sec
  Canny                        126620         7.93 Gpixels/sec
  Stereo Matching              317410        448.9 Gpixels/sec
  Histogram Equalization        80476         14.2 Gpixels/sec
  Gaussian Blur                191848         10.5 Gpixels/sec
  Depth of Field               275997         3.20 Gpixels/sec
  Face Detection                55100         424.2 images/sec
  Horizon Detection             22240        548.2 Mpixels/sec
  Feature Matching              57105         1.18 Gpixels/sec
  Particle Physics             704418              18762.8 FPS
  SFFT                         126614              1.74 Tflops

Benchmark Summary
  OpenCL Score                130662

Run2

OpenCL
  Sobel                        178351         46.1 Gpixels/sec
  Canny                        146318         9.16 Gpixels/sec
  Stereo Matching              312652        442.2 Gpixels/sec
  Histogram Equalization        85528         15.1 Gpixels/sec
  Gaussian Blur                181063         9.95 Gpixels/sec
  Depth of Field               274182         3.18 Gpixels/sec
  Face Detection                46851         360.7 images/sec
  Horizon Detection             22592        556.9 Mpixels/sec
  Feature Matching              54247         1.12 Gpixels/sec
  Particle Physics             720894              19201.6 FPS
  SFFT                         122896              1.69 Tflops

Benchmark Summary
  OpenCL Score                129801

Run3

OpenCL
<Deadlock here>

After:

Run1

OpenCL
  Sobel                        162562         42.1 Gpixels/sec
  Canny                        144716         9.06 Gpixels/sec
  Stereo Matching              305845        432.6 Gpixels/sec
  Histogram Equalization        82899         14.6 Gpixels/sec
  Gaussian Blur                188831         10.4 Gpixels/sec
  Depth of Field               415984         4.82 Gpixels/sec
  Face Detection                53828         414.4 images/sec
  Horizon Detection             71685         1.77 Gpixels/sec
  Feature Matching              57955         1.20 Gpixels/sec
  Particle Physics             698205              18597.3 FPS
  SFFT                         114135              1.57 Tflops

Benchmark Summary
  OpenCL Score                149519

Run2

OpenCL
  Sobel                        162509         42.0 Gpixels/sec
  Canny                        143824         9.00 Gpixels/sec
  Stereo Matching              300965        425.6 Gpixels/sec
  Histogram Equalization        83366         14.7 Gpixels/sec
  Gaussian Blur                187336         10.3 Gpixels/sec
  Depth of Field               391381         4.54 Gpixels/sec
  Face Detection                54261         417.8 images/sec
  Horizon Detection             63023         1.55 Gpixels/sec
  Feature Matching              58069         1.20 Gpixels/sec
  Particle Physics             603168              16065.9 FPS
  SFFT                         114045              1.57 Tflops

Benchmark Summary
  OpenCL Score                144813

Run3

OpenCL
  Sobel                        161366         41.8 Gpixels/sec
  Canny                        144405         9.04 Gpixels/sec
  Stereo Matching              300425        424.9 Gpixels/sec
  Histogram Equalization        83493         14.7 Gpixels/sec
  Gaussian Blur                184641         10.1 Gpixels/sec
  Depth of Field               387630         4.49 Gpixels/sec
  Face Detection                54741         421.5 images/sec
  Horizon Detection             62910         1.55 Gpixels/sec
  Feature Matching              57306         1.19 Gpixels/sec
  Particle Physics             696911              18562.8 FPS
  SFFT                         114215              1.57 Tflops

Benchmark Summary
  OpenCL Score                146299

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocr-runtime/libhsakmt/include/impl/wddm/device.h, projects/rocr-runtime/libhsakmt/include/impl/wddm/event.h, projects/rocr-runtime/libhsakmt/include/impl/wddm/queue.h, projects/rocr-runtime/libhsakmt/src/dxg/events.cpp, projects/rocr-runtime/libhsakmt/src/dxg/wddm/device.cpp (+3 more); no test file found
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@cfreeamd cfreeamd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-assisted pre-review (for @cfreeamd)

[Required] PR title format: "Use event age under Windows and use spin in SDMA thread" does not follow the required type(component): format. ROCm squash-merges; this title becomes the permanent commit title. Suggest: feat(hsakmt): add event age support on Windows and spin SDMA completion wait. Note also that these are two logically separate changes (event-age protocol + SDMA workaround) — consider splitting the commits or at minimum reflecting both in the title.

CMakeLists.txt, device.h, device.cpp, events.cpp, and runtime.h changes look correct. The new lock-free WaitQueue/WaitEntry protocol in event.cpp is correct (the refcnt_/cnt barrier protocol prevents race conditions; QueryMultipleEvents logic is sound).

@mikeqinamd
mikeqinamd force-pushed the users/mqin/win-event-age branch 2 times, most recently from e68db44 to 4561f2c Compare November 4, 2026 20:43
Because Windows auto-reset event are 1:1, we cannot have multiple signals sharing a single event.
@mikeqinamd
mikeqinamd force-pushed the users/mqin/win-event-age branch from 4561f2c to e3effe7 Compare November 4, 2026 20:58

@cfreeamd cfreeamd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-assisted pre-review (for @cfreeamd) — follow-up after author replies

[Required] PR title still needs type(component): prefix before merge. Suggested: feat(hsakmt): add event age support on Windows and use spin for SDMA completion wait.

All other prior findings resolved (see inline thread replies). One new question on the SDMA timeout fallthrough below.

@cfreeamd cfreeamd changed the title Use event age under Windows and use spin in SDMA thread feat(hsakmt): add event age support on Windows and spin SDMA completion wait Nov 5, 2026
@mikeqinamd
mikeqinamd merged commit 8b41e90 into develop Nov 6, 2026
409 of 414 checks passed
@mikeqinamd
mikeqinamd deleted the users/mqin/win-event-age branch November 6, 2026 14:43
@jungx098 jungx098 mentioned this pull request Nov 7, 2026
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants