feat(vpto): add raw L1 fill primitive - #1235
Conversation
ae869fa to
2a4f104
Compare
| @@ -899,6 +899,46 @@ Cube compute step; it does not issue those transfers itself. | |||
|
|
|||
| --- | |||
|
|
|||
| #### `pto.raw_fill_l1(dst: PtrType, byte_offset: int, raw_value: int, repeat_times: int, block_num_32b: int, dst_gap_32b: int, fill_word_bits: int) -> None` | |||
There was a problem hiding this comment.
从repeat_times开始的参数应该强制使用keyword,否则很难分辨参数含义了
There was a problem hiding this comment.
已改为 keyword-only,并补充了位置参数拒绝测试
| @@ -5322,6 +5264,21 @@ def mte_gm_l1(source, destination, len_burst, *, nburst, loops=None): | |||
| ) | |||
|
|
|||
|
|
|||
| @_explicit_mode_only("pto.raw_fill_l1(...)") | |||
| def raw_fill_l1(dst, byte_offset, raw_value, repeat_times, block_num_32b, | |||
| dst_gap_32b, fill_word_bits): | |||
There was a problem hiding this comment.
fill_word_bits只支持16/32,需要在这里检查,避免漏到后面报错;其他约束检查也尽量提前
There was a problem hiding this comment.
在 PTODSL 侧要求静态 Python int,仅接受 16/32。几何字段的静态非负、上限和 offset 对齐也前置检查
| def PTO_RawFillL1Op : PTO_MicroOp<"raw_fill_l1", [ | ||
| CubeMicroOpInterface, | ||
| DeclareOpInterfaceMethods<MemoryEffectsOpInterface> | ||
| ]> { |
There was a problem hiding this comment.
fill_word_bits 用 i64 SSA 操作数表达一个纯编译期约束,是本 PR 类型设计上最值得商榷的点。 它的合法值只有 16/32,且 verifier 强制要求 matchPattern(m_ConstantInt),也就是说它语义上就是 attribute,却被建模成运行时 value:
产生了一个本可静态消除的错误类别("must be a compile-time constant");
assembly format 里每个类型都要打印,IR 噪声大;
建议改为 I64Attr(或 I64EnumAttr<"16,32">,连 verifier 里的取值检查都省掉),DSL 侧传 Python int 即可,不必 _coerce_i64。
There was a problem hiding this comment.
已修改。fill_word_bits 已改为 I64Attr,PTODSL 侧直接构造
IntegerAttr,不再作为运行时 SSA operand 或经 _coerce_i64 传递。
verifier 保留 16/32 取值校验,并继续校验其与 ui16/ui32 destination
view 一致;assembly format 也相应简化。
mouliangyu
left a comment
There was a problem hiding this comment.
发现一个需要修复的行为问题:pto.raw_fill_l1 允许任意非负 byte_offset,并在 wrapper expansion 中直接将其加到 L1 destination 上;但底层 CREATE.CBUF.MATRIX / SET_L1_2D 的 L1 地址需要 32B 对齐。
请在 verifier 中拒绝已知常量的非 32B 对齐 offset,并在文档中将动态 offset 的 32B 对齐作为调用者前置条件;建议补一个 byte_offset = 2 的负例。当前仅检查了非负性,会让该输入通过并生成未对齐访问。
mouliangyu
left a comment
There was a problem hiding this comment.
复核最新提交 232f29e:此前反馈的 32B 对齐约束已在 PTO IR verifier、PTODSL 静态参数校验、文档及 lit 负例中落实;fill_word_bits 属性化后的 wrapper、指针规范化与两条 LLVM emitter 调用链也保持一致。批准。
A3 板测失败
日志尾部 |
Summary
pto.raw_fill_l1public wrapper and canonicalpto.create_cbuf_matrixraw op for MAT/L1 fillsllvm.hivm.SET.L1.2DValidation
PTOASCompilerandpto-test-optllvm-lit -sv build-fill/test/lit/vpto --filter raw_fill_l1(5 passed)ptodsl/tests/test_jit_compile.pyptodsl/tests/test_vector_cube_ops.py(54 passed)git diff --checkNotes
32767)close [Feature] [阻塞] 新增与 create_cbuf_matrix 等价的原生 L1/CBUF 填充操作 #1227