Skip to content

Commit e8f370b

Browse files
lemiremellonyouwanweiqiangintel
authored
Basic AVX-512 implementation (icelake or better) (simdjson#1813)
* Add cascadelake implementation, which use AVX512 Intrinsics to optimize performance(simdjson#1811) Co-authored-by: mellonyou <fangzheng.zhang@intel.com> Co-authored-by: wanweiqiangintel <weiqiang.wan@intel.com>
1 parent 645033a commit e8f370b

34 files changed

Lines changed: 1108 additions & 101 deletions

‎.drone.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ steps:
88
CC: gcc
99
CXX: g++
1010
BUILD_FLAGS: -- -j
11-
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
11+
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
1212
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
1313
commands:
1414
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
@@ -19,6 +19,7 @@ steps:
1919
- cmake $CMAKE_FLAGS ..
2020
- cmake --build . $BUILD_FLAGS
2121
- ctest $CTEST_FLAGS -L acceptance -LE per_implementation
22+
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ctest $CTEST_FLAGS -L per_implementation
2223
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation
2324
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation
2425
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
@@ -35,14 +36,15 @@ steps:
3536
CC: clang-6.0
3637
CXX: clang++-6.0
3738
BUILD_FLAGS: -- -j
38-
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
39+
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
3940
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
4041
commands:
4142
- mkdir build
4243
- cd build
4344
- cmake $CMAKE_FLAGS ..
4445
- cmake --build . $BUILD_FLAGS
4546
- ctest $CTEST_FLAGS -L acceptance -LE per_implementation
47+
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ctest $CTEST_FLAGS -L per_implementation
4648
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation
4749
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation
4850
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
@@ -100,7 +102,7 @@ steps:
100102
CC: gcc
101103
CXX: g++
102104
BUILD_FLAGS: -- -j
103-
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
105+
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
104106
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
105107
commands:
106108
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
@@ -111,6 +113,7 @@ steps:
111113
- cmake $CMAKE_FLAGS ..
112114
- cmake --build . $BUILD_FLAGS
113115
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation
116+
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
114117
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
115118
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
116119
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
@@ -126,7 +129,7 @@ steps:
126129
environment:
127130
CC: clang-9
128131
CXX: clang++-9
129-
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
132+
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
130133
BUILD_FLAGS: -- -j
131134
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
132135
commands:
@@ -135,6 +138,7 @@ steps:
135138
- cmake $CMAKE_FLAGS ..
136139
- cmake --build . $BUILD_FLAGS
137140
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation
141+
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
138142
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
139143
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
140144
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation

‎.github/workflows/msys2-clang.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ jobs:
3838
run: |
3939
mkdir build
4040
cd build
41-
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=ON ..
41+
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=ON ..
4242
cmake --build . --verbose
4343
ctest -j4 --output-on-failure -LE explicitonly

‎.github/workflows/ubuntu22.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Ubuntu 22.04 CI (GCC 11)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ubuntu-build:
7+
if: >-
8+
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
9+
! contains(toJSON(github.event.commits.*.message), '[skip github]')
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/cache@v2
14+
with:
15+
path: dependencies/.cache
16+
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
17+
- name: Use cmake
18+
run: |
19+
mkdir builddebug &&
20+
cd builddebug &&
21+
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
22+
cmake --build . &&
23+
ctest -j --output-on-failure -LE explicitonly &&
24+
cd .. &&
25+
mkdir build &&
26+
cd build &&
27+
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
28+
cmake --build . &&
29+
ctest -j --output-on-failure -LE explicitonly &&
30+
cmake --install . &&
31+
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json &&
32+
cd ../tests/installation_tests/find &&
33+
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build .

‎.github/workflows/vs17-ci.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- {gen: Visual Studio 17 2022, arch: Win32, static: ON}
17-
- {gen: Visual Studio 17 2022, arch: Win32, static: OFF}
18-
- {gen: Visual Studio 17 2022, arch: x64, static: ON}
19-
- {gen: Visual Studio 17 2022, arch: x64, static: OFF}
16+
- {gen: Visual Studio 17 2022, arch: Win32, shared: ON}
17+
- {gen: Visual Studio 17 2022, arch: Win32, shared: OFF}
18+
- {gen: Visual Studio 17 2022, arch: x64, shared: ON}
19+
- {gen: Visual Studio 17 2022, arch: x64, shared: OFF}
2020
steps:
2121
- name: checkout
2222
uses: actions/checkout@v2
2323
- name: Configure
2424
run: |
25-
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_BUILD_STATIC=${{matrix.static}} -B build
25+
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_COMPETITION=OFF -DBUILD_SHARED_LIBS=${{matrix.shared}} -B build
2626
- name: Build Debug
2727
run: cmake --build build --config Debug --verbose
2828
- name: Build Release

‎.github/workflows/vs17-clang-ci.yml‎

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,33 @@ jobs:
99
! contains(toJSON(github.event.commits.*.message), '[skip github]')
1010
name: windows-vs17
1111
runs-on: windows-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- {gen: Visual Studio 17 2022, arch: x64}
1217
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/cache@v2
15-
with:
16-
path: dependencies/.cache
17-
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
18-
- name: 'Run CMake with VS17 Clang'
19-
uses: lukka/run-cmake@v3
20-
with:
21-
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
22-
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
23-
buildDirectory: "${{ github.workspace }}/../../_temp/windows"
24-
cmakeBuildType: Release
25-
buildWithCMake: true
26-
cmakeAppendedArgs: -T ClangCL -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF
27-
buildWithCMakeArgs: --config Release
28-
29-
- name: 'Run CTest'
30-
run: ctest -C Release -LE explicitonly --output-on-failure
31-
working-directory: "${{ github.workspace }}/../../_temp/windows"
18+
- name: checkout
19+
uses: actions/checkout@v2
20+
- name: Configure
21+
run: |
22+
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -T ClangCL -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_COMPETITION=OFF -B build
23+
- name: Build Debug
24+
run: cmake --build build --config Debug --verbose
25+
- name: Build Release
26+
run: cmake --build build --config Release --verbose
27+
- name: Run Release tests
28+
run: |
29+
cd build
30+
ctest -C Release -LE explicitonly --output-on-failure
31+
- name: Run Debug tests
32+
run: |
33+
cd build
34+
ctest -C Debug -LE explicitonly --output-on-failure
35+
- name: Install
36+
run: |
37+
cmake --install build --config Release
38+
- name: Test Installation
39+
run: |
40+
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -B build_install_test tests/installation_tests/find
41+
cmake --build build_install_test --config Release

‎.github/workflows/vs17-ninja-ci.yml‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎CONTRIBUTORS‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,8 @@ Brendan Knapp
3838
Danila Kutenin
3939
Pavel Pavlov
4040
Hao Chen
41-
# if you have contributed to the project and your name does not
41+
Nicolas Boyer
42+
Kim Walisch and Jatin Bhateja (AVX-512 bitset decoder)
43+
Eric Zhang (AVX-512 kernel)
44+
# if you have contributed to the project and your name does not
4245
# appear in this list, please let us know!

‎benchmark/dom/statisticalmodel.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ simdjson_really_inline void simdjson_process_atom(stat_t &s,
5050
} else if(element.is<double>()) {
5151
s.float_count++;
5252
} else if (element.is<bool>()) {
53-
simdjson::error_code err;
5453
bool v;
55-
err = element.get(v);
54+
simdjson::error_code error;
55+
if ((error = element.get(v))) { std::cerr << error << std::endl; abort(); }
5656
if (v) {
5757
s.true_count++;
5858
} else {

‎cmake/developer-options.cmake‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ if(CMAKE_C_COMPILER_ID MATCHES "Intel")
175175
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
176176
endif()
177177

178+
option(
179+
SIMDJSON_AVX512_ALLOWED
180+
"Enable AVX-512 instructions (only affects processors and compilers with AVX-512 support)."
181+
ON
182+
)
183+
if(SIMDJSON_AVX512_ALLOWED)
184+
add_compile_definitions(SIMDJSON_AVX512_ALLOWED=1)
185+
else()
186+
add_compile_definitions(SIMDJSON_AVX512_ALLOWED=0)
187+
message(STATUS "AVX-512 instructions are not allowed.")
188+
endif()
189+
178190
include(CheckSymbolExists)
179191
check_symbol_exists(fork unistd.h HAVE_POSIX_FORK)
180192
check_symbol_exists(wait sys/wait.h HAVE_POSIX_WAIT)

‎cmake/implementation-flags.cmake‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Implementation selection
33
#
4-
set(SIMDJSON_ALL_IMPLEMENTATIONS fallback westmere haswell arm64 ppc64)
4+
set(SIMDJSON_ALL_IMPLEMENTATIONS fallback westmere haswell icelake arm64 ppc64)
55

66
set(
77
SIMDJSON_IMPLEMENTATION ""
@@ -15,7 +15,7 @@ set(
1515
SIMDJSON_EXCLUDE_IMPLEMENTATION ""
1616
CACHE STRING "\
1717
Semicolon-separated list of implementations to exclude \
18-
(haswell/westmere/arm64/ppc64/fallback). By default, excludes any \
18+
(icelake/haswell/westmere/arm64/ppc64/fallback). By default, excludes any \
1919
implementations that are unsupported at compile time or cannot be selected at \
2020
runtime."
2121
)

0 commit comments

Comments
 (0)