Port single-core scan from pto-kernels#113
Merged
Merged
Conversation
Collaborator
Author
|
Updated to main (PTOAS 0.27). Examples all passing: Tests all passing: |
Comment on lines
+179
to
+191
| pto.store(cTile, svOut) | ||
| pto.record_wait_pair("STORE_ACC", "LOAD", 2) | ||
|
|
||
| pto.sync_set(pto.PIPE_FIX, 0) | ||
| pto.sync_wait(pto.PIPE_MTE3, 1) | ||
|
|
||
| with pto.vector_section(): | ||
| tvOut_vec = pto.as_tensor( | ||
| tensor_type, | ||
| ptr=y_ptr, | ||
| shape=[total_len // cTILE_SIZE, cTILE_SIZE], | ||
| strides=[cTILE_SIZE, c1], | ||
| ) |
Collaborator
There was a problem hiding this comment.
So the with pto.vector_section() syntax actually works for mix kernels as long as using manual sync + explicit sync_set/sync_wait... The syntax is quite different from the entry + subfunction + push/pop + auto-sync as in #98 . So we have two styles to write mix kernels now. They can co-exist for now, but will need to unify the style in the future.
learning-chip
approved these changes
May 11, 2026
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.
Mostly straight port of scan algorithm from huawei-csl/pto-kernels#101. I took a different approach with syncing, instead of
TPUSH/TPOPsemantics, I relied onsync_set/sync_waitcalls. As a QoL improvement, I made the insertion of the FFTS commands automatic`, the interface for that can be further polished. Other small changes to interface had to be made to expose scalar ops and the sync ops.The implementation follows the one from pto-kernels, however I encountered issues with the running sum calculation, which was initialized outside the loop and then updated in the loop. The compiler couldn't figure out that the loop will execute multiple times, so it removed the
running_sumcompletely. As a workaround, we now store it in a tile. Furthermore, I couldn't figure out how to usepto.record_wait_pairto sync on the scalar pipe and we can't putPIPE_Sdirectly, so as a workaround I used barrier. We should look into options of exposing scalar pipe in the sync interface in PTOAS.