Pull Request has been successfully merged by CANN-robot.
(Thank you for 可惜春残风雨又's contribution.)变更摘要
本 PR 旨在提升 ctrl cache 回放(replay)性能。核心思路是将 PredCount 与 readyQueue/dieReadyQueue 改为 A/B 两份缓冲的 ping-pong 结构:每次启动前只做指针切换(PingPongSwap),而把真正的数据恢复(PingPongRestore)推迟到本轮 ctrl push task 结束后的空闲尾段(PingPongRestoreAll)执行,用 ctrl 尾部空闲时间掩盖 restore 的 memcpy 开销。同时针对 full cache 场景做了优化:BitmapDataRestoreTask 只需执行一次,且 full cache 下跳过 ResetRerun。相关改动覆盖 device_execute_context.cpp/h、device_ctrl.h、dev_encode.cpp、dev_encode_function_dupped_data.h、dev_encode_program_ctrlflow_cache.cpp/h、queues.h 及对应 UT。
主要改动
- PredCount 改为 ping-pong 双缓冲:
dev_encode.cpp中 predCount 数据区大小乘以PRED_COUNT_PINGPONG_NUM(2);DynFuncDataCache新增predCountPing/predCountPong指针并随dynFuncDataCacheList一起重定位;备份时将快照同时写入 PONG 切片,PredCountPingPongSwap仅交换切片指针(predCount指向当前 PING),PredCountPingPongRestore在后台刷新非活跃切片,避免启动前的整片 memcpy。 - ready/die 队列改为 ping-pong 元素缓冲:
ReadyQueueCache/DieReadyQueueCache新增pingElem/pongElem指针数组并在备份时分配影子缓冲、拷贝快照;queues.h的QueueGeneric新增Data()与FillFrom用于直接重绑elem_;ReadyQueueDataPingPongSwap/DieReadyQueuePingPongSwap在 push 前只重绑到干净缓冲,ReadyQueueDataPingPongRestore/DieReadyQueuePingPongRestore延迟刷新另一份。 - restore 推迟到 ctrl 尾部执行:
DeviceExecuteContext新增PingPongRestoreAll,在GELaunchPartialCache中于RunControlFlow之后统一执行 PredCount 与 ready/die 队列的 ping-pong restore;GELaunchRunCached内改为仅做 swap 与必要的DrcoPredCountDataRestore,以此掩盖 restore 开销。 - full cache 场景优化:新增
bitmapRestoreDone标志,full cache 下BitmapDataRestoreTask只执行一次,并在PingPongRestoreAll中置位;device_ctrl.h在 full cache 时跳过devProg->ResetRerun()。 - 接口调整与测试补充:
IsActivatedPartialCache更名为IsActivatedCache(device_ctrl.h、device_execute_context.cpp同步使用);device_stitch_context.cpp中dynFuncDataCacheList初始化补充 ping/pong predCount 指针;UT 新增PredCountPingPongRoundTrip、ReadyQueuePingPongRoundTrip等用例覆盖连续多轮回放下双缓冲协议的正确性。


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.
You can self-configure the PR merge rules for this repository. For more details, please refer to 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 |
|---|---|---|
| framework/src/machine | ✅ jason_yuan_ye, gaoxingwang (2/2) | ✅ jason_yuan_ye (1/1) |
| repo-cann/pypto | ✅ jason_yuan_ye, gaoxingwang (2/2) | ✅ jason_yuan_ye (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
qq_52905393, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/lgtm


1、将 PredCount 以及 readyque 改为 A B 两份,通过pingpong 结构,当前轮次 ctrl push task 之后,对 B 做 restore ,利用 ctrl 结尾空闲时间掩盖 restore 开销