Skip to content

feat(rocprim): Implement Kernel Tuner for Sort Algorithms - #11678

Draft
NguyenNhuDi wants to merge 42 commits into
developfrom
users/NguyenNhuDi/rocprim-kernel-tuner-sort-algos
Draft

NguyenNhuDi wants to merge 42 commits into
developfrom
users/NguyenNhuDi/rocprim-kernel-tuner-sort-algos

Conversation

@NguyenNhuDi

@NguyenNhuDi NguyenNhuDi commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Motivation

Implement Kernel Tuner for Sort (merge_sort_block_merge, merge_sort_block_sort, radix_sort_block_sort, radix_sort_onesweep) algorithms.

JIRA ID: AIPRIMS-236 & EXSWSTRHPC-322

Technical Details

The rocPRIM config changes are due to running migrate.py (this updates the legacy config to be ready for Kernel Tuner)

This PR is built on top of #11617, #12119 and #11687 , do not merge until the mentioned PR has been merged

Recommended way to review this PR is to go to "Commit" and review the files per commit.

Test Plan

Local running of kernel tuner, making sure output matches legacy tuners and that there are no errors.

Test Result

Generated config files compiles, and all unit tests were passing locally

Submission Checklist

@NguyenNhuDi
NguyenNhuDi force-pushed the users/NguyenNhuDi/rocprim-kernel-tuner-sort-algos branch from 1e5198b to 1b3fc03 Compare September 3, 2026 19:19
@NguyenNhuDi NguyenNhuDi changed the title Users/nguyen nhu di/rocprim kernel tuner sort algos feat(rocprim): Implement Kernel Tuner for Sort Algorithms Sep 3, 2026
@therock-pr-bot

therock-pr-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

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/rocprim/benchmark/benchmark_device_histogram.hpp, projects/rocprim/benchmark/benchmark_device_segmented_radix_sort_keys.hpp, projects/rocprim/benchmark/benchmark_device_segmented_radix_sort_pairs.hpp, projects/rocprim/benchmark/benchmark_device_segmented_reduce.hpp, projects/rocprim/benchmark/benchmark_device_segmented_scan.hpp (+32 more); no test file found
🔎 pre-commit ✅ Pass
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled
🤖 therock-pr-bot ✅ Pass

🎉 All checks passed! This PR is ready for review.

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

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

NguyenNhuDi and others added 14 commits September 8, 2026 16:48
…totuning

I followed the instructions in projects/rocprim/tuning/README.md to confirm that the generated default config now matches the fastest specialization.

The reason this problem was hidden is because the autotuning system always picked the existing default config, which was already the fastest specialization. By passing `--exclude-default-config` to `run_tuning.py` the autotuning system before this fix commit would output terribly slow configs.
In rocPRIM there are several benchmarks which call `state.run()` multiple times during tuning, like `projects/rocprim/benchmark/benchmark_device_segmented_reduce.hpp` calling it for 5 different segment sizes.

This caused the bytes/sec that was returned to Kernel Tuner to be inaccurate, and for the same specialization to be printed 5x in the terminal, which was very confusing.
@NguyenNhuDi
NguyenNhuDi marked this pull request as ready for review September 11, 2026 17:14
@NguyenNhuDi
NguyenNhuDi requested a review from a team as a code owner September 11, 2026 17:14
@NguyenNhuDi
NguyenNhuDi force-pushed the users/NguyenNhuDi/rocprim-kernel-tuner-sort-algos branch from fa2b90f to ad31b6f Compare September 11, 2026 19:12

@amd-jmahovsky amd-jmahovsky 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.

I think the config headers look OK.

I found a few small things.

Comment thread projects/rocprim/tuning/run_tuning.py Outdated
Comment thread projects/rocprim/tuning/tuner/base_tuner.py Outdated
Comment thread projects/rocprim/tuning/tuner/base_tuner.py Outdated

@amd-jmahovsky amd-jmahovsky 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.

Two potential issues: block_size and ipt metadata swapped in one file, and CONFIG entries missing from another.

Comment thread projects/rocprim/rocprim/include/rocprim/device/detail/config/device_search_n.hpp Outdated
@NguyenNhuDi
NguyenNhuDi force-pushed the users/NguyenNhuDi/rocprim-kernel-tuner-sort-algos branch from 74c9d0f to feae0dd Compare September 11, 2026 22:20

@amd-jmahovsky amd-jmahovsky 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.

LGTM

@NguyenNhuDi
NguyenNhuDi marked this pull request as draft September 15, 2026 17:01
@NguyenNhuDi

Copy link
Copy Markdown
Contributor Author

Moving back to draft because major changes are occuring

@NguyenNhuDi
NguyenNhuDi force-pushed the users/NguyenNhuDi/rocprim-kernel-tuner-sort-algos branch from ae456d9 to be7588d Compare September 16, 2026 21:11
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.

4 participants