已合并
feat:nano支持rtsPointerGetAttributes接口 #4371
feat:nano支持rtsPointerGetAttributes接口 #4371
已合并
maxiaofan创建于 20 天前
maxiaofan
20 天前

Pull Request

描述

在 Runtime Compact 中新增 rtsPointerGetAttributes 接口,通过 HAL 查询指针的 Host/Device 内存属性,并补充参数校验及 Linux、LiteOS 单元测试。

变更类型

请选择本次引入的变更类型:

关联的Issue

如何测试

描述测试此变更的步骤和前提条件:
1.
2.

核对清单

其他信息

在此添加任何其他关于本次 PR 的说明。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 maxiaofan 的贡献)
Mmaxiaofan
20 天前 添加了label:enhancement
Mmaxiaofan
20 天前 创建了 pull request,commit c65f0968
atomgit-bot
atomgit-bot
20 天前 评论:

变更摘要

本 PR 为 runtime_compact 特性新增指针属性查询能力:在 HAL 层新增 pointer_attributes_hal.h 头文件,定义内存类型枚举 drvMemType_tDRV_MEMTYPE_HOST / DRV_MEMTYPE_DEVICE)并声明 halMemGetType 接口;在 api.c 中实现 rtsPointerGetAttributes 接口,通过调用 halMemGetType 获取指针所属内存类型并填充 rtPtrAttributes_t 结构体,同时补充了对应的 UT 桩函数与测试用例。

主要改动

  • 新增 HAL 接口头文件:新增 src/runtime_compact/feature/inc/pointer_attributes_hal.h,定义 drvMemType_t 枚举(DRV_MEMTYPE_HOST / DRV_MEMTYPE_DEVICE)并声明 drvMemType_t halMemGetType(const void* p) 接口。
  • 新增 rtsPointerGetAttributes 接口实现:在 src/runtime_compact/feature/src/api.c 中实现该接口,对空指针入参(ptr / attributes)返回 ACL_ERROR_RT_PARAM_INVALID,用 memset_s 清零 rtPtrAttributes_t 后根据 halMemGetType 的结果设置 attributes->location.typeRT_MEMORY_LOC_HOSTRT_MEMORY_LOC_DEVICE)。
  • 新增 UT 桩函数:在 tests/ut/runtime/runtime_c/stub/rt_utest_stub.cc 中增加 halMemGetType 的桩实现,并通过可配置的全局变量 g_halMemTypeForTest 控制返回的内存类型。
  • 新增接口测试用例:在 tests/ut/runtime/runtime_c/testcase/feature/rt_api_test.cc 中新增 runtime_rtsPointerGetAttributes 测试,覆盖 HOST/DEVICE 两种内存类型下的返回结果,以及 ptrattributes 为空时的参数校验分支。
likedislike
不准确?
atomgit-bot
atomgit-bot
20 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
20 天前 添加了label:cann-cla/yes
此处折叠了236条消息 查看更多
wangtao成员
6 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:lgtm
CANN-robot
CANN-robot成员
6 天前 评论:

The MR can not be merged, because of CodeReview discussion not resolved

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

likedislike
Zzhangpengpeng8成员
6 天前 解决了最后一个问题
CANN-robotCANN-robot成员
6 天前 合入了pull request