已合并
refactor: use asc_uintdiv SIMT API in integer fast div sample #6277
refactor: use asc_uintdiv SIMT API in integer fast div sample #6277
已合并
zhangshunwei2创建于 9 天前
zhangshunwei2成员
9 天前

描述

快速除法样例 simd_simt_integer_fast_div 适配 PR #6009 新增的 SIMT 快除接口:

  • integer_div.asc:删除手写的 calc_magic_shift() 预计算函数(内部基于 clz()、bcnt1() 标量接口)以及 __umulhi + 移位的手写快除实现,改为在核函数标量计算逻辑中调用 asc_get_uintdiv_magic_and_shift() 接口预计算 magic 和 shift,在SIMT VF计算逻辑中调用 asc_uintdiv() 接口完成除法计算,两个Case的计算行为与原实现等价。
  • 样例 README.md / README_en.md:Case说明、核心实现、转换原理、关键代码、调优建议同步为新接口调用方式,并为接口添加API文档链接。
  • 《整数除法的快速算法》优化指南(fast_integer_division.md):描述、正例代码、总结同步为新接口调用方式,并为接口添加API文档链接。

关联的Issue

关联 Issue #1592。

测试

  • 环境:CANN 9.2.0(20260909测试包,dav-3510 / Ascend 950PR),按样例README编译运行命令验证。
  • Case 0(普通除法,8388608元素):编译通过,NPU运行精度验证通过([Success] Case accuracy is verification passed.)。
  • Case 1(快速除法,新接口):清缓存全新编译通过,NPU运行精度验证通过(8192与8388608元素均 [Success])。
  • 纯 simt_api/math_functions.h 头文件引用场景编译验证通过(接口最小依赖检查)。
  • pre-commit检查通过(clang-format、codespell、OAT合规等)。

文档更新

更新样例README(中英文)与SIMD与SIMT混合编程优化指南《整数除法的快速算法》:快除实现描述与关键代码同步为 asc_get_uintdiv_magic_and_shift() + asc_uintdiv() 接口调用方式,并添加对应API文档链接。

类型标签

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

变更摘要

本 PR 将快速除法样例 simd_simt_integer_fast_div 重构为使用 PR #6009 新增的 SIMT 快除接口,移除手写的魔数(magic)与移位量(shift)预计算及除法实现,改为调用 asc_get_uintdiv_magic_and_shift() 与 asc_uintdiv(),使两个 Case 的计算行为与原实现保持等价;同时同步更新样例中英文 README 与《整数除法的快速算法》优化指南的说明与关键代码,并补充对应 API 文档链接。

主要改动

  • 移除手写魔数预计算:删除 integer_div.asc 中的 count_leading_zero()、get_bit_count1() 与 calc_magic_shift() 函数,以及 BIT_64_LEN、BIT_32_LEN 常量,核函数标量逻辑改为调用 asc_get_uintdiv_magic_and_shift(&magic, &shift, divisor) 预计算 magic 和 shift。
  • SIMT VF 快除改用接口:将 simt_fast_div 中基于 __umulhi(value, magic) 加右移的手写计算替换为 asc_uintdiv(value, magic, shift),由接口统一完成除法计算。
  • 样例文档同步:README.md / README_en.md 的 Case 说明、核心实现、转换原理、关键代码与调优建议同步为新接口调用方式,并补充接口 API 文档链接。
- **优化指南同步**:`fast_integer_division.md` 的描述、正例代码与总结同步为 `asc_get_uintdiv_magic_and_shift()` + `asc_uintdiv()` 的调用方式,并添加接口文档链接。
likedislike
不准确?
atomgit-bot
atomgit-bot
9 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
9 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9 天前 评论:

CLA Signature Pass

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

likedislike
此处折叠了45条消息 查看更多
CANN-robotCANN-robot成员
9 天前 添加了label:ci-pipeline-passed
Zzhangshunwei2成员
9 天前 解决了最后一个问题
wulinyu成员
9 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
9 天前 添加了label:lgtm
CANN-robotCANN-robot成员
9 天前 合入了pull request