1
- #include < benchmark/benchmark.h>
2
- #include " rand_array.h"
3
- #include " cpuinfo.h"
4
1
#include " avx512fp16-16bit-qsort.hpp"
2
+ #include " cpuinfo.h"
3
+ #include " rand_array.h"
4
+ #include < benchmark/benchmark.h>
5
5
6
6
template <typename T>
7
- static void avx512_qsort (benchmark::State& state) {
7
+ static void avx512_qsort (benchmark::State &state)
8
+ {
8
9
if (cpu_has_avx512fp16 ()) {
9
10
// Perform setup here
10
11
size_t ARRSIZE = state.range (0 );
@@ -13,7 +14,7 @@ static void avx512_qsort(benchmark::State& state) {
13
14
14
15
/* Initialize elements */
15
16
for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
16
- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
17
+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
17
18
arr.push_back (temp);
18
19
}
19
20
arr_bkp = arr;
@@ -32,15 +33,16 @@ static void avx512_qsort(benchmark::State& state) {
32
33
}
33
34
34
35
template <typename T>
35
- static void stdsort (benchmark::State& state) {
36
+ static void stdsort (benchmark::State &state)
37
+ {
36
38
if (cpu_has_avx512fp16 ()) {
37
39
// Perform setup here
38
40
size_t ARRSIZE = state.range (0 );
39
41
std::vector<T> arr;
40
42
std::vector<T> arr_bkp;
41
43
42
44
for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
43
- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
45
+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
44
46
arr.push_back (temp);
45
47
}
46
48
arr_bkp = arr;
@@ -63,7 +65,8 @@ BENCHMARK(avx512_qsort<_Float16>)->Arg(10000)->Arg(1000000);
63
65
BENCHMARK (stdsort<_Float16>)->Arg(10000 )->Arg(1000000 );
64
66
65
67
template <typename T>
66
- static void avx512_qselect (benchmark::State& state) {
68
+ static void avx512_qselect (benchmark::State &state)
69
+ {
67
70
if (cpu_has_avx512fp16 ()) {
68
71
// Perform setup here
69
72
int64_t K = state.range (0 );
@@ -73,7 +76,7 @@ static void avx512_qselect(benchmark::State& state) {
73
76
74
77
/* Initialize elements */
75
78
for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
76
- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
79
+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
77
80
arr.push_back (temp);
78
81
}
79
82
arr_bkp = arr;
@@ -93,7 +96,8 @@ static void avx512_qselect(benchmark::State& state) {
93
96
}
94
97
95
98
template <typename T>
96
- static void stdnthelement (benchmark::State& state) {
99
+ static void stdnthelement (benchmark::State &state)
100
+ {
97
101
if (cpu_has_avx512fp16 ()) {
98
102
// Perform setup here
99
103
int64_t K = state.range (0 );
@@ -103,7 +107,7 @@ static void stdnthelement(benchmark::State& state) {
103
107
104
108
/* Initialize elements */
105
109
for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
106
- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
110
+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
107
111
arr.push_back (temp);
108
112
}
109
113
arr_bkp = arr;
@@ -127,7 +131,8 @@ BENCHMARK(avx512_qselect<_Float16>)->Arg(10)->Arg(100)->Arg(1000)->Arg(5000);
127
131
BENCHMARK (stdnthelement<_Float16>)->Arg(10 )->Arg(100 )->Arg(1000 )->Arg(5000 );
128
132
129
133
template <typename T>
130
- static void avx512_partial_qsort (benchmark::State& state) {
134
+ static void avx512_partial_qsort (benchmark::State &state)
135
+ {
131
136
if (cpu_has_avx512fp16 ()) {
132
137
// Perform setup here
133
138
int64_t K = state.range (0 );
@@ -137,7 +142,7 @@ static void avx512_partial_qsort(benchmark::State& state) {
137
142
138
143
/* Initialize elements */
139
144
for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
140
- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
145
+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
141
146
arr.push_back (temp);
142
147
}
143
148
arr_bkp = arr;
@@ -157,7 +162,8 @@ static void avx512_partial_qsort(benchmark::State& state) {
157
162
}
158
163
159
164
template <typename T>
160
- static void stdpartialsort (benchmark::State& state) {
165
+ static void stdpartialsort (benchmark::State &state)
166
+ {
161
167
if (cpu_has_avx512fp16 ()) {
162
168
// Perform setup here
163
169
int64_t K = state.range (0 );
@@ -167,7 +173,7 @@ static void stdpartialsort(benchmark::State& state) {
167
173
168
174
/* Initialize elements */
169
175
for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
170
- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
176
+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
171
177
arr.push_back (temp);
172
178
}
173
179
arr_bkp = arr;
@@ -187,5 +193,9 @@ static void stdpartialsort(benchmark::State& state) {
187
193
}
188
194
189
195
// Register the function as a benchmark
190
- BENCHMARK (avx512_partial_qsort<_Float16>)->Arg(10 )->Arg(100 )->Arg(1000 )->Arg(5000 );
196
+ BENCHMARK (avx512_partial_qsort<_Float16>)
197
+ ->Arg(10 )
198
+ ->Arg(100 )
199
+ ->Arg(1000 )
200
+ ->Arg(5000 );
191
201
BENCHMARK (stdpartialsort<_Float16>)->Arg(10 )->Arg(100 )->Arg(1000 )->Arg(5000 );
0 commit comments