-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps,src: use SIMD for normal base64 encoding
PR-URL: #39775 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
1 parent
9b53a69
commit 2ec8092
Showing
78 changed files
with
7,161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# base64 | ||
|
||
This project boosts base64 encoding/decoding performance by utilizing SIMD | ||
operations where possible. | ||
|
||
The source is pulled from: https://github.com/aklomp/base64 | ||
|
||
Active development occurs in the default branch (currently named `master`). | ||
|
||
## Updating | ||
|
||
```sh | ||
$ git clone https://github.com/aklomp/base64 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
{ | ||
'variables': { | ||
'arm_fpu%': '', | ||
'target_arch%': '', | ||
}, | ||
'targets': [ | ||
{ | ||
'target_name': 'base64', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'direct_dependent_settings': { | ||
'include_dirs': [ 'base64/include' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE' ], | ||
}, | ||
'defines': [ 'BASE64_STATIC_DEFINE' ], | ||
'sources': [ | ||
'base64/include/libbase64.h', | ||
'base64/lib/arch/generic/codec.c', | ||
'base64/lib/tables/tables.c', | ||
'base64/lib/codec_choose.c', | ||
'base64/lib/codecs.h', | ||
'base64/lib/lib.c', | ||
], | ||
|
||
'conditions': [ | ||
[ 'arm_fpu=="neon" and target_arch=="arm"', { | ||
'defines': [ 'HAVE_NEON32=1' ], | ||
'dependencies': [ 'base64_neon32' ], | ||
}, { | ||
'sources': [ 'base64/lib/arch/neon32/codec.c' ], | ||
}], | ||
|
||
# arm64 requires NEON, so it's safe to always use it | ||
[ 'target_arch=="arm64"', { | ||
'defines': [ 'HAVE_NEON64=1' ], | ||
'dependencies': [ 'base64_neon64' ], | ||
}, { | ||
'sources': [ 'base64/lib/arch/neon64/codec.c' ], | ||
}], | ||
|
||
# Runtime detection will happen for x86 CPUs | ||
[ 'target_arch in "ia32 x64 x32"', { | ||
'defines': [ | ||
'HAVE_SSSE3=1', | ||
'HAVE_SSE41=1', | ||
'HAVE_SSE42=1', | ||
'HAVE_AVX=1', | ||
'HAVE_AVX2=1', | ||
], | ||
'dependencies': [ | ||
'base64_ssse3', | ||
'base64_sse41', | ||
'base64_sse42', | ||
'base64_avx', | ||
'base64_avx2', | ||
], | ||
}, { | ||
'sources': [ | ||
'base64/lib/arch/ssse3/codec.c', | ||
'base64/lib/arch/sse41/codec.c', | ||
'base64/lib/arch/sse42/codec.c', | ||
'base64/lib/arch/avx/codec.c', | ||
'base64/lib/arch/avx2/codec.c', | ||
], | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_ssse3', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/ssse3/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_SSSE3=1' ], | ||
'conditions': [ | ||
[ 'OS!="win"', { | ||
'cflags': [ '-mssse3' ], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': [ '-mssse3' ] | ||
}, | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_sse41', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/sse41/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_SSE41=1' ], | ||
'conditions': [ | ||
[ 'OS!="win"', { | ||
'cflags': [ '-msse4.1' ], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': [ '-msse4.1' ] | ||
}, | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_sse42', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/sse42/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_SSE42=1' ], | ||
'conditions': [ | ||
[ 'OS!="win"', { | ||
'cflags': [ '-msse4.2' ], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': [ '-msse4.2' ] | ||
}, | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_avx', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/avx/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_AVX=1' ], | ||
'conditions': [ | ||
[ 'OS!="win"', { | ||
'cflags': [ '-mavx' ], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': [ '-mavx' ] | ||
}, | ||
}, { | ||
'msvs_settings': { | ||
'VCCLCompilerTool': { | ||
'AdditionalOptions': [ | ||
'/arch:AVX' | ||
], | ||
}, | ||
}, | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_avx2', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/avx2/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_AVX2=1' ], | ||
'conditions': [ | ||
[ 'OS!="win"', { | ||
'cflags': [ '-mavx2' ], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': [ '-mavx2' ] | ||
}, | ||
}, { | ||
'msvs_settings': { | ||
'VCCLCompilerTool': { | ||
'AdditionalOptions': [ | ||
'/arch:AVX2' | ||
], | ||
}, | ||
}, | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_neon32', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/neon32/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_NEON32=1' ], | ||
'conditions': [ | ||
[ 'OS!="win"', { | ||
'cflags': [ '-mfpu=neon' ], | ||
'xcode_settings': { | ||
'OTHER_CFLAGS': [ '-mfpu=neon' ] | ||
}, | ||
}], | ||
], | ||
}, | ||
|
||
{ | ||
'target_name': 'base64_neon64', | ||
'type': 'static_library', | ||
'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
'sources': [ 'base64/lib/arch/neon64/codec.c' ], | ||
'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_NEON64=1' ], | ||
# NEON is required in arm64, so no -mfpu flag is needed | ||
} | ||
|
||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# https://EditorConfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
indent_style = tab | ||
tab_width = 8 | ||
indent_size = 8 | ||
|
||
[CMakeLists.txt] | ||
tab_width = 4 | ||
indent_style = space | ||
[*.cmake] | ||
tab_width = 4 | ||
indent_style = space | ||
|
||
[*.py] | ||
tab_width = 4 | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
makefile-test: | ||
name: makefile-${{ matrix.runner }}-amd64-${{ matrix.compiler }} ${{ ((matrix.openmp == 1) && '+openmp') || '' }} | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runner: ["ubuntu-18.04"] | ||
compiler: ["gcc", "clang"] | ||
openmp: ["0", "1"] | ||
include: | ||
- runner: "macos-11" | ||
compiler: "clang" | ||
openmp: "0" | ||
env: | ||
OPENMP: ${{ matrix.openmp }} | ||
OMP_NUM_THREADS: ${{ ((matrix.openmp == 1) && '2') || '0' }} | ||
CC: ${{ matrix.compiler }} | ||
OBJCOPY: ${{ (startsWith(matrix.runner, 'macos') && 'echo') || 'objcopy' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Run tests | ||
run: ./test/ci/test.sh | ||
|
||
cmake-test: | ||
name: cmake-${{ matrix.runner }} | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runner: ["ubuntu-18.04", "macos-11", "windows-2019"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: CMake Configure | ||
run: > | ||
cmake | ||
-B out | ||
-Werror=dev | ||
-DBASE64_BUILD_TESTS=ON | ||
${{ runner.os != 'Windows' && '-DCMAKE_BUILD_TYPE=Release' || '' }} | ||
${{ runner.os == 'macOS' && '-DBASE64_WITH_AVX2=OFF' || '' }} | ||
- name: CMake Build | ||
run: cmake --build out --config Release --verbose | ||
- name: CTest | ||
run: ctest --no-tests=error --test-dir out -VV --build-config Release | ||
|
||
alpine-makefile-test: | ||
name: makefile-alpine-amd64-gcc | ||
runs-on: ubuntu-latest | ||
container: | ||
image: alpine:3.12 | ||
env: | ||
CC: gcc | ||
steps: | ||
- name: Install deps | ||
run: apk add --update bash build-base git | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Run tests | ||
run: ./test/ci/test.sh | ||
|
||
alpine-cmake-test: | ||
name: cmake-alpine-amd64-gcc | ||
runs-on: ubuntu-latest | ||
container: | ||
image: alpine:3.12 | ||
steps: | ||
- name: Install deps | ||
run: apk add --update bash build-base cmake git | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: CMake Configure | ||
run: cmake -B out -Werror=dev -DBASE64_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release | ||
- name: CMake Build | ||
run: cmake --build out --config Release --verbose | ||
- name: CTest | ||
run: ctest --no-tests=error -VV --build-config Release | ||
working-directory: ./out | ||
|
||
alpine-alt-arch-makefile-test: | ||
name: makefile-alpine-${{matrix.arch}}-${{matrix.cc}} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
arch: [armv7, aarch64, s390x, ppc64le] | ||
cc: [gcc, clang] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: uraimo/run-on-arch-action@v2 | ||
with: | ||
arch: ${{matrix.arch}} | ||
distro: alpine_latest | ||
env: | | ||
CC: ${{matrix.cc}} | ||
install: apk add --update bash build-base cmake git ${{matrix.cc}} | ||
run: ./test/ci/test.sh | ||
|
||
alpine-alt-arch-cmake-test: | ||
name: cmake-alpine-${{matrix.arch}}-${{matrix.cc}} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
arch: [armv7, aarch64, s390x, ppc64le] | ||
cc: [gcc, clang] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: uraimo/run-on-arch-action@v2 | ||
with: | ||
arch: ${{matrix.arch}} | ||
distro: alpine_latest | ||
env: | | ||
CC: ${{matrix.cc}} | ||
install: apk add --update bash build-base cmake git ${{matrix.cc}} | ||
run: | | ||
echo "::group::CMake Configure" | ||
cmake -B out -Werror=dev -DBASE64_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release | ||
echo "::endgroup::CMake Configure" | ||
echo "::group::CMake Build" | ||
cmake --build out --config Release --verbose | ||
echo "::endgroup::CMake Build" | ||
echo "::group::CTest" | ||
ctest --no-tests=error --test-dir out -VV --build-config Release | ||
echo "::endgroup::CTest" |
Oops, something went wrong.