-
Notifications
You must be signed in to change notification settings - Fork 66
[PTODSL] Add SIMT micro-op API surface #798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zhangstevenunity
merged 8 commits into
hw-native-sys:main
from
jimmychou0:ptodsl-simt-batch1
Jun 15, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2ae8501
feat(ptodsl): add simt launch query APIs
jimmychou0 0a802ef
feat(ptodsl): add simt micro-op wrappers
jimmychou0 bf02b2e
fix(ptodsl): specialize simt helpers by signature
jimmychou0 b38f5fd
test(ptodsl): declare pipe peer fixture explicitly
jimmychou0 ec88c06
docs(ptodsl): update simt helper design
jimmychou0 6a06a8b
feat(ptodsl): document and expose simt entry resources
jimmychou0 6dfd047
fix(ptodsl): resolve simt reserved-buffer peer symbols
jimmychou0 2aa540e
Add PTODSL SIMT micro-op surface
jimmychou0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -539,7 +539,7 @@ instruction appears to operate on a single element (`lds`, `sts`, `a + b`), | |
| but the same instruction is issued across a large number of work-items | ||
| simultaneously. | ||
|
|
||
| **Signature**: `@pto.simt(fn=None, *, name=None, target="a5")` | ||
| **Signature**: `@pto.simt(fn=None, *, name=None, target="a5", max_threads=None, max_regs=None)` | ||
|
|
||
| <!-- ptodsl-doc-test: {"mode":"compile_fragment","fixture":"kernel_entry.simt_signature","symbol":"kernel_entry_simt_signature_probe","compile":{"BLOCK":8}} --> | ||
| ```python | ||
|
|
@@ -573,13 +573,90 @@ def blend_output_rows( | |
| scalar.store(o_next, o_next_tile[row, col]) | ||
| ``` | ||
|
|
||
| SIMT kernels read and write individual scalar elements from tiles. The unit | ||
| executes the same scalar instruction across many work-items in parallel, making | ||
| it efficient for per-element operations. | ||
| SIMT kernels read and write individual scalar elements from tiles or typed | ||
| pointers. The unit executes the same scalar instruction across many work-items | ||
| in parallel, making it efficient for per-element operations. | ||
|
|
||
| #### SIMT resource attributes | ||
|
|
||
| Optional `max_threads` and `max_regs` arguments attach VPTO resource attributes | ||
| to the generated `pto.simt_entry` helper. | ||
|
|
||
| **Signature**: `@pto.simt(fn=None, *, name=None, target="a5", max_threads=None, max_regs=None)` | ||
|
|
||
| **Parameters**: | ||
|
|
||
| | Parameter | Type | Default | Description | | ||
| |-----------|------|---------|-------------| | ||
| | `max_threads` | positive Python `int` | backend default `1024` | Compile-time launch envelope for this SIMT helper | | ||
| | `max_regs` | positive Python `int` | backend default `32` | Scalar register budget per work-item | | ||
|
|
||
| `max_threads` is not the launch size. The actual work-item count comes from the | ||
| SIMT launch dimensions. Both arguments must be Python integers known at trace | ||
| time, greater than zero, and fit in signless `i32`. They are only valid on | ||
| decorated SIMT helper functions, not inline `with pto.simt():` scopes. | ||
|
|
||
| **Example**: | ||
|
|
||
| <!-- ptodsl-doc-test: {"mode":"compile","symbol":"kernel_entry_simt_resource_probe","compile":{}} --> | ||
| ```python | ||
| @pto.simt(max_threads=256, max_regs=48) | ||
| def write_tid(dst: pto.ptr(pto.i32, "gm")): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 后面我想把pto.simd/pto.cube/pto.simt的接口规范成Tile/TensorView/scalar,这样自定义的simt op也能被公共pass优化。 |
||
| tid = pto.get_tid_x() | ||
| idx = scalar.index_cast(tid) | ||
| pto.stg(tid, dst, idx) | ||
|
|
||
|
|
||
| @pto.jit(target="a5") | ||
| def kernel_entry_simt_resource_probe(dst: pto.ptr(pto.i32, "gm")): | ||
| write_tid[128, 1, 1](dst) | ||
| ``` | ||
|
|
||
| **Invocation modes**: can be called from `@pto.jit` in either mode, or used | ||
| inline with `with pto.simt():` (Section 3.4). | ||
|
|
||
| #### Explicit SIMT launch dimensions | ||
|
|
||
| Calling a decorated SIMT helper directly uses the default launch descriptor | ||
| emitted by the tracer. Use indexed launch syntax when the launch dimensions must | ||
| be authored explicitly. `pto.simt_launch(...)` is the equivalent functional | ||
| form. | ||
|
|
||
| **Signatures**: | ||
|
|
||
| ```python | ||
| body[dim_x, dim_y, dim_z](*args, **static_kwargs) | ||
| pto.simt_launch(body, *args, dims=(dim_x, dim_y, dim_z), **static_kwargs) | ||
| ``` | ||
|
|
||
| **Parameters**: | ||
|
|
||
| | Parameter | Type | Description | | ||
| |-----------|------|-------------| | ||
| | `body` | `@pto.simt` function | SIMT entry body to launch | | ||
| | `*args` | PTO values | Runtime arguments passed to the SIMT body | | ||
| | `dim_x`, `dim_y`, `dim_z` | `i32`-compatible values | Launch dimensions in source-level `x, y, z` order | | ||
| | `**static_kwargs` | hashable Python values | Trace-time specialization arguments for the SIMT body | | ||
|
|
||
| **Returns**: None. | ||
|
|
||
| **Example**: | ||
|
|
||
| <!-- ptodsl-doc-test: {"mode":"compile","symbol":"kernel_entry_simt_launch_probe","compile":{}} --> | ||
| ```python | ||
| @pto.simt | ||
| def fill_tid(dst: pto.ptr(pto.i32, "gm")): | ||
| tid = pto.get_tid_x() | ||
| pto.stg(tid, dst, scalar.index_cast(tid)) | ||
|
|
||
|
|
||
| @pto.jit(target="a5") | ||
| def kernel_entry_simt_launch_probe(dst: pto.ptr(pto.i32, "gm")): | ||
| fill_tid[32, 1, 1](dst) | ||
| ``` | ||
|
|
||
| Specific SIMT micro-op APIs are documented in Chapter 13. | ||
|
|
||
| ## 3.4 Inline context manager syntax | ||
|
|
||
| In addition to the decorator form, each sub-kernel unit provides a context | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.