Merged
reduceprod性能优化 #690
sunzhongwen1Add on Jul 31
reduceprod性能优化 #690
Merged
Merged fromsunzhongwen1/opbaseperfimprove/reduceprodintocann/opbasemaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for sunzhongwen1's contribution.)Jul 31 Created pull request, commit a9258f97
atomgit-bot
Jul 31 Comments:
Jul 31 Comments:
变更摘要
本 PR 针对 reduceprod(归约乘积)算子进行性能优化,改动集中在 pkg_inc/op_common/atvoss/reduce/reduce_operator.h。核心思路是将 ReduceAR / ReduceARI64 中"归约到 1"的最终阶段由逐元素串行乘法改为基于 DeInterleave + Mul 的对数树形归约,将指令循环次数从 O(reservedR) 降为 O(log2(eleCount)),同时精简了 ReduceARFoldBase 中冗余的块重复归约第二段循环及相关参数。
主要改动
- 新增
LogBase2辅助函数: 在文件中新增LogBase2(uint16_t n)用于计算以 2 为底的对数(对n <= 0返回 0),作为树形归约的迭代次数repeatTime。 - 精简
ReduceARFoldBase签名与逻辑: 移除dstAddr、maskElems、blkElems、isBlkRepeat、blkRepeats参数,并删除其中基于DIST_BLK加载的块重复归约第二段循环(含LocalMemBar),块内归约改由调用方统一完成。 - "Reduce to 1" 阶段改为对数树形归约:
ReduceAR与ReduceARI64中将原先"Duplicate置 1 + 广播DataCopy+Mul循环reservedR次"的串行实现,替换为"Select结合全 1 的tempOne将掩码外元素置 1,再循环repeatTime = LogBase2(eleCount)次执行DeInterleave+Mul",并在归约前新增LocalMemBar屏障。 vLElems/blkElems计算简化:ReduceAR中去除IsB64<PromteT>()条件分支,统一按VL_LEN / sizeof(PromteT)、BLOCK_SIZE / sizeof(PromteT)计算;ReduceARI64中统一按float计算;同时移除blkRepeats、isBlkRepeat、reservedR等中间变量,改为eleCount与repeatTime。


Incorrect?
atomgit-bot
Jul 31 Comments:
Jul 31 Comments:
Jul 31 Added label: cann-cla/yes
CANN-robot
Jul 31 Comments:
Jul 31 Comments:
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.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| pkg_inc | ✅ 王永光, 王瑞 (2/2) | ✅ 王永光 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
sunzhongwen1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


CANN-robot
Jul 31 Comments:
Jul 31 Comments:
Jul 31 Set zhou-qilong,wangrui_,rxtfeng,loov1,tang-lei01,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng,wangyongguang as approver
Jul 31 Set zhou-qilong,wangrui_,rxtfeng,loov1,tang-lei01,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng,wangyongguang as approver
10 event messages are collapsed here。 See more
Aug 11 Added label: cann-cla/yes
sunzhongwen1
Aug 17 Comments:
Aug 17 Comments:
compile


Aug 17 Pre merge succeeded (commit_id: e9dd1b1dde8d52af9786e33cc44b09ec27100816)
5 event messages are collapsed here。 See more
Aug 18 Modify description of pull request
wangyongguang
Aug 18 Comments:
Aug 18 Comments:
/approve


Aug 18 Added label: approved
RuiWang_
Aug 18 Comments:
Aug 18 Comments:
/lgtm
/approve


Aug 18 Added label: lgtm
Aug 18 Closed associated issue
Aug 18 Merged pull request
描述
ARpattern下,reduce to 1的累加计算从逐元素累乘改为使用deinterleave+mul的树形规约。
关联的Issue
测试
文档更新
类型标签