Closed
[Requirement|需求建议]: SIMT 数学类型 API 接口性能优化 #1782
xuyiyangAdd on  Sep 22Closed at  5 days ago
xuyiyang
xuyiyangCollaborators
Sep 22 Create

Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.

Background(背景信息)

客户此前反馈 SIMT 数学类型 API 精度不足,经优化接口精度后该问题已解决,但精度优化牺牲了一部分性能。
需要对 SIMT 数学类型 API 接口共 20+ 个需要做性能优化。

优化手段

  1. SIMT 分支友好化:将接口开头的 early-return(早退)特殊值分支改为尾置 result = ... 覆盖赋值,消除 SIMT 锁步下指令流中的 DVG(发散等待),降低分支发散开销;
  2. 换用快速内建指令:在精度不受影响的场景下,将 sqrtf -> __sqrtf、logf -> __logf、expf -> __expf、rsqrtf -> 1.0f / __sqrtf 等。

Origin(信息来源)

SIMT 开发需求

Benefit / Necessity (价值/作用)

  1. 恢复/提升精度优化后 SIMT 数学接口的性能,改善客户模型中数学算子的执行吞吐;
  2. 减少 SIMT 锁步下分支发散导致的 DVG 等待,提升整体算子性能;
  3. 在保持现有高精度结果不变的前提下,仅通过指令优化提升性能,不引入精度回退。

Design(设计方案)

  1. SIMT 分支友好化:early-return 特殊值分支后置为尾置覆盖赋值,主体无条件直落计算;
  2. 换用快速内建指令 __sqrtf/__logf/__expf 等(以 1.0f / __sqrtf 替代 rsqrtf);
  3. 逐个接口做精度回归(ULP 对比)与性能对比(clock 周期),确保性能提升的同时精度不回退。
likedislike
xuyiyangxuyiyangCollaborators
Sep 22 Added label: requirement
xuyiyangxuyiyangCollaborators
Sep 22 Change title to "[Requirement|需求建议]: SIMT 数学类型 API 接口性能优化", originally titled "[Requirement|需求建议]: SIMT 数学类型 API 全量接口性能优化(40+ 接口)".
xuyiyangxuyiyangCollaborators
Sep 22 Modify description of issue
xuyiyangxuyiyangCollaborators
Sep 22 Modify description of issue
xuyiyangxuyiyangCollaborators
Sep 22 Assign xuyiyang0324 as responsible person
xuyiyang
xuyiyangCollaborators
Sep 22 Comments:

你好,感谢你的建议,我们将安排在保证接口精度的情况下优化接口的性能。

likedislike
xuyiyangxuyiyangCollaborators
5 days ago Modify description of issue
xuyiyang
xuyiyangCollaborators
5 days ago Comments:

你好,我们已经修复相关问题,在保证接口精度的情况下优化相关20+接口的性能,详见pr:
https://gitcode.com/cann/asc-devkit/pull/6308
https://gitcode.com/cann/asc-devkit/pull/6500
https://gitcode.com/cann/asc-devkit/pull/6676
https://gitcode.com/cann/asc-devkit/pull/6829
https://gitcode.com/cann/asc-devkit/pull/7121

我们对接口的实现做了如下处理:
SIMT 分支友好化:early-return 特殊值分支后置为尾置覆盖赋值,主体无条件直落计算;
换用快速内建指令 __sqrtf/__logf/__expf 等(以 1.0f / __sqrtf 替代 rsqrtf);
逐个接口做精度回归(ULP 对比)与性能对比(clock 周期),确保性能提升的同时精度不回退。

如果没有问题,我们将关闭此issue。

likedislike
xuyiyangxuyiyangCollaborators
5 days ago changed custom state from 待办的 to 已解决
xuyiyangxuyiyangCollaborators
5 days ago Close issue
CANN-robotCANN-robotCollaborators
5 days ago Added label: resolved