|
1 |
| -#include <benchmark/benchmark.h> |
2 |
| -#include "rand_array.h" |
3 |
| -#include "cpuinfo.h" |
4 |
| -#include "avx512-16bit-qsort.hpp" |
5 |
| -#include "avx512-32bit-qsort.hpp" |
6 |
| -#include "avx512-64bit-qsort.hpp" |
7 |
| - |
8 |
| -template <typename T> |
9 |
| -static void avx512_qsort(benchmark::State& state) { |
10 |
| - if (!cpu_has_avx512bw()) { |
11 |
| - state.SkipWithMessage("Requires AVX512 BW ISA"); |
12 |
| - } |
13 |
| - if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) { |
14 |
| - state.SkipWithMessage("Requires AVX512 VBMI2 ISA"); |
15 |
| - } |
16 |
| - // Perform setup here |
17 |
| - size_t ARRSIZE = state.range(0); |
18 |
| - std::vector<T> arr; |
19 |
| - std::vector<T> arr_bkp; |
20 |
| - |
21 |
| - /* Initialize elements is reverse order */ |
22 |
| - arr = get_uniform_rand_array<T>(ARRSIZE); |
23 |
| - arr_bkp = arr; |
24 |
| - |
25 |
| - /* call avx512 quicksort */ |
26 |
| - for (auto _ : state) { |
27 |
| - avx512_qsort<T>(arr.data(), ARRSIZE); |
28 |
| - state.PauseTiming(); |
29 |
| - arr = arr_bkp; |
30 |
| - state.ResumeTiming(); |
31 |
| - } |
32 |
| -} |
33 |
| - |
34 |
| -template <typename T> |
35 |
| -static void stdsort(benchmark::State& state) { |
36 |
| - // Perform setup here |
37 |
| - size_t ARRSIZE = state.range(0); |
38 |
| - std::vector<T> arr; |
39 |
| - std::vector<T> arr_bkp; |
40 |
| - |
41 |
| - /* Initialize elements is reverse order */ |
42 |
| - arr = get_uniform_rand_array<T>(ARRSIZE); |
43 |
| - arr_bkp = arr; |
44 |
| - |
45 |
| - /* call avx512 quicksort */ |
46 |
| - for (auto _ : state) { |
47 |
| - std::sort(arr.begin(), arr.end()); |
48 |
| - state.PauseTiming(); |
49 |
| - arr = arr_bkp; |
50 |
| - state.ResumeTiming(); |
51 |
| - } |
52 |
| -} |
53 |
| - |
54 |
| -// Register the function as a benchmark |
55 |
| -BENCHMARK(avx512_qsort<float>)->Arg(10000)->Arg(1000000); |
56 |
| -BENCHMARK(stdsort<float>)->Arg(10000)->Arg(1000000); |
57 |
| -BENCHMARK(avx512_qsort<uint32_t>)->Arg(10000)->Arg(1000000); |
58 |
| -BENCHMARK(stdsort<uint32_t>)->Arg(10000)->Arg(1000000); |
59 |
| -BENCHMARK(avx512_qsort<int32_t>)->Arg(10000)->Arg(1000000); |
60 |
| -BENCHMARK(stdsort<int32_t>)->Arg(10000)->Arg(1000000); |
61 |
| - |
62 |
| -BENCHMARK(avx512_qsort<double>)->Arg(10000)->Arg(1000000); |
63 |
| -BENCHMARK(stdsort<double>)->Arg(10000)->Arg(1000000); |
64 |
| -BENCHMARK(avx512_qsort<uint64_t>)->Arg(10000)->Arg(1000000); |
65 |
| -BENCHMARK(stdsort<uint64_t>)->Arg(10000)->Arg(1000000); |
66 |
| -BENCHMARK(avx512_qsort<int64_t>)->Arg(10000)->Arg(1000000); |
67 |
| -BENCHMARK(stdsort<int64_t>)->Arg(10000)->Arg(10000000); |
68 |
| - |
69 |
| -//BENCHMARK(avx512_qsort<float16>)->Arg(10000)->Arg(1000000); |
70 |
| -BENCHMARK(avx512_qsort<uint16_t>)->Arg(10000)->Arg(1000000); |
71 |
| -BENCHMARK(stdsort<uint16_t>)->Arg(10000)->Arg(1000000); |
72 |
| -BENCHMARK(avx512_qsort<int16_t>)->Arg(10000)->Arg(1000000); |
73 |
| -BENCHMARK(stdsort<int16_t>)->Arg(10000)->Arg(10000000); |
| 1 | +#include "bench_qsort.hpp" |
| 2 | +#include "bench_qselect.hpp" |
| 3 | +#include "bench_partial_qsort.hpp" |
0 commit comments