Skip to content

Commit 6d6067a

Browse files
Explicitly verify dependency between architectures (like sse3 implies sse2)
Also add CI to make sure the assumption we make are correct on all architectures supported by GCC. Fix #1070
1 parent 4cd58ef commit 6d6067a

25 files changed

+207
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Arch consistency check
2+
on: [push, pull_request]
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout xsimd
11+
uses: actions/checkout@v3
12+
- name: Install dependencies
13+
run: sudo apt install g++
14+
- name: Check architecture consistency
15+
run: cd test && sh ./check_arch.sh

include/xsimd/types/xsimd_avx2_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ namespace xsimd
2929
};
3030

3131
#if XSIMD_WITH_AVX2
32+
33+
#if !XSIMD_WITH_AVX
34+
#error "architecture inconsistency: avx2 requires avx"
35+
#endif
36+
3237
namespace types
3338
{
3439
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(avx2, avx);

include/xsimd/types/xsimd_avx512bw_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512BW
3333

34+
#if !XSIMD_WITH_AVX512DQ
35+
#error "architecture inconsistency: avx512bw requires avx512dq"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512cd_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512CD
3333

34+
#if !XSIMD_WITH_AVX512F
35+
#error "architecture inconsistency: avx512bw requires avx512f"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512dq_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512DQ
3333

34+
#if !XSIMD_WITH_AVX512CD
35+
#error "architecture inconsistency: avx512dq requires avx512cd"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512er_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512ER
3333

34+
#if !XSIMD_WITH_AVX512CD
35+
#error "architecture inconsistency: avx512er requires avx512cd"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512f_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ namespace xsimd
3333

3434
#if XSIMD_WITH_AVX512F
3535

36+
#if !XSIMD_WITH_AVX2
37+
#error "architecture inconsistency: avx512f requires avx2"
38+
#endif
39+
3640
namespace types
3741
{
3842
template <class T>

include/xsimd/types/xsimd_avx512ifma_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512IFMA
3333

34+
#if !XSIMD_WITH_AVX512BW
35+
#error "architecture inconsistency: avx512ifma requires avx512bw"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512pf_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512PF
3333

34+
#if !XSIMD_WITH_AVX512ER
35+
#error "architecture inconsistency: avx512pf requires avx512er"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512vbmi_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ namespace xsimd
3131

3232
#if XSIMD_WITH_AVX512VBMI
3333

34+
#if !XSIMD_WITH_AVX512IFMA
35+
#error "architecture inconsistency: avx512vbmi requires avx512ifma"
36+
#endif
37+
3438
namespace types
3539
{
3640
template <class T>

include/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ namespace xsimd
3434

3535
#if XSIMD_WITH_AVX512VNNI_AVX512BW
3636

37+
#if !XSIMD_WITH_AVX512BW
38+
#error "architecture inconsistency: avx512vnni+avx512bw requires avx512bw"
39+
#endif
40+
3741
namespace types
3842
{
3943
template <class T>

include/xsimd/types/xsimd_avx512vnni_avx512vbmi_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ namespace xsimd
3434

3535
#if XSIMD_WITH_AVX512VNNI_AVX512VBMI
3636

37+
#if !XSIMD_WITH_AVX512VBMI
38+
#error "architecture inconsistency: avx512vnni+avx512vbmi requires avx512vbmi"
39+
#endif
40+
3741
namespace types
3842
{
3943
template <class T>

include/xsimd/types/xsimd_avx_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ namespace xsimd
3434

3535
#if XSIMD_WITH_AVX
3636

37+
#if !XSIMD_WITH_SSE4_2
38+
#error "architecture inconsistency: avx requires sse4.2"
39+
#endif
40+
3741
#include <immintrin.h>
3842

3943
namespace xsimd

include/xsimd/types/xsimd_avxvnni_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ namespace xsimd
2929
};
3030

3131
#if XSIMD_WITH_AVXVNNI
32+
33+
#if !XSIMD_WITH_AVX2
34+
#error "architecture inconsistency: avxvnni requires avx2"
35+
#endif
36+
3237
namespace types
3338
{
3439
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(avxvnni, avx2);

include/xsimd/types/xsimd_fma3_avx2_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_FMA3_AVX2
36+
37+
#if !XSIMD_WITH_AVX2
38+
#error "architecture inconsistency: fma3+avx2 requires avx2"
39+
#endif
40+
3641
namespace types
3742
{
3843

include/xsimd/types/xsimd_fma3_avx_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_FMA3_AVX
36+
37+
#if !XSIMD_WITH_AVX
38+
#error "architecture inconsistency: fma3+avx requires avx"
39+
#endif
40+
3641
namespace types
3742
{
3843

include/xsimd/types/xsimd_fma3_sse_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_FMA3_SSE
36+
37+
#if !XSIMD_WITH_SSE4_2
38+
#error "architecture inconsistency: fma3+sse4.2 requires sse4.2"
39+
#endif
40+
3641
namespace types
3742
{
3843

include/xsimd/types/xsimd_fma4_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_FMA4
36+
37+
#if !XSIMD_WITH_SSE4_2
38+
#error "architecture inconsistency: fma4 requires sse4.2"
39+
#endif
40+
3641
namespace types
3742
{
3843

include/xsimd/types/xsimd_i8mm_neon64_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_I8MM_NEON64
36+
37+
#if !XSIMD_WITH_NEON64
38+
#error "architecture inconsistency: i8mm+neon64 requires neon64"
39+
#endif
40+
3641
namespace types
3742
{
3843

include/xsimd/types/xsimd_neon64_register.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ namespace xsimd
3232

3333
#if XSIMD_WITH_NEON64
3434

35+
#if !XSIMD_WITH_NEON
36+
#error "architecture inconsistency: neon64 requires neon"
37+
#endif
38+
3539
namespace types
3640
{
3741
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(neon64, neon);

include/xsimd/types/xsimd_sse3_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_SSE3
36+
37+
#if !XSIMD_WITH_SSE2
38+
#error "architecture inconsistency: sse3 requires sse2"
39+
#endif
40+
3641
namespace types
3742
{
3843

include/xsimd/types/xsimd_sse4_1_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_SSE4_1
36+
37+
#if !XSIMD_WITH_SSSE3
38+
#error "architecture inconsistency: sse4.1 requires ssse3"
39+
#endif
40+
3641
namespace types
3742
{
3843
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(sse4_1, ssse3);

include/xsimd/types/xsimd_sse4_2_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_SSE4_2
36+
37+
#if !XSIMD_WITH_SSE4_1
38+
#error "architecture inconsistency: sse4.2 requires sse4.1"
39+
#endif
40+
3641
namespace types
3742
{
3843
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(sse4_2, sse4_1);

include/xsimd/types/xsimd_ssse3_register.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace xsimd
3333
};
3434

3535
#if XSIMD_WITH_SSSE3
36+
37+
#if !XSIMD_WITH_SSE3
38+
#error "architecture inconsistency: ssse3 requires sse3"
39+
#endif
40+
3641
namespace types
3742
{
3843
XSIMD_DECLARE_SIMD_REGISTER_ALIAS(ssse3, sse3);

test/check_arch.sh

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/sh
2+
set -e
3+
CXX=g++
4+
printf "int main() { return 0;}" > sanity_check.cpp
5+
printf "#include <xsimd/xsimd.hpp>\nint main() { return 0;}" > xsimd_check.cpp
6+
7+
sed -n '/x86[-]64/,$ p' $0 | \
8+
while read arch; do \
9+
if echo $arch | grep -q '#' ; then continue; fi ; \
10+
echo "# $arch" ; \
11+
$CXX -w -march=$arch sanity_check.cpp -fsyntax-only ; \
12+
$CXX -w -I../include -march=$arch xsimd_check.cpp -fsyntax-only ; \
13+
done
14+
15+
rm sanity_check.cpp xsimd_check.cpp
16+
17+
exit 0
18+
nocona
19+
core2
20+
nehalem
21+
corei7
22+
westmere
23+
sandybridge
24+
corei7-avx
25+
ivybridge
26+
core-avx-i
27+
haswell
28+
core-avx2
29+
broadwell
30+
skylake
31+
skylake-avx512
32+
cannonlake
33+
icelake-client
34+
rocketlake
35+
icelake-server
36+
cascadelake
37+
tigerlake
38+
cooperlake
39+
sapphirerapids
40+
emeraldrapids
41+
alderlake
42+
raptorlake
43+
meteorlake
44+
graniterapids
45+
graniterapids-d
46+
bonnell
47+
atom
48+
silvermont
49+
slm
50+
goldmont
51+
goldmont-plus
52+
tremont
53+
gracemont
54+
sierraforest
55+
grandridge
56+
knl
57+
knm
58+
x86-64
59+
x86-64-v2
60+
x86-64-v3
61+
x86-64-v4
62+
eden-x2
63+
nano
64+
nano-1000
65+
nano-2000
66+
nano-3000
67+
nano-x2
68+
eden-x4
69+
nano-x4
70+
lujiazui
71+
k8
72+
k8-sse3
73+
opteron
74+
opteron-sse3
75+
athlon64
76+
athlon64-sse3
77+
athlon-fx
78+
amdfam10
79+
barcelona
80+
bdver1
81+
bdver2
82+
bdver3
83+
bdver4
84+
znver1
85+
znver2
86+
znver3
87+
znver4
88+
btver1
89+
btver2

0 commit comments

Comments
 (0)