with pto.simt(x, y, z) - Inline SIMT 实现#927
Conversation
Codex Review该评论由 review 机器人自动更新。
SummaryReview failed at stage Findings未生成结构化 findings,因为 review 过程提前失败。 Log Tail |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
| - `with pto.simt(dim_x, dim_y, dim_z):` is a true inline SIMT scope: PTODSL | ||
| emits `pto.store_vfsimt_info` at the current location, keeps the block body in | ||
| the enclosing kernel function, and does not create an anonymous helper or | ||
| `pto.simt_launch`. |
There was a problem hiding this comment.
这里我没明白,用户写with pto.simt(x, y, z): 的本意就是想launch一个simt函数啊,如果不发射pto.simt_launch要如何实现呢?
Zhendong404
left a comment
There was a problem hiding this comment.
重点看了 inline simt launch 这条路径,整体上我理解这个方案的核心收益是:把 SIMT outline / ABI 收口到 PTOAS,DSL 只保留 lexical region,前端会更轻,也更方便后续在 PTOAS 里统一做 SIMT 相关变换。相对地,代价是新的中间形态 pto.section.simt 需要所有相关 verifier / lowering / backend 一起跟上,否则就容易出现“前端能写、后端不能过”的分叉。
当前我看到两个比较具体的问题:
-
emitc路径看起来没有覆盖到这个新形态。DSL 现在会把 inlinewith pto.simt():发成pto.section.simt,但pto-outline-simt-sections只接在 VPTO pipeline 里,emitcpipeline 这边没有对应处理。如果emitc侧也允许走到 inline simt,这里会留下未处理 IR。 -
SIMT scope 的语义覆盖还没完全对齐。这个 PR 已经把
syncthreads/threadfence/threadfence_block放宽到pto.section.simt,但keep/resume这类 op 目前看还是只认pto.simt_entry。也就是说 inline SIMT 如果后面要支持 keep/resume,这里还会在 outline 之前被 verifier 拒掉。
从方案角度看,我觉得“DSL 标记 region,PTOAS 做 outline”相比“DSL 直接生成 outline helper”主要是这几个 tradeoff:
- 优势:前端职责更单一;SIMT ABI 只在 PTOAS 一处定义;后面如果要在 outline 前看 lexical 邻接关系,region 形态会更好做。
- 劣势:管线耦合更强;所有后端和 verifier 都要认识这层新 IR;问题会更偏 pipeline integration,而不是前端本地闭合。
- 风险:后续只要还有任何 pass / verifier / backend 默认把
pto.simt_entry当成唯一 SIMT 作用域,就会继续出现类似漏点。
所以我对方向本身没有异议,但建议至少把 backend 覆盖边界和 section.simt 支持范围说清楚,并把剩余只认 pto.simt_entry 的点再系统扫一遍。
| @@ -2605,6 +2530,7 @@ static void prepareVPTOForEmission(PassManager &pm) { | |||
| // backend checks catch any illegal barrier that still leaks through. | |||
| kernelModulePM.addNestedPass<func::FuncOp>( | |||
| pto::createLoweringSyncToPipePass()); | |||
| kernelModulePM.addPass(pto::createPTOOutlineSIMTSectionsPass()); | |||
There was a problem hiding this comment.
这个outline的时机会不会太晚了,导致前面所有pass都要对没有outline的SIMT Section做适配
TODO:
需要看一下和 叠加pto.persistent还有什么没考虑到的:#925
实现:
需求参考:
mouliangyu#495
https://github.com/KurrinQu/PTOAS/blob/qkl/ptoas-persistent-simt-fragment-design/docs/designs/ptoas_persistent_simt_fragment_plan.md