Skip to content

Commit b66f426

Browse files
author
Raghuveer Devulapalli
committed
Use __builtin_cpu_supports
1 parent 658de9b commit b66f426

17 files changed

+52
-52
lines changed

benchmarks/bench-argsort.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ template <typename T, class... Args>
5252
static void avx512argsort(benchmark::State &state, Args &&...args)
5353
{
5454
auto args_tuple = std::make_tuple(std::move(args)...);
55-
if (!cpu_has_avx512bw()) {
55+
if (!__builtin_cpu_supports("avx512bw")) {
5656
state.SkipWithMessage("Requires AVX512 BW ISA");
5757
}
5858
// Perform setup here

benchmarks/bench-partial-qsort.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
template <typename T>
44
static void avx512_partial_qsort(benchmark::State &state)
55
{
6-
if (!cpu_has_avx512bw()) {
6+
if (!__builtin_cpu_supports("avx512bw")) {
77
state.SkipWithMessage("Requires AVX512 BW ISA");
88
}
9-
if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) {
9+
if ((sizeof(T) == 2) && (!__builtin_cpu_supports("avx512vbmi2"))) {
1010
state.SkipWithMessage("Requires AVX512 VBMI2 ISA");
1111
}
1212
// Perform setup here

benchmarks/bench-qselect.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
template <typename T>
44
static void avx512_qselect(benchmark::State &state)
55
{
6-
if (!cpu_has_avx512bw()) {
6+
if (!__builtin_cpu_supports("avx512bw")) {
77
state.SkipWithMessage("Requires AVX512 BW ISA");
88
}
9-
if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) {
9+
if ((sizeof(T) == 2) && (!__builtin_cpu_supports("avx512vbmi2"))) {
1010
state.SkipWithMessage("Requires AVX512 VBMI2 ISA");
1111
}
1212
// Perform setup here

benchmarks/bench-qsort-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "avx512-32bit-qsort.hpp"
66
#include "avx512-64bit-argsort.hpp"
77
#include "avx512-64bit-qsort.hpp"
8-
#include "cpuinfo.h"
8+
99
#include "rand_array.h"
1010
#include <benchmark/benchmark.h>
1111

benchmarks/bench-qsort.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ template <typename T, class... Args>
4141
static void avx512qsort(benchmark::State &state, Args &&...args)
4242
{
4343
auto args_tuple = std::make_tuple(std::move(args)...);
44-
if (!cpu_has_avx512bw()) {
44+
if (!__builtin_cpu_supports("avx512bw")) {
4545
state.SkipWithMessage("Requires AVX512 BW ISA");
4646
}
47-
if ((sizeof(T) == 2) && (!cpu_has_avx512_vbmi2())) {
47+
if ((sizeof(T) == 2) && (!__builtin_cpu_supports("avx512vbmi2"))) {
4848
state.SkipWithMessage("Requires AVX512 VBMI2");
4949
}
5050
// Perform setup here

benchmarks/bench-qsortfp16.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "avx512fp16-16bit-qsort.hpp"
2-
#include "cpuinfo.h"
2+
33
#include "rand_array.h"
44
#include <benchmark/benchmark.h>
55

66
template <typename T>
77
static void avx512_qsort(benchmark::State &state)
88
{
9-
if (cpu_has_avx512fp16()) {
9+
if (__builtin_cpu_supports("avx512fp16")) {
1010
// Perform setup here
1111
size_t ARRSIZE = state.range(0);
1212
std::vector<T> arr;
@@ -35,7 +35,7 @@ static void avx512_qsort(benchmark::State &state)
3535
template <typename T>
3636
static void stdsort(benchmark::State &state)
3737
{
38-
if (cpu_has_avx512fp16()) {
38+
if (__builtin_cpu_supports("avx512fp16")) {
3939
// Perform setup here
4040
size_t ARRSIZE = state.range(0);
4141
std::vector<T> arr;
@@ -67,7 +67,7 @@ BENCHMARK(stdsort<_Float16>)->Arg(10000)->Arg(1000000);
6767
template <typename T>
6868
static void avx512_qselect(benchmark::State &state)
6969
{
70-
if (cpu_has_avx512fp16()) {
70+
if (__builtin_cpu_supports("avx512fp16")) {
7171
// Perform setup here
7272
int64_t K = state.range(0);
7373
size_t ARRSIZE = 10000;
@@ -98,7 +98,7 @@ static void avx512_qselect(benchmark::State &state)
9898
template <typename T>
9999
static void stdnthelement(benchmark::State &state)
100100
{
101-
if (cpu_has_avx512fp16()) {
101+
if (__builtin_cpu_supports("avx512fp16")) {
102102
// Perform setup here
103103
int64_t K = state.range(0);
104104
size_t ARRSIZE = 10000;
@@ -133,7 +133,7 @@ BENCHMARK(stdnthelement<_Float16>)->Arg(10)->Arg(100)->Arg(1000)->Arg(5000);
133133
template <typename T>
134134
static void avx512_partial_qsort(benchmark::State &state)
135135
{
136-
if (cpu_has_avx512fp16()) {
136+
if (__builtin_cpu_supports("avx512fp16")) {
137137
// Perform setup here
138138
int64_t K = state.range(0);
139139
size_t ARRSIZE = 10000;
@@ -164,7 +164,7 @@ static void avx512_partial_qsort(benchmark::State &state)
164164
template <typename T>
165165
static void stdpartialsort(benchmark::State &state)
166166
{
167-
if (cpu_has_avx512fp16()) {
167+
if (__builtin_cpu_supports("avx512fp16")) {
168168
// Perform setup here
169169
int64_t K = state.range(0);
170170
size_t ARRSIZE = 10000;

meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ subdir('benchmarks')
2424
testexe = executable('testexe',
2525
include_directories : [src, utils],
2626
dependencies : gtest_dep,
27-
link_whole : [libtests, libcpuinfo]
27+
link_whole : [libtests]
2828
)
2929

3030
benchexe = executable('benchexe',
3131
include_directories : [src, utils, bench],
3232
dependencies : [gbench_dep],
3333
link_args: ['-lbenchmark_main'],
34-
link_whole : [libbench, libcpuinfo],
34+
link_whole : [libbench],
3535
)
3636

3737
summary({

tests/test-argselect.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TYPED_TEST_SUITE_P(avx512argselect);
1111

1212
TYPED_TEST_P(avx512argselect, test_random)
1313
{
14-
if (cpu_has_avx512bw()) {
14+
if (__builtin_cpu_supports("avx512bw")) {
1515
const int arrsize = 1024;
1616
auto arr = get_uniform_rand_array<TypeParam>(arrsize);
1717
std::vector<int64_t> sorted_inx;

tests/test-argsort-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "avx512-64bit-argsort.hpp"
2-
#include "cpuinfo.h"
2+
33
#include "rand_array.h"
44
#include <algorithm>
55
#include <gtest/gtest.h>

tests/test-argsort.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TYPED_TEST_SUITE_P(avx512argsort);
1010

1111
TYPED_TEST_P(avx512argsort, test_random)
1212
{
13-
if (cpu_has_avx512bw()) {
13+
if (__builtin_cpu_supports("avx512bw")) {
1414
std::vector<int64_t> arrsizes;
1515
for (int64_t ii = 0; ii <= 1024; ++ii) {
1616
arrsizes.push_back(ii);
@@ -39,7 +39,7 @@ TYPED_TEST_P(avx512argsort, test_random)
3939

4040
TYPED_TEST_P(avx512argsort, test_constant)
4141
{
42-
if (cpu_has_avx512bw()) {
42+
if (__builtin_cpu_supports("avx512bw")) {
4343
std::vector<int64_t> arrsizes;
4444
for (int64_t ii = 0; ii <= 1024; ++ii) {
4545
arrsizes.push_back(ii);
@@ -71,7 +71,7 @@ TYPED_TEST_P(avx512argsort, test_constant)
7171

7272
TYPED_TEST_P(avx512argsort, test_small_range)
7373
{
74-
if (cpu_has_avx512bw()) {
74+
if (__builtin_cpu_supports("avx512bw")) {
7575
std::vector<int64_t> arrsizes;
7676
for (int64_t ii = 0; ii <= 1024; ++ii) {
7777
arrsizes.push_back(ii);
@@ -100,7 +100,7 @@ TYPED_TEST_P(avx512argsort, test_small_range)
100100

101101
TYPED_TEST_P(avx512argsort, test_sorted)
102102
{
103-
if (cpu_has_avx512bw()) {
103+
if (__builtin_cpu_supports("avx512bw")) {
104104
std::vector<int64_t> arrsizes;
105105
for (int64_t ii = 0; ii <= 1024; ++ii) {
106106
arrsizes.push_back(ii);
@@ -129,7 +129,7 @@ TYPED_TEST_P(avx512argsort, test_sorted)
129129

130130
TYPED_TEST_P(avx512argsort, test_reverse)
131131
{
132-
if (cpu_has_avx512bw()) {
132+
if (__builtin_cpu_supports("avx512bw")) {
133133
std::vector<int64_t> arrsizes;
134134
for (int64_t ii = 0; ii <= 1024; ++ii) {
135135
arrsizes.push_back(ii);
@@ -159,7 +159,7 @@ TYPED_TEST_P(avx512argsort, test_reverse)
159159

160160
TYPED_TEST_P(avx512argsort, test_array_with_nan)
161161
{
162-
if (!cpu_has_avx512bw()) {
162+
if (!__builtin_cpu_supports("avx512bw")) {
163163
GTEST_SKIP() << "Skipping this test, it requires avx512bw ISA";
164164
}
165165
if (!std::is_floating_point<TypeParam>::value) {
@@ -193,7 +193,7 @@ TYPED_TEST_P(avx512argsort, test_array_with_nan)
193193

194194
TYPED_TEST_P(avx512argsort, test_max_value_at_end_of_array)
195195
{
196-
if (!cpu_has_avx512bw()) {
196+
if (!__builtin_cpu_supports("avx512bw")) {
197197
GTEST_SKIP() << "Skipping this test, it requires avx512bw ISA";
198198
}
199199
std::vector<int64_t> arrsizes;
@@ -224,7 +224,7 @@ TYPED_TEST_P(avx512argsort, test_max_value_at_end_of_array)
224224

225225
TYPED_TEST_P(avx512argsort, test_all_inf_array)
226226
{
227-
if (!cpu_has_avx512bw()) {
227+
if (!__builtin_cpu_supports("avx512bw")) {
228228
GTEST_SKIP() << "Skipping this test, it requires avx512bw ISA";
229229
}
230230
std::vector<int64_t> arrsizes;

0 commit comments

Comments
 (0)