

Pull Request已成功合入, 合并人@ascend-robot
(感谢 SanidhyaBarara 的贡献)变更摘要
此 PR 为华为 AscendNPU SIMT 后端新增了全局 scratch 内存(global scratch memory)的分阶段(staging)支持,主要应用于 TileDotLoads 中的非加载操作数分阶段和 ConvertLayout 操作的跨布局转换。核心思路是:当共享内存(SMEM)预算不足以容纳分阶段缓冲区时,允许回退到全局内存(GMEM)路径。为此,PR 将原有的 SharedMemConflictModel 重构为更通用的 DotTilingCostModel,新增了 storeDGlobal/loadDGlobal 接口,引入了 enable-global-scratch-allocation(默认关闭)的管道选项,并重命名了 ConvertSharedPtrToMemDesc → LowerDotBuffersAndSharedMem 以更准确地反映其职责扩展。
主要改动
-
成本模型重构:
SharedMemConflictModel重命名为DotTilingCostModel,AscendSmemGeometry重命名为AscendMemGeometry并新增peakBandwidthBytesPerCycleGmem()方法;StagingDecisionInputs从单一roundTripBytes拆分为roundTripBytesA/roundTripBytesB,新增smemStageA/smemStageB标志和stagingFixedOverheadCyclesGmem字段,stageThroughSmem改为stageThroughMem,使成本模型能分别评估 SMEM 和 GMEM 路径的开销。 -
新增全局内存加载/存储接口:在
TargetInfo和TargetInfoBase中新增storeDGlobal和loadDGlobal虚方法,TargetInfo.cpp中实现了完整的全局内存存取逻辑,支持向量化、子字节元素处理、大宽度拆分,并使用ascend_dpx::StoreOp/ascend_dpx::LoadOp及L2_CACHE_HINT_NORMAL_FV缓存策略。 -
StageNonLoadOperandPattern支持全局 scratch:当totalStageBytes > smemBudgetBytes且allowGlobalScratch为真时,模式不再直接失败,而是按需将 A 或 B 操作数的地址空间切换为kGlobalMemoryAddressSpace(ptr<1>),并通过appendScratchArg向函数追加带bishengir.scratch_global标记的参数,使非加载操作数可通过全局内存完成分阶段。 -
ConvertLayoutOp全局内存路径:新增ConvertLayoutOpConversionGM模式,在Allocation.cpp中当allowGlobalScratch开启且ConvertLayoutOp的共享内存偏移量超出smemSize时,将其标记为store_to_gmem并分配全局 scratch 偏移;lowerLdStShared新增switchToGM参数,在 GMEM 路径下调用storeDGlobal/loadDGlobal替代storeDShared/loadDShared。 -
管道与 Pass 重命名:
ConvertSharedPtrToMemDescpass 重命名为LowerDotBuffersAndSharedMem(lower-dot-buffers-and-shared-mem),新增SetAllowGlobalScratchAttrpass(set-allow-global-scratch-attr)用于将命令行选项写入模块属性ttg.enable-global-scratch-allocation;管道中条件性插入TritonGPUGlobalScratchAllocationPass。


libing-pipeline创建中,请等待……


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/AscendNPU-IR | ✅ yue-xy, michael_hliao (2/2) | ✅ michael_hliao (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
SanidhyaBarara, thanks for your pull request. All authors of the commits have signed the CLA. 👍


ascend docs pipeline is running...


compile


ascend docs pipeline is running...


npuir-smoke


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| 流水线 | PR-pipeline_ascendnpu-ir | ✅ | >>> |


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Compile | ✅ | >>> |
| 开发者测试 | CVOps | ✅ | >>> |
| 流水线 | PR-pipeline_npuir-smoke | ✅ | >>> |


/lgtm


/approve


Not enough required testers
If you want to solve this problem, you can click here to do it in the FAQs.

