Skip to content

feat(ptodsl): redesign tileop simt/simd/cube subkernel surface#867

Draft
jimmychou0 wants to merge 3 commits into
hw-native-sys:mainfrom
jimmychou0:ptodsl-tileop-simt-redesign
Draft

feat(ptodsl): redesign tileop simt/simd/cube subkernel surface#867
jimmychou0 wants to merge 3 commits into
hw-native-sys:mainfrom
jimmychou0:ptodsl-tileop-simt-redesign

Conversation

@jimmychou0

@jimmychou0 jimmychou0 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • redesign the PTODSL tileop / simd / cube subkernel surface so decorated helpers stay naked tileop helpers while inline scopes preserve explicit vector/cube sections
  • add backend support for tileop helper summary inference, contract verification, section materialization, memory planning, and sync/normalization integration
  • support scalar-return tileop helpers, refresh PTODSL docs/tests, align low-precision lit expectations, and fix PTODSL regression target dependencies

Validation

  • ninja -C build-local-vpto check-pto
  • python -m unittest discover -s ptodsl/tests -p 'test_*.py' under the PTOAS build environment
  • ninja -C build-local-vpto check-dsl

Refs #859

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jimmychou0 jimmychou0 force-pushed the ptodsl-tileop-simt-redesign branch from cef0751 to fab48f5 Compare June 26, 2026 07:49
@jimmychou0 jimmychou0 changed the title feat(ptodsl): add tileop subkernel surface feat(ptodsl): redesign tileop simt/simd/cube subkernel surface Jun 26, 2026
@jimmychou0 jimmychou0 force-pushed the ptodsl-tileop-simt-redesign branch 6 times, most recently from 6c5286b to db7b13d Compare June 27, 2026 07:40
@jimmychou0 jimmychou0 force-pushed the ptodsl-tileop-simt-redesign branch from db7b13d to 7c39285 Compare June 27, 2026 08:08
}

def PTOMaterializeTileOpSections
: Pass<"pto-materialize-tileop-sections", "func::FuncOp"> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NormalizeUncoveredTileSections pass和这个pass是相同功能,建议直接在NormalizeUncoveredTileSections中加逻辑处理

- **helper 内禁止 `alloc_tile`/`reserve_buffer`/`TAlloc`/任何需 PlanMemory 为 callee-local 规划的 op;内部 tile buffer 必须来自 caller operand。内部 vreg/mask/scalar 临时可存但不跨边界。**
- body 允许 tload/tstore、vector ops、scalar(PIPE_S) ops、cube ops、`pipe_barrier` 同步。
- 不允许 host tensor/TensorSpec/vreg/mask/pipe_handle 跨边界;不允许 SIMT-only op。
- **tileop 不能在另一 tileop/section 内调用**(避免 inline 后嵌套 section,`VPTOSplitCVModule:113-118` 禁嵌套 section)。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里感觉可以在inline时做特殊处理,或者让VPTOSplitCVModule适配下,按理说同类section嵌套也是合理的

@reedhecre

reedhecre commented Jun 29, 2026

Copy link
Copy Markdown

Codex Review

该评论由 review 机器人自动更新。

Summary

Review failed at stage codex-review: exit=1

Findings

未生成结构化 findings,因为 review 过程提前失败。

Log Tail

#include "mlir/Dialect/Func/IR/FuncOps.h"
exec
/bin/bash -lc "sed -n '1,220p' lib/PTO/Transforms/PTOPlanMemory.cpp" in /tmp/ptoas-pr-review-monitor/runs/20260629_223529_pr867/repo succeeded in 0ms:
// Copyright (c) 2026 Huawei Technologies Co., Ltd.
// This program is free software, you can redistribute it and/or modify it under the terms and conditions of
// CANN Open Software License Agreement Version 2.0 (the "License").
// Please refer to the License for details. You may not use this file except in compliance with the License.
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
// See LICENSE in the root of the software repository for the full text of the License.

//===- PlanMemory.cpp ----Plan Buffer Memory Address ----------------------===//
//===----------------------------------------------------------------------===//

#include "PTOPlanMemory.h"

#include "PTO/IR/PTOTypeUtils.h"

#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/AsmState.h"
#include "mlir/Transforms/DialectConversion.h"
exec
/bin/bash -lc "sed -n '1,220p' lib/PTO/Transforms/Utils.cpp" in /tmp/ptoas-pr-review-monitor/runs/20260629_223529_pr867/repo succeeded in 0ms:
// Copyright (c) 2026 Huawei Technologies Co., Ltd.
// This program is free software, you can redistribute it and/or modify it under the terms and conditions of
// CANN Open Software License Agreement Version 2.0 (the "License").
// Please refer to the License for details. You may not use this file except in compliance with the License.
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
// See LICENSE in the root of the software repository for the full text of the License.

#include "PTO/IR/PTO.h"
#include "Utils.h"
#include "llvm/Support/ErrorHandling.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"

#define DEBUG_TYPE "pto-utils"
#define DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")
#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
#define DBGSNL() (llvm::dbgs() << "\n")
exec
/bin/bash -lc 'grep -RIn "@pto.simt[''^
]*'"\\n.*return\\|def .*@pto.simt\" ptodsl/tests ptodsl/examples test | sed -n '1,240p'" in /tmp/ptoas-pr-review-monitor/runs/20260629_223529_pr867/repo succeeded in 0ms:
grep: Invalid regular expression
exec
/bin/bash -lc "grep -n \"def AicInitializePipeOp\\|def AivInitializePipeOp\" -A20 -B5 include/PTO/IR/PTOOps.td" in /tmp/ptoas-pr-review-monitor/runs/20260629_223529_pr867/repo succeeded in 0ms:
1599-
1600-//===----------------------------------------------------------------------===//
1601-// Frontend TPUSH/TPOP Pipe Communication Ops
1602-//===----------------------------------------------------------------------===//
1603-
1604:def AicInitializePipeOp : PTO_Op<"aic_initialize_pipe",
1605-                                 [AttrSizedOperandSegments]> {
1606-  let summary = "Frontend Cube-kernel pipe initialization";
1607-
1608-  let arguments = (ins
1609-      DefaultValuedOptionalAttr<I32Attr, "0">:$id,
1610-      I8Attr:$dir_mask,
1611-      I32Attr:$slot_size,
1612-      OptionalAttr<I32Attr>:$slot_num,
1613-      OptionalAttr<I32Attr>:$local_slot_num,
1614-      OptionalAttr<BoolAttr>:$nosplit,
1615-      Optional<PtrType>:$gm_slot_buffer,
1616-      Optional<TensorViewType>:$gm_slot_tensor,
1617-      Optional<I32>:$c2v_consumer_buf,
1618-      Optional<I32>:$v2c_consumer_buf
Reconnecting... 1/5 (stream disconnected before completion: Transport error: network error: error decoding response body)
exec
/bin/bash -lc "grep -n \"createPTOInstantiateAndInlineOpLibPass\\|InlineOpLib\" -n tools/ptoas/ptoas.cpp lib/PTO/Transforms/PTOInstantiateAndInlineOpLib.cpp | sed -n '1,240p'" in /tmp/ptoas-pr-review-monitor/runs/20260629_223529_pr867/repo succeeded in 0ms:

ERROR: Selected model is at capacity. Please try a different model.
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260629_223529_pr867/codex_last_message.json
tokens used
684,255
===== END STAGE codex-review rc=1 @ 2026-06-29 23:24:56 =====

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants