Skip to content

Commit 27ec4ff

Browse files
Provide stub for avx vnni architecture
1 parent fdd4086 commit 27ec4ff

File tree

6 files changed

+88
-6
lines changed

6 files changed

+88
-6
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/***************************************************************************
2+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
3+
* Martin Renou *
4+
* Copyright (c) QuantStack *
5+
* Copyright (c) Serge Guelton *
6+
* *
7+
* Distributed under the terms of the BSD 3-Clause License. *
8+
* *
9+
* The full license is in the file LICENSE, distributed with this software. *
10+
****************************************************************************/
11+
12+
#ifndef XSIMD_AVXVNNI_HPP
13+
#define XSIMD_AVXVNNI_HPP
14+
15+
#include <array>
16+
#include <type_traits>
17+
18+
#include "../types/xsimd_avxvnni_register.hpp"
19+
20+
#endif

include/xsimd/arch/xsimd_isa.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#include "./xsimd_fma3_avx.hpp"
5353
#endif
5454

55+
#if XSIMD_WITH_AVXVNNI
56+
#include "./xsimd_avxvnni.hpp"
57+
#endif
58+
5559
#if XSIMD_WITH_AVX2
5660
#include "./xsimd_avx2.hpp"
5761
#endif

include/xsimd/config/xsimd_config.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@
9999
#define XSIMD_WITH_AVX2 0
100100
#endif
101101

102+
/**
103+
* @ingroup xsimd_config_macro
104+
*
105+
* Set to 1 if AVXVNNI is available at compile-time, to 0 otherwise.
106+
*/
107+
#ifdef __AVXVNNI__
108+
#define XSIMD_WITH_AVXVNNI 1
109+
#else
110+
#define XSIMD_WITH_AVXVNNI 0
111+
#endif
112+
102113
/**
103114
* @ingroup xsimd_config_macro
104115
*
@@ -422,7 +433,7 @@
422433

423434
#endif
424435

425-
#if !XSIMD_WITH_SSE2 && !XSIMD_WITH_SSE3 && !XSIMD_WITH_SSSE3 && !XSIMD_WITH_SSE4_1 && !XSIMD_WITH_SSE4_2 && !XSIMD_WITH_AVX && !XSIMD_WITH_AVX2 && !XSIMD_WITH_FMA3_SSE && !XSIMD_WITH_FMA4 && !XSIMD_WITH_FMA3_AVX && !XSIMD_WITH_FMA3_AVX2 && !XSIMD_WITH_AVX512F && !XSIMD_WITH_AVX512CD && !XSIMD_WITH_AVX512DQ && !XSIMD_WITH_AVX512BW && !XSIMD_WITH_AVX512ER && !XSIMD_WITH_AVX512PF && !XSIMD_WITH_AVX512IFMA && !XSIMD_WITH_AVX512VBMI && !XSIMD_WITH_NEON && !XSIMD_WITH_NEON64 && !XSIMD_WITH_SVE && !XSIMD_WITH_RVV && !XSIMD_WITH_WASM
436+
#if !XSIMD_WITH_SSE2 && !XSIMD_WITH_SSE3 && !XSIMD_WITH_SSSE3 && !XSIMD_WITH_SSE4_1 && !XSIMD_WITH_SSE4_2 && !XSIMD_WITH_AVX && !XSIMD_WITH_AVX2 && !XSIMD_WITH_AVXVNNI && !XSIMD_WITH_FMA3_SSE && !XSIMD_WITH_FMA4 && !XSIMD_WITH_FMA3_AVX && !XSIMD_WITH_FMA3_AVX2 && !XSIMD_WITH_AVX512F && !XSIMD_WITH_AVX512CD && !XSIMD_WITH_AVX512DQ && !XSIMD_WITH_AVX512BW && !XSIMD_WITH_AVX512ER && !XSIMD_WITH_AVX512PF && !XSIMD_WITH_AVX512IFMA && !XSIMD_WITH_AVX512VBMI && !XSIMD_WITH_NEON && !XSIMD_WITH_NEON64 && !XSIMD_WITH_SVE && !XSIMD_WITH_RVV && !XSIMD_WITH_WASM
426437
#endif
427438

428439
#endif

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace xsimd
4545
unsigned avx : 1;
4646
unsigned fma3_avx : 1;
4747
unsigned avx2 : 1;
48+
unsigned avxvnni : 1;
4849
unsigned fma3_avx2 : 1;
4950
unsigned avx512f : 1;
5051
unsigned avx512cd : 1;
@@ -104,14 +105,14 @@ namespace xsimd
104105

105106
best = ::xsimd::rvv::version() * rvv;
106107
#elif defined(__x86_64__) || defined(__i386__) || defined(_M_AMD64) || defined(_M_IX86)
107-
auto get_cpuid = [](int reg[4], int func_id) noexcept
108+
auto get_cpuid = [](int reg[4], int level, int count = 0) noexcept
108109
{
109110

110111
#if defined(_MSC_VER)
111-
__cpuidex(reg, func_id, 0);
112+
__cpuidex(reg, level, count);
112113

113114
#elif defined(__INTEL_COMPILER)
114-
__cpuid(reg, func_id);
115+
__cpuid(reg, level);
115116

116117
#elif defined(__GNUC__) || defined(__clang__)
117118

@@ -122,13 +123,13 @@ namespace xsimd
122123
"xchg{l}\t{%%}ebx, %1\n\t"
123124
: "=a"(reg[0]), "=r"(reg[1]), "=c"(reg[2]),
124125
"=d"(reg[3])
125-
: "a"(func_id), "c"(0));
126+
: "0"(level), "2"(count));
126127

127128
#else
128129
__asm__("cpuid\n\t"
129130
: "=a"(reg[0]), "=b"(reg[1]), "=c"(reg[2]),
130131
"=d"(reg[3])
131-
: "a"(func_id), "c"(0));
132+
: "0"(level), "2"(count));
132133
#endif
133134

134135
#else
@@ -181,6 +182,11 @@ namespace xsimd
181182
avx2 = regs7[1] >> 5 & 1;
182183
best = std::max(best, avx2::version() * avx2);
183184

185+
int regs7a[4];
186+
get_cpuid(regs7a, 0x7, 0x1);
187+
avxvnni = regs7a[0] >> 4 & 1;
188+
best = std::max(best, avxvnni::version() * avxvnni * avx2);
189+
184190
fma3_avx2 = avx2 && fma3_sse;
185191
best = std::max(best, fma3<xsimd::avx2>::version() * fma3_avx2);
186192

include/xsimd/types/xsimd_all_registers.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "xsimd_avx2_register.hpp"
2020
#include "xsimd_avx_register.hpp"
21+
#include "xsimd_avxvnni_register.hpp"
2122
#include "xsimd_fma3_avx2_register.hpp"
2223
#include "xsimd_fma3_avx_register.hpp"
2324

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/***************************************************************************
2+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
3+
* Martin Renou *
4+
* Copyright (c) QuantStack *
5+
* Copyright (c) Serge Guelton *
6+
* *
7+
* Distributed under the terms of the BSD 3-Clause License. *
8+
* *
9+
* The full license is in the file LICENSE, distributed with this software. *
10+
****************************************************************************/
11+
12+
#ifndef XSIMD_AVXVNNI_REGISTER_HPP
13+
#define XSIMD_AVXVNNI_REGISTER_HPP
14+
15+
#include "./xsimd_avx2_register.hpp"
16+
17+
namespace xsimd
18+
{
19+
/**
20+
* @ingroup architectures
21+
*
22+
* AVXVNNI instructions
23+
*/
24+
struct avxvnni : avx2
25+
{
26+
static constexpr bool supported() noexcept { return XSIMD_WITH_AVXVNNI; }
27+
static constexpr bool available() noexcept { return true; }
28+
static constexpr unsigned version() noexcept { return generic::version(2, 3, 0); }
29+
static constexpr char const* name() noexcept { return "avxvnni"; }
30+
};
31+
32+
#if XSIMD_WITH_AVXVNNI
33+
namespace types
34+
{
35+
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(avxvnni, avx2);
36+
}
37+
#endif
38+
}
39+
40+
#endif

0 commit comments

Comments
 (0)