| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
perf(population_count): 小shape性能优化:核扇出收敛+SWAR寄存器链 Co-authored-by: babeiee<125106023003@njust.edu.cn> # message auto-generated for no-merge-commit merge: !6383 merge perf/population-count-small-shape into master perf(population_count): 小shape性能优化:核扇出收敛+SWAR寄存器链 Created-by: babeiee Commit-by: babeiee Merged-by: cann-robot Description: ## 问题单 比率0.544 < 带宽折算(均值)=0.556,15 例小 shape(n=84~152K,int16/uint16)性能均值不过。 ## 根因(实测修正) 1. **主因:小 shape 核数扇出**。旧 tiling 以 32 元素最小块对齐( blockFactor = CeilAlign(CeilDiv(n, coreNum), ubBlockSize)),小 shape 被铺满核(n=3544 → 56 核 × 64 元素)。AIV 块调度成本随核数线性增长(实测 ~7-10ns/核),而 launch-bound 小 kernel 每核计算仅 1 个 VF tile。对照 abs(atvoss 调度器 512 元素对齐,n=3544 仅 7 核)floor 1.50us vs 修复前 2.01us。 2. **次因:SWAR 计算链 UB 驻留形态**(实测稳态差 ~0.1us,方差显著)。 ## 修复内容(3 文件 +100/-57) - **tiling**(population_count_tiling_arch35.cpp):blockFactor 对齐 512 元素(1KB/核,int16),小 shape 收敛至少数核;双 buffer 仅在 loopCount>=2(blockFactor > ubFactorSingle)时启用 - **kernel**(population_count.h):Compute 改为 __VEC_SCOPE__ 寄存器驻留 SWAR 链——DIST_NORM 128 元素/拍打包装载,DIST_PACK_B16 store 取每 16-bit lane 低字节直出 uint8(省去 Cast/0x00FF 掩码/VECCALC tmpBuf) - 入口补 KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_AIV_ONLY)(仓内标准写法) 数值正确性:step3 后 0x0F0F 掩码保留(nibble 残留会污染 bit4,popcount=16 输入出错);step4 后高字节残留由 PACK_B16 低字节选取自然丢弃。 ## 验证(Ascend950PR_9599 / CANN 9.3.0 / ttk v3.0.0 e2e,CI framework-api 同链路) - **15 失败例 CST 均值 0.519 → 0.697(阈值 0.556,余量 +25%),逐例 0.62~0.77 全过线** - 精度 **49/49 逐位一致**(15 失败例 + 26 边界例[标量/空张量/非对齐尾拍/1M/10M × int16+uint16] + 8 极值例[全0/全-1/±32767/65535]) - 大 shape 带宽不回归:10M 例 ~1871 GB/s ≥ 旧版 1779 GB/s - 大 shape 段比值原有 2.3~2.7 优势不变(未改动其执行路径参数) ## 复测注意 - 改 host tiling 后需清理 GE 图编译缓存(kernel_meta/),否则旧 tiling 被缓存冻结 - 自定义包 e2e 首跑含在线编译,判定用 per-call 稳态(min)或缓存预热后重跑 ## 关联的Issue - #3605(https://gitcode.com/cann/ops-math/issues/3605) See merge request: cann/ops-math!6383 | 2 天前 | |
perf(population_count): 小shape性能优化:核扇出收敛+SWAR寄存器链 Co-authored-by: babeiee<125106023003@njust.edu.cn> # message auto-generated for no-merge-commit merge: !6383 merge perf/population-count-small-shape into master perf(population_count): 小shape性能优化:核扇出收敛+SWAR寄存器链 Created-by: babeiee Commit-by: babeiee Merged-by: cann-robot Description: ## 问题单 比率0.544 < 带宽折算(均值)=0.556,15 例小 shape(n=84~152K,int16/uint16)性能均值不过。 ## 根因(实测修正) 1. **主因:小 shape 核数扇出**。旧 tiling 以 32 元素最小块对齐( blockFactor = CeilAlign(CeilDiv(n, coreNum), ubBlockSize)),小 shape 被铺满核(n=3544 → 56 核 × 64 元素)。AIV 块调度成本随核数线性增长(实测 ~7-10ns/核),而 launch-bound 小 kernel 每核计算仅 1 个 VF tile。对照 abs(atvoss 调度器 512 元素对齐,n=3544 仅 7 核)floor 1.50us vs 修复前 2.01us。 2. **次因:SWAR 计算链 UB 驻留形态**(实测稳态差 ~0.1us,方差显著)。 ## 修复内容(3 文件 +100/-57) - **tiling**(population_count_tiling_arch35.cpp):blockFactor 对齐 512 元素(1KB/核,int16),小 shape 收敛至少数核;双 buffer 仅在 loopCount>=2(blockFactor > ubFactorSingle)时启用 - **kernel**(population_count.h):Compute 改为 __VEC_SCOPE__ 寄存器驻留 SWAR 链——DIST_NORM 128 元素/拍打包装载,DIST_PACK_B16 store 取每 16-bit lane 低字节直出 uint8(省去 Cast/0x00FF 掩码/VECCALC tmpBuf) - 入口补 KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_AIV_ONLY)(仓内标准写法) 数值正确性:step3 后 0x0F0F 掩码保留(nibble 残留会污染 bit4,popcount=16 输入出错);step4 后高字节残留由 PACK_B16 低字节选取自然丢弃。 ## 验证(Ascend950PR_9599 / CANN 9.3.0 / ttk v3.0.0 e2e,CI framework-api 同链路) - **15 失败例 CST 均值 0.519 → 0.697(阈值 0.556,余量 +25%),逐例 0.62~0.77 全过线** - 精度 **49/49 逐位一致**(15 失败例 + 26 边界例[标量/空张量/非对齐尾拍/1M/10M × int16+uint16] + 8 极值例[全0/全-1/±32767/65535]) - 大 shape 带宽不回归:10M 例 ~1871 GB/s ≥ 旧版 1779 GB/s - 大 shape 段比值原有 2.3~2.7 优势不变(未改动其执行路径参数) ## 复测注意 - 改 host tiling 后需清理 GE 图编译缓存(kernel_meta/),否则旧 tiling 被缓存冻结 - 自定义包 e2e 首跑含在线编译,判定用 per-call 稳态(min)或缓存预热后重跑 ## 关联的Issue - #3605(https://gitcode.com/cann/ops-math/issues/3605) See merge request: cann/ops-math!6383 | 2 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 天前 | ||
| 2 天前 |