File tree Expand file tree Collapse file tree 1 file changed +82
-2
lines changed Expand file tree Collapse file tree 1 file changed +82
-2
lines changed Original file line number Diff line number Diff line change 1
- # BitonicSort_ComputeShader
2
- key and index can be sorted
1
+ ## Introduction
2
+ Bitonic Sort implemented in ComputeShader.
3
+ Sort index and key together.
4
+ バイトニックソートのコンピュートシェーダー移植版
5
+ indexとkeyを一緒にソートします
6
+
7
+
8
+ ## 高速化
9
+
10
+ 高速化は
11
+ http://www.bealto.com/gpu-sorting_parallel-bitonic-1.html
12
+ を参考にしました。
13
+
14
+ ### Only B2
15
+
16
+ 1threadあたり2箇所Load,Storeを行います。
17
+ ![ gpuimpliment1] ( https://user-images.githubusercontent.com/44022497/87314023-a8a16000-c55d-11ea-9353-6dd51890e7d6.png )
18
+
19
+ 一番標準的な実装です。実行時間(ms)の表です。
20
+
21
+ | 要素数/カーネル名| B2|
22
+ | ---| ---|
23
+ | 65536| 1|
24
+ | 131072| 1|
25
+ | 262144| 2|
26
+ | 524288| 4|
27
+ | 1048576| 10|
28
+ | 2097152| 19|
29
+ | 4194304| 39|
30
+ | 8388608| 83|
31
+ | 16777216| 179|
32
+ | 33554432| 382|
33
+ | 67108864| 818|
34
+ | 134217728| 1744|
35
+
36
+ ### B2C2
37
+
38
+ Shared Memoryを使った高速化版です。
39
+ ![ shared1] ( https://user-images.githubusercontent.com/44022497/87314088-b8b93f80-c55d-11ea-8e55-df8c4850bfc5.png )
40
+
41
+ 青の部分はグローバルメモリへ書き込みをしないでShared memoryに書き込み使いまわしている部分です。
42
+ グローバルメモリのアクセスを抑えたことにより高速化できます。
43
+
44
+ | 要素数/カーネル名| B2| B2C2|
45
+ | ---| ---| ---|
46
+ | 65536| 1| 0|
47
+ | 131072| 1| 1|
48
+ | 262144| 2| 1|
49
+ | 524288| 4| 3|
50
+ | 1048576| 10| 8|
51
+ | 2097152| 19| 11|
52
+ | 4194304| 39| 24|
53
+ | 8388608| 83| 51|
54
+ | 16777216| 179| 109|
55
+ | 33554432| 382| 236|
56
+ | 67108864| 818| 508|
57
+ | 134217728| 1744| 1095|
58
+
59
+ ### B2B4B8B16C2C4
60
+
61
+ 1threadあたり4箇所Load,Storeを行うことでグローバルメモリのアクセス回数を減らします。
62
+ ![ gpuimpliment2] ( https://user-images.githubusercontent.com/44022497/87314155-c66ec500-c55d-11ea-9bd9-a8227274e079.png )
63
+ これを8,16と増やすことでさらなる高速化ができました。
64
+ Shared memory内も1threadあたり4箇所Load,Storeを行うことでShared memoryへのアクセス回数を減らします。
65
+
66
+ | 要素数/カーネル名| B2| B2C2| B2B4B8B16C2C4|
67
+ | ---| ---| ---| ---|
68
+ | 65536| 1| 0| 0|
69
+ | 131072| 1| 1| 0|
70
+ | 262144| 2| 1| 1|
71
+ | 524288| 4| 3| 2|
72
+ | 1048576| 10| 8| 5|
73
+ | 2097152| 19| 11| 7|
74
+ | 4194304| 39| 24| 14|
75
+ | 8388608| 83| 51| 29|
76
+ | 16777216| 179| 109| 60|
77
+ | 33554432| 382| 236| 127|
78
+ | 67108864| 818| 508| 264|
79
+ | 134217728| 1744| 1095| 552|
80
+
81
+
82
+ 最終進化形だとここまで速くなります。最初と比べ3倍以上高速化できました!!わーい
You can’t perform that action at this time.
0 commit comments