| name | triton-ascend-case-reduction-amin-large |
| description | 极大规模1D归约(amin)优化:二次切分避免超UB+计算重组减少归约次数,网格数接近AI Core数量(grid=32)、UB用满、无尾块时性能最优(9.61us),适用于极大规模1D数据(400万级元素)的全量归约场景 |
| category | case |
| version | 1.0.0 |
| metadata | {"backend":"ascend","dsl":"triton_ascend","hardware":"Atlas A2, Atlas A3"} |
极大规模 1D Amin 归约优化
任务特征
优化 1:二次切分
pid = tl.program_id(0)
for start in range(0, BLOCK_SIZE, SUB_BLOCK_SIZE):
offsets = pid * BLOCK_SIZE + start + tl.arange(0, SUB_BLOCK_SIZE)
优化 2:计算重组
row_min = float('inf')
for n_start in range(0, BLOCK_SIZE, SUB_BLOCK_SIZE):
curr_min = tl.min(block_data)
row_min = tl.minimum(curr_min, row_min)
curr_min = tl.full((SUB_BLOCK_SIZE,), float('inf'), dtype=tl.float32)
for start in range(0, BLOCK_SIZE, SUB_BLOCK_SIZE):
curr_min = tl.minimum(curr_min, block_data)
min_val = tl.min(curr_min)
Autotune 配置
triton.Config({'BLOCK_SIZE': 262144, 'SUB_BLOCK_SIZE': 16384})
triton.Config({'BLOCK_SIZE': 131072, 'SUB_BLOCK_SIZE': 16384})
triton.Config({'BLOCK_SIZE': 131072, 'SUB_BLOCK_SIZE': 8192})
triton.Config({'BLOCK_SIZE': 104858, 'SUB_BLOCK_SIZE': 16384})
triton.Config({'BLOCK_SIZE': 65536, 'SUB_BLOCK_SIZE': 32768})
总结
网格数接近AI Core数量、UB用满、无尾块时性能最优。二次切分避免超出硬件缓存。