Pull Request已成功合入, 合并人@CANN-robot
(感谢 陈思 的贡献)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 |
|---|---|---|
| repo-cann/ops-blas | ✅ 王子韬, xutianze (2/2) | ✅ 王子韬 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
chensi79, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


变更摘要
此 PR 为 arch35 (ascend950) 平台新增了 aclblasSrot 接口,实现 BLAS Level-1 的 Givens 平面旋转(x[i] = c*x[i] + s*y[i], y[i] = c*y[i] - s*x[i])。核心设计包含两条计算路径:当 incx==1 && incy==1 时走连续 SIMD membase 路径,否则走 SIMT 网格步长路径。此外,c 和 s 参数支持独立的主机指针或设备指针位置检测(通过 aclrtPointerGetAttributes),设备指针直接透传给 kernel 在 GM 上读取。测试套件覆盖了 host/device/mixed 三种 csPtrMode、NaN 传播、恒等旋转精确校验以及零步长的 netlib 串行回退等场景。
主要改动
-
新增
aclblasSrot公共 API:在include/cann_ops_blas.h中声明,由blas/rot/arch35/srot_host.cpp实现完整的主机端入口,包含参数校验、handle 空指针检测、n<=0快速返回,以及调用LaunchSrotKernel进行 tiling 计算与异步内核启动。 -
双路径内核设计:
srot_kernel.cpp通过tilingKey选择路径——tilingKey==0使用SrotAIV类走 SIMD membase(DataCopy/DataCopyPad+Muls/Axpy向量计算,分 tile 循环处理);tilingKey==1使用srot_simt_kernel走 SIMT 网格步长循环(asc_vf_call),支持负步长和零步长。零步长场景通过仅block0.thread0串行执行来匹配 netlib 的语义。 -
c/s指针位置独立检测:PrepareSrotCsSource通过aclrtPointerGetAttributes分别查询c和s的指针位置(主机或设备)。主机指针在主机端解引用一次,标量值写入 tiling 数据广播;设备指针则原样透传GM_ADDR给 kernel 在 GM 上读取,无需 D2H 拷贝或流同步。两个指针相互独立(允许 c 在主机、s 在设备的混合模式)。 -
Tiling 数据结构
SrotTilingData:定义于srot_tiling_data.h,通过常量引用传递给 kernel(无 GM tiling 缓冲区、无 H2D 拷贝)。包含tilingKey、totalN、cosValue/sinValue、cIsDevice/sIsDevice标志、连续路径的perCoreN/remainder/tileSize以及步长路径的incx/incy(int32_t支持负步长)。步长偏移量在主机端以int64_t计算并做溢出检查。 -
测试套件与 NPU 包装器:
srot_npu_wrapper.h实现aclblasSrot_npu,根据csPtrMode(host/device/mixed)将c/s标量分配到主机栈或设备 HBM,并管理 x/y 的设备缓冲区分配、H2D/D2H 拷贝和资源释放。srot_test.cpp包含空句柄测试和 CSV 驱动测试,针对 NaN 输入直接验证std::isnan传播,针对c==1 && s==0恒等旋转进行 EXACT 精确校验,其余情况使用 MERE/MARE 相对误差验证;srot_golden.h以cblas_srot作为 CPU 参考实现。


/lgtm


描述
为 arch35(Ascend 950PR / 950DT)平台新增 BLAS Level-1
aclblasSrot接口,实现 Givens 平面旋转:对 FP32 向量 x、y 按标量 c=cosθ、s=sinθ 原地旋转改动原因
ops-blas 当前缺少面向 arch35 的 SROT 实现。
改动方法
blas/rot/arch35/:host(参数校验、c/s 指针 Host/Device 自动判定、tiling、kernel 启动)、kernel(连续 SIMD / stride SIMT 双路径)、tiling datainclude/cann_ops_blas.h注册aclblasSrot接口声明(同时补充aclblasSrotm前置声明,留待后续实现)aclrtPointerGetAttributes对 c、s 各自独立判定 Host/Device 内存;n≤0 短路返回 SUCCESS;(n−1)·stride 超 int32 范围返回 INVALID_VALUE关联的Issue
测试
test/rot/srot/新增 CSV 驱动测试(约 48 用例),覆盖:精度校验对齐 OpenBLAS
cblas_srot,按数据特征选 NaN 逐元素、单位+Inf 位级 EXACT、默认 MERE/MARE 三种模式。readme中示例代码本地验证通过:

文档更新
blas/rot/README.md:新增aclblasSrot章节(产品支持表 950PR/950DT、函数原型、参数说明、约束、可编译调用示例)docs/zh/develop/compile_and_run_example.md、blas/asum|nrm2|scal|scalex/README.md:随附的调用示例 RAII 类型安全重构(std::remove_pointer_t+ 自定义 deleter).类型标签