Skip to content

Commit ed63086

Browse files
Provide modeling and runtime detection of i8mm arm extension
Some extra thoughts could be done on the way we model instruction set extensions, I'm not happy with the way it's currently done.
1 parent ead0742 commit ed63086

File tree

7 files changed

+90
-1
lines changed

7 files changed

+90
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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_I8MM_NEON64_HPP
13+
#define XSIMD_I8MM_NEON64_HPP
14+
15+
#include "../types/xsimd_i8mm_neon64_register.hpp"
16+
17+
#endif

include/xsimd/arch/xsimd_isa.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
#include "./xsimd_neon64.hpp"
105105
#endif
106106

107+
#if XSIMD_WITH_I8MM_NEON64
108+
#include "./xsimd_i8mm_neon64.hpp"
109+
#endif
110+
107111
#if XSIMD_WITH_SVE
108112
#include "./xsimd_sve.hpp"
109113
#endif

include/xsimd/config/xsimd_arch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ namespace xsimd
194194

195195
using all_sve_architectures = arch_list<detail::sve<512>, detail::sve<256>, detail::sve<128>>;
196196
using all_rvv_architectures = arch_list<detail::rvv<512>, detail::rvv<256>, detail::rvv<128>>;
197-
using all_arm_architectures = typename detail::join<all_sve_architectures, arch_list<neon64, neon>>::type;
197+
using all_arm_architectures = typename detail::join<all_sve_architectures, arch_list<i8mm<neon64>, neon64, neon>>::type;
198198
using all_riscv_architectures = all_rvv_architectures;
199199
using all_wasm_architectures = arch_list<wasm>;
200200
using all_architectures = typename detail::join<all_riscv_architectures, all_wasm_architectures, all_arm_architectures, all_x86_architectures>::type;

include/xsimd/config/xsimd_config.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,17 @@
349349
#define XSIMD_WITH_NEON64 0
350350
#endif
351351

352+
/**
353+
* @ingroup xsimd_config_macro
354+
*
355+
* Set to 1 if i8mm neon64 extension is available at compile-time, to 0 otherwise.
356+
*/
357+
#if defined(__ARM_FEATURE_MATMUL_INT8)
358+
#define XSIMD_WITH_I8MM_NEON64 1
359+
#else
360+
#define XSIMD_WITH_I8MM_NEON64 0
361+
#endif
362+
352363
/**
353364
* @ingroup xsimd_config_macro
354365
*

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
#if defined(__linux__) && (defined(__ARM_NEON) || defined(_M_ARM) || defined(__riscv_vector))
1919
#include <asm/hwcap.h>
2020
#include <sys/auxv.h>
21+
22+
#ifndef HWCAP2_I8MM
23+
#define HWCAP2_I8MM (1 << 13)
24+
#endif
25+
2126
#endif
2227

2328
#if defined(_MSC_VER)
@@ -66,6 +71,7 @@ namespace xsimd
6671
ARCH_FIELD_EX(avx512vnni<::xsimd::avx512vbmi>, avx512vnni_vbmi)
6772
ARCH_FIELD(neon)
6873
ARCH_FIELD(neon64)
74+
ARCH_FIELD_EX(i8mm<::xsimd::neon64>, i8mm_neon64)
6975
ARCH_FIELD(sve)
7076
ARCH_FIELD(rvv)
7177
ARCH_FIELD(wasm)
@@ -83,6 +89,9 @@ namespace xsimd
8389
#if defined(__aarch64__) || defined(_M_ARM64)
8490
neon = 1;
8591
neon64 = 1;
92+
#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)
93+
i8mm_neon64 = bool(getauxval(AT_HWCAP2) & HWCAP2_I8MM);
94+
#endif
8695
#elif defined(__ARM_NEON) || defined(_M_ARM)
8796

8897
#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)

include/xsimd/types/xsimd_all_registers.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include "xsimd_avx512dq_register.hpp"
3737
#include "xsimd_avx512f_register.hpp"
3838

39+
#include "xsimd_i8mm_neon64_register.hpp"
40+
3941
#include "xsimd_neon64_register.hpp"
4042
#include "xsimd_neon_register.hpp"
4143

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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_I8MM_NEON64_REGISTER_HPP
13+
#define XSIMD_I8MM_NEON64_REGISTER_HPP
14+
15+
#include "./xsimd_neon64_register.hpp"
16+
17+
namespace xsimd
18+
{
19+
template <typename arch>
20+
struct i8mm;
21+
22+
/**
23+
* @ingroup architectures
24+
*
25+
* Neon64 + i8mm instructions
26+
*/
27+
template <>
28+
struct i8mm<neon64> : neon64
29+
{
30+
static constexpr bool supported() noexcept { return XSIMD_WITH_I8MM_NEON64; }
31+
static constexpr bool available() noexcept { return true; }
32+
static constexpr unsigned version() noexcept { return generic::version(8, 2, 0); }
33+
static constexpr char const* name() noexcept { return "i8mm+neon64"; }
34+
};
35+
36+
#if XSIMD_WITH_I8MM_NEON64
37+
namespace types
38+
{
39+
40+
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(i8mm<neon64>, neon64);
41+
42+
}
43+
#endif
44+
45+
}
46+
#endif

0 commit comments

Comments
 (0)