forked from numpy/x86-simd-sort
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench-vqsort.cpp
More file actions
32 lines (30 loc) · 933 Bytes
/
Copy pathbench-vqsort.cpp
File metadata and controls
32 lines (30 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "bench.h"
#define VQSORT_ONLY_STATIC 1
#include "hwy/contrib/sort/vqsort-inl.h"
template <typename T, class... Args>
static void vqsort(benchmark::State &state, Args &&...args)
{
// Get args
auto args_tuple = std::make_tuple(std::move(args)...);
size_t arrsize = std::get<0>(args_tuple);
std::string arrtype = std::get<1>(args_tuple);
// set up array
std::vector<T> arr = get_array<T>(arrtype, arrsize);
std::vector<T> arr_bkp = arr;
// benchmark
for (auto _ : state) {
hwy::HWY_NAMESPACE::VQSortStatic(
arr.data(), arrsize, hwy::SortAscending());
state.PauseTiming();
arr = arr_bkp;
state.ResumeTiming();
}
}
BENCH_SORT(vqsort, uint64_t)
BENCH_SORT(vqsort, int64_t)
BENCH_SORT(vqsort, uint32_t)
BENCH_SORT(vqsort, int32_t)
BENCH_SORT(vqsort, uint16_t)
BENCH_SORT(vqsort, int16_t)
BENCH_SORT(vqsort, float)
BENCH_SORT(vqsort, double)