已合并
添加PCIE Through需求相关内部接口 #727
ren-botao创建于 7 天前
添加PCIE Through需求相关内部接口 #727
已合并
ren-botao创建于 7 天前
ren-botao成员
7 天前

描述

此 PR 为算子执行框架新增 PCIE Through 功能相关的内部接口,主要目的是在检测到 tensor 地址位于 PCIE 地址范围时,跳过算子执行缓存(OpExecCache)的查找与写入,避免因 PCIE 通道数据变化导致缓存命中过期结果。变更涉及在 OpConfigInfo 中新增 usePcieAddr 标记字段、新增 op_feature_internal 模块提供 PCIE 地址检测能力,以及在算子缓存流程的关键路径上增加 PCIE 地址判断与缓存短路逻辑。

关联的Issue

#312 nnopbase支持PCIe through

测试

冒烟看护

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 ren-botao 的贡献)
Rren-botao成员
7 天前 创建了 pull request,commit fd7b2419
atomgit-bot
atomgit-bot
7 天前 评论:

变更摘要

此 PR 为算子执行框架新增 PCIE Through 功能相关的内部接口,主要目的是在检测到 tensor 地址位于 PCIE 地址范围时,跳过算子执行缓存(OpExecCache)的查找与写入,避免因 PCIE 通道数据变化导致缓存命中过期结果。变更涉及在 OpConfigInfo 中新增 usePcieAddr 标记字段、新增 op_feature_internal 模块提供 PCIE 地址检测能力,以及在算子缓存流程的关键路径上增加 PCIE 地址判断与缓存短路逻辑。

主要改动

  • 新增 usePcieAddr 字段到 OpConfigInfo:在 include/nnopbase/opdev/op_config.h 中为 OpConfigInfo 结构体增加了 bool usePcieAddr{false} 成员,并在拷贝构造和赋值运算符中同步处理该字段,同时将 reserved 数组从 5 字节缩减为 4 字节以保持结构体大小不变。

  • 新增 op_feature_internal 模块声明与实现:新增 src/nnopbase/common/inc/op_feature_internal.h 头文件和 src/nnopbase/common/utils/op_feature.cpp 实现文件,提供 InitPcieThroughInfo()IsPcieThroughEnabled()IsTensorAddrInPcieRange() 三个内部接口。当前使用占位地址段(0x1~0x2)进行框架验证,真实地址段待后续弱符号接口接入后填充。

  • 缓存初始化/重置时清零 usePcieAddr:在 src/nnopbase/common/utils/op_cache.cppResetCacheThreadLocal()InitPTACacheThreadLocal()InitExecutorCacheThreadLocal() 三个函数中增加 usePcieAddr = false 的重置逻辑,确保每次线程局部缓存初始化时标记处于干净状态。

  • Tensor 地址登记时检测 PCIE 范围并置标记:在 AddTensorAddrToCachedList()AddAclTensorToCachedList() 中,当 IsPcieThroughEnabled() 为真且 IsTensorAddrInPcieRange() 判定地址命中时,将线程局部上下文的 usePcieAddr 置为 true

  • 算子缓存查找与写入的 PCIE 短路逻辑:在 GetOpExecCache()(两个重载)中,若 usePcieAddrtrue 则直接返回 nullptr 跳过缓存查找;在 AddOpExecCache() 中,若 usePcieAddrtrue 则直接销毁传入的缓存对象并返回 false,阻止 PCIE 场景下写入缓存。

  • 在 L2 初始化流程中触发 PCIE 信息初始化:在 src/nnopbase/composite_op/aclnn_engine/op_executor.cppInitL2Phase1Context() 函数开头调用 op::internal::InitPcieThroughInfo(),确保在每次 L2 算子执行上下文的初始化阶段完成 PCIE Through 相关全局状态的 std::call_once 初始化。

likedislike
atomgit-bot
atomgit-bot
7 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
7 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7 天前 评论:

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
include 王永光, 汤平川, 宋恺 (3/2) 王永光 (1/1)
repo-cann/opbase 汤平川, 宋恺 (2/2) 汤平川, 宋恺 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
7 天前 将zhou-qilong,wangrui_,rxtfeng,loov1,tang-lei01,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng,wangyongguang设为评审人
此处折叠了11条事件消息 查看更多
CANN-robotCANN-robot成员
7 天前 添加了label:cann-cla/yes
ren-botao成员
7 天前 评论:

compile

likedislike
Rren-botao成员
7 天前 update merge request[project id: 7649482, iid: 727, commit_id: 25fd1b654e6c51176ad7a48e15a1fa5faf35ba55] virtual merging success
此处折叠了8条事件消息 查看更多
CANN-robotCANN-robot成员
7 天前 添加了label:cann-cla/yes
ren-botao成员
7 天前 评论:

compile

likedislike
Rren-botao成员
7 天前 update merge request[project id: 7649482, iid: 727, commit_id: 3580b503632b2c7592293c04df54017cf8b18d74] virtual merging success
CANN-robotCANN-robot成员
7 天前 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
7 天前 添加了label:ci-pipeline-running
Rren-botao成员
7 天前 修改了pull request 的描述
TangPC
TangPC成员
7 天前 评论:

/lgtm
/approve

likedislike
songkai111成员
7 天前 评论:

/approve

likedislike
songkai111成员
7 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
7 天前 添加了label:lgtm
CANN-robotCANN-robot成员
7 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7 天前 添加了label:ci-pipeline-passed
wangyongguang成员
7 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7 天前 添加了label:approved
CANN-robotCANN-robot成员
7 天前 关闭了关联的issue
CANN-robotCANN-robot成员
7 天前 合入了pull request