@@ -33,30 +33,23 @@ GPU Kernel直接影响了算子性能, 我们推荐采用以下等通用优化
33
33
34
34
我们推荐结合OP的使用场景设计对于的线程配置策略,如下图所示[ IndexSample OP] ( https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/index_sample_cn.html#index-sample ) 常用于处理2维数据, 因此使用[ 2维的线程配置策略] ( https://github.com/PaddlePaddle/Paddle/blob/30838aa698d6f3f3b0860b052f6a50ef53ac6784/paddle/phi/kernels/gpu/index_sample_kernel.cu#L82-L91 ) 相对比1维配置策略,性能可提升20%左右。
35
35
36
- <figure align =" center " >
37
- <img src="../images/index_sample.png" width=80% height=80%/>
38
- <figcaption><center>图1. IndexSample OP 线程配置策略</center></figcaption>
39
- </figure >
36
+ <img src =" https://raw.githubusercontent.com/PaddlePaddle/docs/develop/docs/dev_guides/images/index_sample.png " style =" zoom :50% " />
37
+
40
38
41
39
优化GPU Kernel中的线程配置策略, 涵盖一维、二维、三维线程配置策略, 目前已经在` Elementwise ` , ` Stack ` , ` IndexSample ` 等OP中使用.
42
40
43
41
### 2.2 [ Warp计算优化] ( https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/kernels/funcs/math_cuda_utils.h )
44
42
45
43
飞桨内对上文中提到的** Warp级操作** 进行了封装, 提供了简易的调用接口, 开发者可调用接口快速获得Warp内或者Block内的全部数据的求和、最大值、最小值.
46
44
47
- <figure align =" center " >
48
- <img src="../images/cuda_math_utils.png" width=80% height=80%/>
49
- <figcaption><center>图2. Warp级操作封装</center></figcaption>
50
- </figure >
45
+ <img src =" https://raw.githubusercontent.com/PaddlePaddle/docs/develop/docs/dev_guides/images/cuda_math_utils.png " style =" zoom :50% " />
46
+
51
47
52
48
### 2.3 [ 索引计算优化] ( https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/platform/fast_divmod.h ) :
53
49
54
50
当GPU Kernel的索引计算中存在除法或取模操作, 将在导致汇编层面计算开销变大, 我们建议采用快速除法优化这部分的计算开销。飞桨内[ Pooling OP] ( https://github.com/PaddlePaddle/Paddle/blob/890c73158f663b327be7664ed6c4d08fb2c236a9/paddle/phi/kernels/funcs/pooling.cu#L41-L101 ) 采用索引优化计算后, 性能提升1倍.
55
51
56
- <figure align =" center " >
57
- <img src="../images/fast_divmod.png" width=50% height=50%/>
58
- <figcaption><center>图3. 快速整型除法操作</center></figcaption>
59
- </figure >
52
+ <img src =" https://raw.githubusercontent.com/PaddlePaddle/docs/develop/docs/dev_guides/images/fast_divmod.png " style =" zoom :50% " />
60
53
61
54
### 2.4 [ Kps优化工具库] ( https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/dev_guides/kernel_primitive_api/index_cn.html )
62
55
0 commit comments