Add scan (prefix sum) operations support#39
Merged
maleadt merged 6 commits intoJuliaGPU:mainfrom Jan 30, 2026
Merged
Conversation
Contributor
Author
|
This depends on #37 PR. |
This commit adds support for scan (parallel prefix sum) operations to cuTile, based on the IntegerReduce branch and commit 0c9ab90. Key changes: - Added encode_ScanOp! to bytecode encodings for generating ScanOp bytecode - Added encode_scan_identity_array! to reuse existing identity encoding - Added scan intrinsic implementation using operation_identity from IntegerReduce - Added scan() and cumsum() public APIs with proper 1-indexed to 0-indexed axis conversion - Added comprehensive codegen tests for scan operations - Added scankernel.jl example demonstrating CSDL scan algorithm Features: - Supports cumulative sum (cumsum) for float and integer types - Supports both forward and reverse scan directions - Reuses FloatIdentityOp and IntegerIdentityOp from IntegerReduce - Uses operation_identity function for cleaner identity value creation - 1-indexed axis parameter (consistent with reduce operations) - Preserves tile shape (scan is an element-wise operation along one dimension) Tests: - All 142 codegen tests pass (including 6 new scan tests) - Scankernel.jl example runs successfully with CSDL algorithm - Clarify that it demonstrates device-side scan operation - Add note that test might occasionally fail (race condition in phase 2 loop) Minor comment improvements in scankernel.jl example - Clarify that it demonstrates device-side scan operation - Add note that test might occasionally fail (race condition in phase 2 loop)
3731b87 to
368e6c5
Compare
Contributor
Author
|
This will fail. Still uses IdentityOp. |
Contributor
Author
|
@maleadt Thanks. |
Member
|
I moved the example into the test suite, if you don't mind. I'd rather keep the |
Contributor
Author
Completely agree. I updated comments too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds support for scan (parallel prefix sum) operations to cuTile,
based on the IntegerReduce branch and commit 0c9ab90.
Key changes:
- Added scankernel.jl example demonstrating two pass chained scan algorithmFeatures:
- 1-indexed axis parameter (consistent with reduce operations)Tests: