1- #include < benchmark/benchmark.h>
2- #include " rand_array.h"
3- #include " cpuinfo.h"
41#include " avx512fp16-16bit-qsort.hpp"
2+ #include " cpuinfo.h"
3+ #include " rand_array.h"
4+ #include < benchmark/benchmark.h>
55
66template <typename T>
7- static void avx512_qsort (benchmark::State& state) {
7+ static void avx512_qsort (benchmark::State &state)
8+ {
89 if (cpu_has_avx512fp16 ()) {
910 // Perform setup here
1011 size_t ARRSIZE = state.range (0 );
@@ -13,7 +14,7 @@ static void avx512_qsort(benchmark::State& state) {
1314
1415 /* Initialize elements */
1516 for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
16- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
17+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
1718 arr.push_back (temp);
1819 }
1920 arr_bkp = arr;
@@ -32,15 +33,16 @@ static void avx512_qsort(benchmark::State& state) {
3233}
3334
3435template <typename T>
35- static void stdsort (benchmark::State& state) {
36+ static void stdsort (benchmark::State &state)
37+ {
3638 if (cpu_has_avx512fp16 ()) {
3739 // Perform setup here
3840 size_t ARRSIZE = state.range (0 );
3941 std::vector<T> arr;
4042 std::vector<T> arr_bkp;
4143
4244 for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
43- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
45+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
4446 arr.push_back (temp);
4547 }
4648 arr_bkp = arr;
@@ -63,7 +65,8 @@ BENCHMARK(avx512_qsort<_Float16>)->Arg(10000)->Arg(1000000);
6365BENCHMARK (stdsort<_Float16>)->Arg(10000 )->Arg(1000000 );
6466
6567template <typename T>
66- static void avx512_qselect (benchmark::State& state) {
68+ static void avx512_qselect (benchmark::State &state)
69+ {
6770 if (cpu_has_avx512fp16 ()) {
6871 // Perform setup here
6972 int64_t K = state.range (0 );
@@ -73,7 +76,7 @@ static void avx512_qselect(benchmark::State& state) {
7376
7477 /* Initialize elements */
7578 for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
76- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
79+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
7780 arr.push_back (temp);
7881 }
7982 arr_bkp = arr;
@@ -93,7 +96,8 @@ static void avx512_qselect(benchmark::State& state) {
9396}
9497
9598template <typename T>
96- static void stdnthelement (benchmark::State& state) {
99+ static void stdnthelement (benchmark::State &state)
100+ {
97101 if (cpu_has_avx512fp16 ()) {
98102 // Perform setup here
99103 int64_t K = state.range (0 );
@@ -103,7 +107,7 @@ static void stdnthelement(benchmark::State& state) {
103107
104108 /* Initialize elements */
105109 for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
106- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
110+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
107111 arr.push_back (temp);
108112 }
109113 arr_bkp = arr;
@@ -127,7 +131,8 @@ BENCHMARK(avx512_qselect<_Float16>)->Arg(10)->Arg(100)->Arg(1000)->Arg(5000);
127131BENCHMARK (stdnthelement<_Float16>)->Arg(10 )->Arg(100 )->Arg(1000 )->Arg(5000 );
128132
129133template <typename T>
130- static void avx512_partial_qsort (benchmark::State& state) {
134+ static void avx512_partial_qsort (benchmark::State &state)
135+ {
131136 if (cpu_has_avx512fp16 ()) {
132137 // Perform setup here
133138 int64_t K = state.range (0 );
@@ -137,7 +142,7 @@ static void avx512_partial_qsort(benchmark::State& state) {
137142
138143 /* Initialize elements */
139144 for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
140- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
145+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
141146 arr.push_back (temp);
142147 }
143148 arr_bkp = arr;
@@ -157,7 +162,8 @@ static void avx512_partial_qsort(benchmark::State& state) {
157162}
158163
159164template <typename T>
160- static void stdpartialsort (benchmark::State& state) {
165+ static void stdpartialsort (benchmark::State &state)
166+ {
161167 if (cpu_has_avx512fp16 ()) {
162168 // Perform setup here
163169 int64_t K = state.range (0 );
@@ -167,7 +173,7 @@ static void stdpartialsort(benchmark::State& state) {
167173
168174 /* Initialize elements */
169175 for (size_t jj = 0 ; jj < ARRSIZE; ++jj) {
170- _Float16 temp = (float ) rand () / (float )(RAND_MAX);
176+ _Float16 temp = (float )rand () / (float )(RAND_MAX);
171177 arr.push_back (temp);
172178 }
173179 arr_bkp = arr;
@@ -187,5 +193,9 @@ static void stdpartialsort(benchmark::State& state) {
187193}
188194
189195// 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 );
191201BENCHMARK (stdpartialsort<_Float16>)->Arg(10 )->Arg(100 )->Arg(1000 )->Arg(5000 );
0 commit comments