Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benchmarks/bench-argsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ template <typename T, class... Args>
static void avx512argsort(benchmark::State &state, Args &&...args)
{
auto args_tuple = std::make_tuple(std::move(args)...);
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
state.SkipWithMessage("Requires AVX512 BW ISA");
}
// Perform setup here
Expand Down Expand Up @@ -84,9 +84,9 @@ static void avx512argsort(benchmark::State &state, Args &&...args)
}
}

#define BENCH_BOTH(type)\
BENCH(avx512argsort, type)\
BENCH(stdargsort, type)\
#define BENCH_BOTH(type) \
BENCH(avx512argsort, type) \
BENCH(stdargsort, type)

BENCH_BOTH(int64_t)
BENCH_BOTH(uint64_t)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench-partial-qsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
template <typename T>
static void avx512_partial_qsort(benchmark::State &state)
{
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
state.SkipWithMessage("Requires AVX512 BW ISA");
}
if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) {
if ((sizeof(T) == 2) && (!__builtin_cpu_supports("avx512vbmi2"))) {
state.SkipWithMessage("Requires AVX512 VBMI2 ISA");
}
// Perform setup here
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench-qselect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
template <typename T>
static void avx512_qselect(benchmark::State &state)
{
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
state.SkipWithMessage("Requires AVX512 BW ISA");
}
if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) {
if ((sizeof(T) == 2) && (!__builtin_cpu_supports("avx512vbmi2"))) {
state.SkipWithMessage("Requires AVX512 VBMI2 ISA");
}
// Perform setup here
Expand Down
6 changes: 2 additions & 4 deletions benchmarks/bench-qsort-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "avx512-32bit-qsort.hpp"
#include "avx512-64bit-argsort.hpp"
#include "avx512-64bit-qsort.hpp"
#include "cpuinfo.h"

#include "rand_array.h"
#include <benchmark/benchmark.h>

Expand All @@ -19,8 +19,7 @@
})))

#define BENCH(func, type) \
MY_BENCHMARK_CAPTURE( \
func, type, random_5k, 5000, std::string("random")); \
MY_BENCHMARK_CAPTURE(func, type, random_5k, 5000, std::string("random")); \
MY_BENCHMARK_CAPTURE( \
func, type, random_100k, 100000, std::string("random")); \
MY_BENCHMARK_CAPTURE( \
Expand All @@ -34,5 +33,4 @@
MY_BENCHMARK_CAPTURE( \
func, type, reverse_10k, 10000, std::string("reverse"));


#endif
8 changes: 4 additions & 4 deletions benchmarks/bench-qsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ template <typename T, class... Args>
static void avx512qsort(benchmark::State &state, Args &&...args)
{
auto args_tuple = std::make_tuple(std::move(args)...);
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
state.SkipWithMessage("Requires AVX512 BW ISA");
}
if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) {
if ((sizeof(T) == 2) && (!__builtin_cpu_supports("avx512vbmi2"))) {
state.SkipWithMessage("Requires AVX512 VBMI2");
}
// Perform setup here
Expand Down Expand Up @@ -80,8 +80,8 @@ static void avx512qsort(benchmark::State &state, Args &&...args)
}
}

#define BENCH_BOTH_QSORT(type)\
BENCH(avx512qsort, type)\
#define BENCH_BOTH_QSORT(type) \
BENCH(avx512qsort, type) \
BENCH(stdsort, type)

BENCH_BOTH_QSORT(uint64_t)
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/bench-qsortfp16.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "avx512fp16-16bit-qsort.hpp"
#include "cpuinfo.h"

#include "rand_array.h"
#include <benchmark/benchmark.h>

template <typename T>
static void avx512_qsort(benchmark::State &state)
{
if (cpu_has_avx512fp16()) {
if (__builtin_cpu_supports("avx512fp16")) {
// Perform setup here
size_t ARRSIZE = state.range(0);
std::vector<T> arr;
Expand Down Expand Up @@ -35,7 +35,7 @@ static void avx512_qsort(benchmark::State &state)
template <typename T>
static void stdsort(benchmark::State &state)
{
if (cpu_has_avx512fp16()) {
if (__builtin_cpu_supports("avx512fp16")) {
// Perform setup here
size_t ARRSIZE = state.range(0);
std::vector<T> arr;
Expand Down Expand Up @@ -67,7 +67,7 @@ BENCHMARK(stdsort<_Float16>)->Arg(10000)->Arg(1000000);
template <typename T>
static void avx512_qselect(benchmark::State &state)
{
if (cpu_has_avx512fp16()) {
if (__builtin_cpu_supports("avx512fp16")) {
// Perform setup here
int64_t K = state.range(0);
size_t ARRSIZE = 10000;
Expand Down Expand Up @@ -98,7 +98,7 @@ static void avx512_qselect(benchmark::State &state)
template <typename T>
static void stdnthelement(benchmark::State &state)
{
if (cpu_has_avx512fp16()) {
if (__builtin_cpu_supports("avx512fp16")) {
// Perform setup here
int64_t K = state.range(0);
size_t ARRSIZE = 10000;
Expand Down Expand Up @@ -133,7 +133,7 @@ BENCHMARK(stdnthelement<_Float16>)->Arg(10)->Arg(100)->Arg(1000)->Arg(5000);
template <typename T>
static void avx512_partial_qsort(benchmark::State &state)
{
if (cpu_has_avx512fp16()) {
if (__builtin_cpu_supports("avx512fp16")) {
// Perform setup here
int64_t K = state.range(0);
size_t ARRSIZE = 10000;
Expand Down Expand Up @@ -164,7 +164,7 @@ static void avx512_partial_qsort(benchmark::State &state)
template <typename T>
static void stdpartialsort(benchmark::State &state)
{
if (cpu_has_avx512fp16()) {
if (__builtin_cpu_supports("avx512fp16")) {
// Perform setup here
int64_t K = state.range(0);
size_t ARRSIZE = 10000;
Expand Down
7 changes: 3 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ gtest_dep = dependency('gtest_main', required : true, static: true)
gbench_dep = dependency('benchmark', required : true, static: true)

fp16code = '''#include<immintrin.h>
int main() {
int main() {
__m512h temp = _mm512_set1_ph(1.0f);
__m512h var2 = _mm512_min_ph(temp, temp);
return 0;
}
'''
cancompilefp16 = cpp.compiles(fp16code, args:'-march=sapphirerapids')

subdir('utils')
subdir('tests')
subdir('benchmarks')

testexe = executable('testexe',
include_directories : [src, utils],
dependencies : gtest_dep,
link_whole : [libtests, libcpuinfo]
link_whole : [libtests]
)

benchexe = executable('benchexe',
include_directories : [src, utils, bench],
dependencies : [gbench_dep],
link_args: ['-lbenchmark_main'],
link_whole : [libbench, libcpuinfo],
link_whole : [libbench],
)

summary({
Expand Down
2 changes: 1 addition & 1 deletion tests/test-argselect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TYPED_TEST_SUITE_P(avx512argselect);

TYPED_TEST_P(avx512argselect, test_random)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
const int arrsize = 1024;
auto arr = get_uniform_rand_array<TypeParam>(arrsize);
std::vector<int64_t> sorted_inx;
Expand Down
2 changes: 1 addition & 1 deletion tests/test-argsort-common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "avx512-64bit-argsort.hpp"
#include "cpuinfo.h"

#include "rand_array.h"
#include <algorithm>
#include <gtest/gtest.h>
Expand Down
16 changes: 8 additions & 8 deletions tests/test-argsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TYPED_TEST_SUITE_P(avx512argsort);

TYPED_TEST_P(avx512argsort, test_random)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
std::vector<int64_t> arrsizes;
for (int64_t ii = 0; ii <= 1024; ++ii) {
arrsizes.push_back(ii);
Expand Down Expand Up @@ -39,7 +39,7 @@ TYPED_TEST_P(avx512argsort, test_random)

TYPED_TEST_P(avx512argsort, test_constant)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
std::vector<int64_t> arrsizes;
for (int64_t ii = 0; ii <= 1024; ++ii) {
arrsizes.push_back(ii);
Expand Down Expand Up @@ -71,7 +71,7 @@ TYPED_TEST_P(avx512argsort, test_constant)

TYPED_TEST_P(avx512argsort, test_small_range)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
std::vector<int64_t> arrsizes;
for (int64_t ii = 0; ii <= 1024; ++ii) {
arrsizes.push_back(ii);
Expand Down Expand Up @@ -100,7 +100,7 @@ TYPED_TEST_P(avx512argsort, test_small_range)

TYPED_TEST_P(avx512argsort, test_sorted)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
std::vector<int64_t> arrsizes;
for (int64_t ii = 0; ii <= 1024; ++ii) {
arrsizes.push_back(ii);
Expand Down Expand Up @@ -129,7 +129,7 @@ TYPED_TEST_P(avx512argsort, test_sorted)

TYPED_TEST_P(avx512argsort, test_reverse)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
std::vector<int64_t> arrsizes;
for (int64_t ii = 0; ii <= 1024; ++ii) {
arrsizes.push_back(ii);
Expand Down Expand Up @@ -159,7 +159,7 @@ TYPED_TEST_P(avx512argsort, test_reverse)

TYPED_TEST_P(avx512argsort, test_array_with_nan)
{
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
GTEST_SKIP() << "Skipping this test, it requires avx512bw ISA";
}
if (!std::is_floating_point<TypeParam>::value) {
Expand Down Expand Up @@ -193,7 +193,7 @@ TYPED_TEST_P(avx512argsort, test_array_with_nan)

TYPED_TEST_P(avx512argsort, test_max_value_at_end_of_array)
{
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
GTEST_SKIP() << "Skipping this test, it requires avx512bw ISA";
}
std::vector<int64_t> arrsizes;
Expand Down Expand Up @@ -224,7 +224,7 @@ TYPED_TEST_P(avx512argsort, test_max_value_at_end_of_array)

TYPED_TEST_P(avx512argsort, test_all_inf_array)
{
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
GTEST_SKIP() << "Skipping this test, it requires avx512bw ISA";
}
std::vector<int64_t> arrsizes;
Expand Down
4 changes: 2 additions & 2 deletions tests/test-keyvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* *******************************************/

#include "avx512-64bit-keyvaluesort.hpp"
#include "cpuinfo.h"

#include "rand_array.h"
#include <gtest/gtest.h>
#include <vector>
Expand All @@ -30,7 +30,7 @@ TYPED_TEST_SUITE_P(KeyValueSort);

TYPED_TEST_P(KeyValueSort, test_64bit_random_data)
{
if (cpu_has_avx512bw()) {
if (__builtin_cpu_supports("avx512bw")) {
std::vector<int64_t> keysizes;
for (int64_t ii = 0; ii < 1024; ++ii) {
keysizes.push_back((TypeParam)ii);
Expand Down
5 changes: 3 additions & 2 deletions tests/test-partial-qsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ TYPED_TEST_P(avx512_partial_sort, test_ranges)
int64_t arrsize = 1024;
int64_t nranges = 500;

if (cpu_has_avx512bw()) {
if ((sizeof(TypeParam) == 2) && (!cpu_has_avx512_vbmi2())) {
if (__builtin_cpu_supports("avx512bw")) {
if ((sizeof(TypeParam) == 2)
&& (!__builtin_cpu_supports("avx512vbmi2"))) {
GTEST_SKIP() << "Skipping this test, it requires avx512_vbmi2";
}
std::vector<TypeParam> arr;
Expand Down
10 changes: 6 additions & 4 deletions tests/test-qselect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ TYPED_TEST_SUITE_P(avx512_select);

TYPED_TEST_P(avx512_select, test_random)
{
if (cpu_has_avx512bw()) {
if ((sizeof(TypeParam) == 2) && (!cpu_has_avx512_vbmi2())) {
if (__builtin_cpu_supports("avx512bw")) {
if ((sizeof(TypeParam) == 2)
&& (!__builtin_cpu_supports("avx512vbmi2"))) {
GTEST_SKIP() << "Skipping this test, it requires avx512_vbmi2";
}
std::vector<int64_t> arrsizes;
Expand Down Expand Up @@ -51,8 +52,9 @@ TYPED_TEST_P(avx512_select, test_random)

TYPED_TEST_P(avx512_select, test_small_range)
{
if (cpu_has_avx512bw()) {
if ((sizeof(TypeParam) == 2) && (!cpu_has_avx512_vbmi2())) {
if (__builtin_cpu_supports("avx512bw")) {
if ((sizeof(TypeParam) == 2)
&& (!__builtin_cpu_supports("avx512vbmi2"))) {
GTEST_SKIP() << "Skipping this test, it requires avx512_vbmi2";
}
std::vector<int64_t> arrsizes;
Expand Down
2 changes: 1 addition & 1 deletion tests/test-qsort-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "avx512-16bit-qsort.hpp"
#include "avx512-32bit-qsort.hpp"
#include "avx512-64bit-qsort.hpp"
#include "cpuinfo.h"

#include "rand_array.h"
#include <gtest/gtest.h>

Expand Down
2 changes: 1 addition & 1 deletion tests/test-qsort-fp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TYPED_TEST_SUITE_P(avx512_sort_fp);
TYPED_TEST_P(avx512_sort_fp, test_random_nan)
{
const int num_nans = 3;
if (!cpu_has_avx512bw()) {
if (!__builtin_cpu_supports("avx512bw")) {
GTEST_SKIP() << "Skipping this test, it requires avx512bw";
}
std::vector<int64_t> arrsizes;
Expand Down
Loading