Merged
update auto preload #5332
huanyongbenAdd on Aug 6
update auto preload #5332
Merged
huanyongbenAdd on Aug 6
huanyongben
Aug 6

1、增加不支持场景的校验
2、自动核间同步使用sync_graph方案
3、修复自动preload的bug

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for huanyongben's contribution.)
huanyongbenhuanyongben
Aug 6 Created pull request, commit 17d6698e
atomgit-bot
atomgit-bot
Aug 6 Comments:

变更摘要

该 PR 主要围绕流水线(pipeline)自动预加载(auto preload)的同步机制进行重构,引入了统一的同步依赖图(_sync_graph.py)来替代之前分散的逐场景同步推导逻辑,支持 RAW/WAR 边、地址复用区域、混合阶段(mix stage)和循环检测。同时新增了编译期常量分支剪枝(constant-branch pruning)能力,通过在解析阶段探测 if 条件的常量性来消除死分支,使流水线分析器只看到确定性的阶段调用。此外修复了地址重叠反向同步只生成单条边的缺陷,并增加了对跨核事件 ID 范围(0..15)的编译时校验。

主要改动

  • 新增同步依赖图模块 _sync_graph.py:构建基于物理槽位时间线的图模型,统一处理 RAW/WAR 边、地址重叠和混合阶段的跨核同步推导,支持循环死锁检测和完整的同步指令规划(plan_sync_sites / plan_drain),替代 _analyzer.py 中基于配对的重叠反向同步逻辑

  • 新增常量分支剪枝机制:在 _ast_parser.py 增加 collect_if_const 开关和 if_const_map,在 _control_flow_parser.py 增加 _record_if_const 钩子记录每个 if 条件的编译期常量性;在 _analyzer.py 新增 probe_if_const_map 函数,分别对 Cube/Vector 目标进行探测解析后合并结果,供流水线变换剪除死分支

  • 重构重叠反向同步为基于图模型:_analyzer.py 的 _build_overlap_reverse_syncs 改为从 _sync_graph 的 WAR 边驱动,解决了配对模式下每区域仅产生一条边导致 FA 重叠用例第二条边缺失的问题;同步指令的 guard 常量推迟到发射阶段根据真实调度计算

  • 跨核扫描器增强(_cross_core_scanner.py):导出 _MAX_EVENT_ID = 15 硬件限制常量,新增 _resolve_tuple_ints 对 fwd_ids/bwd_ids 中的事件 ID 值进行范围校验;为 CrossCoreAccess 增加 sub_stage 字段以在 mix 阶段内恢复程序顺序,为 OverlapReverseSync 增加 wait_section_kind 字段

  • JIT 编译流程调整(jit.py):_prepare_codegen_inputs 在调用 transform_pipeline 前先通过 probe_if_const_map 获取常量分支映射并传入;流水线生成源码的 dump 目录改为直接放在 out_dir 下,与生成的 kernel.cpp 并置

likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 6 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 6 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 6 Comments:

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.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/pypto ✅ wangbing110, gaoxiang618 (2/2) ✅ wangbing110, gaoxiang618 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

huanyongben, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
148 messages are collapsed here。 See more
poorwillpoorwillCollaborators
Aug 21 Approval passed
poorwillpoorwillCollaborators
Aug 21 Approval passed
poorwill
poorwillCollaborators
Aug 21 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 21 Added label: lgtm
CANN-robotCANN-robotCollaborators
Aug 21 Merged pull request