已合并
[Bugfix] Scope cached CCU kernel handles by instance and die #234
KaranocaVe创建于 9月27日
[Bugfix] Scope cached CCU kernel handles by instance and die #234
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 KaranocaVe 的贡献)9月27日 创建了 pull request,commit bdd50f76
9月27日 关联了issue:CCU kernel cache reuses handles across instances
atomgit-bot
9月27日 评论:
9月27日 评论:
变更摘要
本 PR 修复主机侧启动缓存仅以 binary_cache_tag 作为键导致跨 CCU 实例、跨物理 die 复用错误 kernel handle 的问题。核心改动集中在 src/ccu/ccu_host_launch.cpp 的 KernelHandleCache:在缓存键中引入 CCU 实例身份与物理 die 掩码,使 kernel 注册仅在二进制标签、CCU 实例、物理 die 三者一致时才复用;tests/ut/ccu/test_ccu_host_launch.cpp 增加了对应的宿主单元测试。
主要改动
- 缓存键结构重构:新增
KernelCacheKey结构,包含binaryCacheTag、CcuInstanceCacheIdentity instance、phyDieMask三个字段,并定义operator==用于精确匹配缓存条目。 - 实例身份提取机制:新增
CcuInstanceCacheIdentity及CcuInstanceCacheIdentityTraits模板,通过 SFINAE 从CcuInsHandle中提取ccuInsKey与ccuInsPtr,缺省情况下回退为 handle 与 0,从而把 CCU 实例身份纳入缓存键。 - 缓存容器类型变更:
KernelHandleCache内部缓存由std::unordered_map<uint64_t, CcuKernelHandle>改为std::unordered_map<KernelCacheKey, CcuKernelHandle, KernelCacheKeyHash>,并新增KernelCacheKeyHash哈希实现。 - 匹配流程调整:
KernelHandleCache::Match中改为根据cacheTag、cfg->ccu_ins实例身份和cfg->ccu_schd.phy_die_mask构造cacheKey进行查找与写入,取代原先仅以cacheTag索引。 - 单测覆盖扩展:测试桩
HcommCcuKernelRegister增加记录insHandle与dieId的g_observedRegisterIns、g_observedRegisterDie及调用计数g_registerKernelCallCount,并新增BinaryCacheTagIsScopedToCcuInstance用例验证同实例复用与跨实例/跨 die 隔离。


不准确?
atomgit-bot
9月27日 评论:
9月27日 评论:
9月27日 添加了label:cann-cla/yes
此处折叠了77条消息 查看更多
KaranocaVe
15 天前 评论:
15 天前 评论:
@dengjing_aoe @YeZZzzz1 @DragonBornHD84 @jiangxinyu3 @qin437231 @chenma @shi_nanxiang @houyuyang @changxianyu @suqwe @bianque @yanqingshang
昨天已请各位审核,这里再跟进一下:麻烦抽空看一下这个 PR。如有需要修改的地方,请直接留言;确认没有问题后,烦请按仓库规则补齐所需的 /lgtm 和 /approve,协助推进合入。谢谢!


changxianyu
14 天前 评论:
14 天前 评论:
/lgtm


14 天前 添加了label:lgtmapproved
14 天前 合入了pull request
[Bugfix] Scope cached CCU kernel handles by instance and die
Problem
The host launch cache is keyed only by
binary_cache_tag. When two CCUinstances use the same tag, the second launch reuses the kernel handle
registered for the first instance. The same issue occurs across physical dies.
Reproduction
Launch the same kernel with the same
binary_cache_tagfirst on one CCUinstance and then on a different instance, or use a different physical die.
The second launch reuses the first registration instead of registering the
kernel for its own instance and die.
Expected and actual behavior
and physical die are the same.
different instance or die is reused.
Impact
Kernel launches can use a handle registered for the wrong CCU instance or
physical die when identical binary cache tags are used.
Fix
Include the CCU instance identity and physical die mask in the cache key, and
cover same-instance reuse and cross-instance/die isolation in the host unit
test.
Verification
The regression fails on the original implementation and passes with the fix.
The
asccomm_ut_ccu_host_launchsuite passes all 12 tests.关联 Issue: https://gitcode.com/cann/asc-comm/issues/48