优化了reducesum算子的速度与吞吐量 #7

Merged
wawahejun merged 1 commits from meiying/GPUKernelContest:main into main 2026-02-13 17:57:13 +08:00
Contributor

具体优化内容
1.使用多级归约,先将数据分为多块,进行块内归约,再将块内归约的结果进行归约。
2.在此基础上,通过调整线程块的大小和每个线程处理的元素数量来提升GPU利用率以及内存访问速度;
3.我们分别尝试了64,128,256,512,最终确定256为最佳线程块大小;
4.同时,每个线程处理两个元素,但采用交错加载保证每次都是访问连续地址;
5.最后的warp内归约使用手动归约以提升访问和计算速度;

性能提升(设备:曦云 C500 显存32G):
默认实现:
数据规模 时间(ms) 吞吐量(G/s)

 1000000          0.093              10.726

134217728 0.436 307.500
536870912 1.386 387.400
1073741824 2.684 400.075

优化后:
数据规模 时间(ms) 吞吐量(G/s)

 1000000          0.065              15.379

134217728 0.065 2054.420
536870912 0.065 8308.843
1073741824 0.075 14276.052

**具体优化内容**: 1.使用多级归约,先将数据分为多块,进行块内归约,再将块内归约的结果进行归约。 2.在此基础上,通过调整线程块的大小和每个线程处理的元素数量来提升GPU利用率以及内存访问速度; 3.我们分别尝试了64,128,256,512,最终确定256为最佳线程块大小; 4.同时,每个线程处理两个元素,但采用交错加载保证每次都是访问连续地址; 5.最后的warp内归约使用手动归约以提升访问和计算速度; **性能提升(设备:曦云 C500 显存32G):** 默认实现: 数据规模 时间(ms) 吞吐量(G/s) ----------------------------------------------- 1000000 0.093 10.726 134217728 0.436 307.500 536870912 1.386 387.400 1073741824 2.684 400.075 优化后: 数据规模 时间(ms) 吞吐量(G/s) ----------------------------------------------- 1000000 0.065 15.379 134217728 0.065 2054.420 536870912 0.065 8308.843 1073741824 0.075 14276.052
meiying added 1 commit 2025-11-25 16:53:21 +08:00
wawahejun merged commit 55ce894285 into main 2026-02-13 17:57:13 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ccf-ai-infra/GPUKernelContest#7
No description provided.