ITADN

Reduce kernel maybe need some modifications in certain areas to make it more efficient.

#405OpenJackWang2120 创建于 2026-01-15
stale
J
JackWang2120commented
Hi,First of all, thank you for sharing the CUDA kernel code. When I was looking at the current repo's reduce kernel, I found the following code below: <img width="581" height="540" alt="Image" src="https://github.com/user-attachments/assets/8cac3075-b367-4856-83dc-a1fb81a1f514" /> When you use first warp to compute the cross warp reduce sum, you first load the data from shared memory into registers and then check if you are in the first warp. Does this result in a lot of redundant register resource usage in non-first warps? I think perhaps this code could be written more efficiently in the following way. ``` if(warp == 0){ sum = (lane < NUM_WARPS) ? reduce_smem[lane]:0.0f; sum = warp_reduce_sum<NUM_WARPS>(sum); if(lane == 0)atomicAdd(y, sum); } ```
1 条评论