Skip to content

Commit 9e79d6a

Browse files
Properly handle xsimd_avx512vnni hierarchy
avx512vnni can be available both with bw and vbmi, which leads to different arch hierarchy. Handle this as we did for fma3.
1 parent 89b9be3 commit 9e79d6a

9 files changed

+119
-21
lines changed

include/xsimd/arch/xsimd_avx512vnni.hpp renamed to include/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* The full license is in the file LICENSE, distributed with this software. *
1010
****************************************************************************/
1111

12-
#ifndef XSIMD_AVX512VNNI_HPP
13-
#define XSIMD_AVX512VNNI_HPP
12+
#ifndef XSIMD_AVX512VNNI_AVX512_BW_HPP
13+
#define XSIMD_AVX512VNNI_AVX512_BW_HPP
1414

1515
#include <array>
1616
#include <type_traits>
1717

18-
#include "../types/xsimd_avx512vnni_register.hpp"
18+
#include "../types/xsimd_avx512vnni_avx512bw_register.hpp"
1919

2020
#endif
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_AVX512VNNI_AVX512VBMI_HPP
13+
#define XSIMD_AVX512VNNI_AVX512VBMI_HPP
14+
15+
#include <array>
16+
#include <type_traits>
17+
18+
#include "../types/xsimd_avx512vnni_avx512vbmi_register.hpp"
19+
20+
#endif

include/xsimd/arch/xsimd_isa.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@
8888
#include "./xsimd_avx512vbmi.hpp"
8989
#endif
9090

91-
#if XSIMD_WITH_AVX512VNNI
92-
#include "./xsimd_avx512vnni.hpp"
91+
#if XSIMD_WITH_AVX512VNNI_AVX512BW
92+
#include "./xsimd_avx512vnni_avx512bw.hpp"
93+
#endif
94+
95+
#if XSIMD_WITH_AVX512VNNI_AVX512VBMI
96+
#include "./xsimd_avx512vnni_avx512vbmi.hpp"
9397
#endif
9498

9599
#if XSIMD_WITH_NEON

include/xsimd/config/xsimd_arch.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ namespace xsimd
190190
struct unsupported
191191
{
192192
};
193-
using all_x86_architectures = arch_list<avx512vnni, avx512vbmi, avx512ifma, avx512pf, avx512bw, avx512er, avx512dq, avx512cd, avx512f, avxvnni, fma3<avx2>, avx2, fma3<avx>, avx, fma4, fma3<sse4_2>, sse4_2, sse4_1, /*sse4a,*/ ssse3, sse3, sse2>;
193+
using all_x86_architectures = arch_list<
194+
avx512vnni<avx512vbmi>, avx512vbmi, avx512ifma, avx512pf, avx512vnni<avx512bw>, avx512bw, avx512er, avx512dq, avx512cd, avx512f,
195+
avxvnni, fma3<avx2>, avx2, fma3<avx>, avx, fma4, fma3<sse4_2>,
196+
sse4_2, sse4_1, /*sse4a,*/ ssse3, sse3, sse2>;
197+
194198
using all_sve_architectures = arch_list<detail::sve<512>, detail::sve<256>, detail::sve<128>>;
195199
using all_rvv_architectures = arch_list<detail::rvv<512>, detail::rvv<256>, detail::rvv<128>>;
196200
using all_arm_architectures = typename detail::join<all_sve_architectures, arch_list<neon64, neon>>::type;

include/xsimd/config/xsimd_config.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,20 @@
305305
* Set to 1 if AVX512VNNI is available at compile-time, to 0 otherwise.
306306
*/
307307
#ifdef __AVX512VNNI__
308-
#define XSIMD_WITH_AVX512VNNI XSIMD_WITH_AVX512F
308+
309+
#if XSIMD_WITH_AVX512_VBMI
310+
#define XSIMD_WITH_AVX512VNNI_AVX512VBMI XSIMD_WITH_AVX512F
311+
#define XSIMD_WITH_AVX512VNNI_AVX512BW XSIMD_WITH_AVX512F
312+
#else
313+
#define XSIMD_WITH_AVX512VNNI_AVX512VBMI 0
314+
#define XSIMD_WITH_AVX512VNNI_AVX512BW XSIMD_WITH_AVX512F
315+
#endif
316+
309317
#else
310-
#define XSIMD_WITH_AVX512VNNI 0
318+
319+
#define XSIMD_WITH_AVX512VNNI_AVX512VBMI 0
320+
#define XSIMD_WITH_AVX512VNNI_AVX512BW 0
321+
311322
#endif
312323

313324
#ifdef __ARM_NEON

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ namespace xsimd
5555
unsigned avx512pf : 1;
5656
unsigned avx512ifma : 1;
5757
unsigned avx512vbmi : 1;
58-
unsigned avx512vnni : 1;
58+
unsigned avx512vnni_bw : 1;
59+
unsigned avx512vnni_vbmi : 1;
5960
unsigned neon : 1;
6061
unsigned neon64 : 1;
6162
unsigned sve : 1;
@@ -214,8 +215,11 @@ namespace xsimd
214215
avx512vbmi = regs7[2] >> 1 & 1;
215216
best = std::max(best, avx512vbmi::version() * avx512vbmi * avx512ifma * avx512bw * avx512dq * avx512cd * avx512f);
216217

217-
avx512vnni = regs7[2] >> 11 & 1;
218-
best = std::max(best, avx512vnni::version() * avx512vnni * avx512vbmi * avx512ifma * avx512bw * avx512dq * avx512cd * avx512f);
218+
avx512vnni_bw = regs7[2] >> 11 & 1;
219+
best = std::max(best, avx512vnni<xsimd::avx512bw>::version() * avx512vnni_bw * avx512bw * avx512dq * avx512cd * avx512f);
220+
221+
avx512vnni_vbmi = avx512vbmi && avx512vnni_bw;
222+
best = std::max(best, avx512vnni<xsimd::avx512vbmi>::version() * avx512vnni_vbmi);
219223
#endif
220224
}
221225
};

include/xsimd/types/xsimd_all_registers.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#include "xsimd_fma3_avx2_register.hpp"
2323
#include "xsimd_fma3_avx_register.hpp"
2424

25-
#include "xsimd_avx512vnni_register.hpp"
25+
#include "xsimd_avx512vnni_avx512vbmi_register.hpp"
26+
#include "xsimd_avx512vnni_avx512bw_register.hpp"
2627

2728
#include "xsimd_avx512ifma_register.hpp"
2829
#include "xsimd_avx512vbmi_register.hpp"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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_AVX512VNNI_AVX512BW_REGISTER_HPP
13+
#define XSIMD_AVX512VNNI_AVX512BW_REGISTER_HPP
14+
15+
#include "./xsimd_avx512bw_register.hpp"
16+
17+
namespace xsimd
18+
{
19+
template<typename arch>
20+
struct avx512vnni;
21+
22+
/**
23+
* @ingroup architectures
24+
*
25+
* AVX512VNNI instructions
26+
*/
27+
template<>
28+
struct avx512vnni<avx512bw> : avx512bw
29+
{
30+
static constexpr bool supported() noexcept { return XSIMD_WITH_AVX512VNNI_AVX512BW; }
31+
static constexpr bool available() noexcept { return true; }
32+
static constexpr unsigned version() noexcept { return generic::version(3, 4, 1); }
33+
static constexpr char const* name() noexcept { return "avx512vnni+avx512bw"; }
34+
};
35+
36+
#if XSIMD_WITH_AVX512VNNI_AVX512BW
37+
38+
namespace types
39+
{
40+
template <class T>
41+
struct get_bool_simd_register<T, avx512vnni<avx512bw>>
42+
{
43+
using type = simd_avx512_bool_register<T>;
44+
};
45+
46+
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(avx512vnni<avx512bw>, avx512bw);
47+
48+
}
49+
#endif
50+
}
51+
#endif

include/xsimd/types/xsimd_avx512vnni_register.hpp renamed to include/xsimd/types/xsimd_avx512vnni_avx512vbmi_register.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,41 @@
99
* The full license is in the file LICENSE, distributed with this software. *
1010
****************************************************************************/
1111

12-
#ifndef XSIMD_AVX512VNNI_REGISTER_HPP
13-
#define XSIMD_AVX512VNNI_REGISTER_HPP
12+
#ifndef XSIMD_AVX512VNNI_AVX512VBMI_REGISTER_HPP
13+
#define XSIMD_AVX512VNNI_AVX512VBMI_REGISTER_HPP
1414

1515
#include "./xsimd_avx512vbmi_register.hpp"
1616

1717
namespace xsimd
1818
{
19+
template<typename arch>
20+
struct avx512vnni;
1921

2022
/**
2123
* @ingroup architectures
2224
*
2325
* AVX512VNNI instructions
2426
*/
25-
struct avx512vnni : avx512vbmi
27+
template<>
28+
struct avx512vnni<avx512vbmi> : avx512vbmi
2629
{
27-
static constexpr bool supported() noexcept { return XSIMD_WITH_AVX512VNNI; }
30+
static constexpr bool supported() noexcept { return XSIMD_WITH_AVX512VNNI_AVX512VBMI; }
2831
static constexpr bool available() noexcept { return true; }
29-
static constexpr unsigned version() noexcept { return generic::version(3, 7, 0); }
30-
static constexpr char const* name() noexcept { return "avx512vnni"; }
32+
static constexpr unsigned version() noexcept { return generic::version(3, 6, 1); }
33+
static constexpr char const* name() noexcept { return "avx512vnni+avx512vbmi"; }
3134
};
3235

33-
#if XSIMD_WITH_AVX512VNNI
36+
#if XSIMD_WITH_AVX512VNNI_AVX512VBMI
3437

3538
namespace types
3639
{
3740
template <class T>
38-
struct get_bool_simd_register<T, avx512vnni>
41+
struct get_bool_simd_register<T, avx512vnni<avx512vbmi>>
3942
{
4043
using type = simd_avx512_bool_register<T>;
4144
};
4245

43-
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(avx512vnni, avx512vbmi);
46+
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(avx512vnni<avx512vbmi>, avx512vbmi);
4447

4548
}
4649
#endif

0 commit comments

Comments
 (0)