Skip to content

Commit bacb655

Browse files
author
Raghuveer Devulapalli
committed
Add vqsort to benchmarks
1 parent 5a9edc4 commit bacb655

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

benchmarks/bench-vqsort.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "bench.h"
2+
#define VQSORT_ONLY_STATIC 1
3+
#include "hwy/contrib/sort/vqsort-inl.h"
4+
5+
template <typename T, class... Args>
6+
static void vqsort(benchmark::State &state, Args &&...args)
7+
{
8+
// Get args
9+
auto args_tuple = std::make_tuple(std::move(args)...);
10+
size_t arrsize = std::get<0>(args_tuple);
11+
std::string arrtype = std::get<1>(args_tuple);
12+
// set up array
13+
std::vector<T> arr = get_array<T>(arrtype, arrsize);
14+
std::vector<T> arr_bkp = arr;
15+
// benchmark
16+
for (auto _ : state) {
17+
hwy::HWY_NAMESPACE::VQSortStatic(arr.data(), arrsize, hwy::SortAscending());
18+
state.PauseTiming();
19+
arr = arr_bkp;
20+
state.ResumeTiming();
21+
}
22+
}
23+
24+
BENCH_SORT(vqsort, uint64_t)
25+
BENCH_SORT(vqsort, int64_t)
26+
BENCH_SORT(vqsort, uint32_t)
27+
BENCH_SORT(vqsort, int32_t)
28+
BENCH_SORT(vqsort, float)
29+
BENCH_SORT(vqsort, double)

benchmarks/meson.build

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ libbench += static_library('bench_qsort',
88
include_directories : [src, lib, utils],
99
cpp_args : ['-O3'],
1010
)
11+
12+
if fs.is_file('highway/hwy/contrib/sort/vqsort-inl.h')
13+
hwy = include_directories('highway')
14+
libbench += static_library('bench_vqsort',
15+
files(
16+
'bench-vqsort.cpp',
17+
),
18+
dependencies: gbench_dep,
19+
include_directories : [src, lib, utils, hwy],
20+
cpp_args : ['-O3', '-march=native'],
21+
)
22+
endif

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ project('x86-simd-sort', 'cpp',
22
version : '4.0.0',
33
license : 'BSD 3-clause',
44
default_options : ['cpp_std=c++17'])
5+
fs = import('fs')
56
cpp = meson.get_compiler('cpp')
67
src = include_directories('src')
78
lib = include_directories('lib')

0 commit comments

Comments
 (0)