| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 01bed64 commit 5073a3e
32 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,13 +49,15 @@ | |||
| 49 | 49 | 'HAVE_SSE42=1', | |
| 50 | 50 | 'HAVE_AVX=1', | |
| 51 | 51 | 'HAVE_AVX2=1', | |
| 52 | + 'HAVE_AVX512=1', | ||
| 52 | 53 | ], | |
| 53 | 54 | 'dependencies': [ | |
| 54 | 55 | 'base64_ssse3', | |
| 55 | 56 | 'base64_sse41', | |
| 56 | 57 | 'base64_sse42', | |
| 57 | 58 | 'base64_avx', | |
| 58 | 59 | 'base64_avx2', | |
| 60 | + 'base64_avx512', | ||
| 59 | 61 | ], | |
| 60 | 62 | }, { | |
| 61 | 63 | 'sources': [ | |
@@ -64,6 +66,7 @@ | |||
| 64 | 66 | 'base64/lib/arch/sse42/codec.c', | |
| 65 | 67 | 'base64/lib/arch/avx/codec.c', | |
| 66 | 68 | 'base64/lib/arch/avx2/codec.c', | |
| 69 | + 'base64/lib/arch/avx512/codec.c', | ||
| 67 | 70 | ], | |
| 68 | 71 | }], | |
| 69 | 72 | ], | |
@@ -165,6 +168,30 @@ | |||
| 165 | 168 | ], | |
| 166 | 169 | }, | |
| 167 | 170 | ||
| 171 | + { | ||
| 172 | + 'target_name': 'base64_avx512', | ||
| 173 | + 'type': 'static_library', | ||
| 174 | + 'include_dirs': [ 'base64/include', 'base64/lib' ], | ||
| 175 | + 'sources': [ 'base64/lib/arch/avx512/codec.c' ], | ||
| 176 | + 'defines': [ 'BASE64_STATIC_DEFINE', 'HAVE_AVX512=1' ], | ||
| 177 | + 'conditions': [ | ||
| 178 | + [ 'OS!="win"', { | ||
| 179 | + 'cflags': [ '-mavx512vl', '-mavx512vbmi' ], | ||
| 180 | + 'xcode_settings': { | ||
| 181 | + 'OTHER_CFLAGS': [ '-mavx512vl', '-mavx512vbmi' ] | ||
| 182 | + }, | ||
| 183 | + }, { | ||
| 184 | + 'msvs_settings': { | ||
| 185 | + 'VCCLCompilerTool': { | ||
| 186 | + 'AdditionalOptions': [ | ||
| 187 | + '/arch:AVX512' | ||
| 188 | + ], | ||
| 189 | + }, | ||
| 190 | + }, | ||
| 191 | + }], | ||
| 192 | + ], | ||
| 193 | + }, | ||
| 194 | + | ||
| 168 | 195 | { | |
| 169 | 196 | 'target_name': 'base64_neon32', | |
| 170 | 197 | 'type': 'static_library', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1 @@ | |||
| 1 | - *.o | ||
| 2 | - bin/base64 | ||
| 3 | - lib/config.h | ||
| 4 | - test/benchmark | ||
| 5 | - test/test_base64 | ||
| 6 | - | ||
| 7 | - # visual studio symbol db, etc. | ||
| 8 | - .vs/ | ||
| 9 | - # build directory used by CMakePresets | ||
| 10 | - out/ | ||
| 11 | - # private cmake presets | ||
| 12 | - CMakeUserPresets.json | ||
| 1 | + # Intentionally empty | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ if (POLICY CMP0127) | |||
| 17 | 17 | cmake_policy(SET CMP0127 NEW) | |
| 18 | 18 | endif() | |
| 19 | 19 | ||
| 20 | - project(base64 LANGUAGES C VERSION 0.5.0) | ||
| 20 | + project(base64 LANGUAGES C VERSION 0.5.1) | ||
| 21 | 21 | ||
| 22 | 22 | include(GNUInstallDirs) | |
| 23 | 23 | include(CMakeDependentOption) | |
@@ -62,6 +62,8 @@ cmake_dependent_option(BASE64_WITH_AVX "add AVX codepath" ON ${_IS_X86} OFF) | |||
| 62 | 62 | add_feature_info(AVX BASE64_WITH_AVX "add AVX codepath") | |
| 63 | 63 | cmake_dependent_option(BASE64_WITH_AVX2 "add AVX 2 codepath" ON ${_IS_X86} OFF) | |
| 64 | 64 | add_feature_info(AVX2 BASE64_WITH_AVX2 "add AVX2 codepath") | |
| 65 | + cmake_dependent_option(BASE64_WITH_AVX512 "add AVX 512 codepath" ON ${_IS_X86} OFF) | ||
| 66 | + add_feature_info(AVX512 BASE64_WITH_AVX512 "add AVX512 codepath") | ||
| 65 | 67 | ||
| 66 | 68 | cmake_dependent_option(BASE64_WITH_NEON32 "add NEON32 codepath" OFF _TARGET_ARCH_arm OFF) | |
| 67 | 69 | add_feature_info(NEON32 BASE64_WITH_NEON32 "add NEON32 codepath") | |
@@ -118,6 +120,7 @@ add_library(base64 | |||
| 118 | 120 | lib/arch/sse42/codec.c | |
| 119 | 121 | lib/arch/avx/codec.c | |
| 120 | 122 | lib/arch/avx2/codec.c | |
| 123 | + lib/arch/avx512/codec.c | ||
| 121 | 124 | ||
| 122 | 125 | lib/arch/neon32/codec.c | |
| 123 | 126 | lib/arch/neon64/codec.c | |
@@ -206,6 +209,7 @@ if (_TARGET_ARCH STREQUAL "x86" OR _TARGET_ARCH STREQUAL "x64") | |||
| 206 | 209 | configure_codec(SSE42 __SSSE4_2__) | |
| 207 | 210 | configure_codec(AVX) | |
| 208 | 211 | configure_codec(AVX2) | |
| 212 | + configure_codec(AVX512) | ||
| 209 | 213 | ||
| 210 | 214 | elseif (_TARGET_ARCH STREQUAL "arm") | |
| 211 | 215 | set(BASE64_NEON32_CFLAGS "${COMPILE_FLAGS_NEON32}" CACHE STRING "the NEON32 compile flags (for 'lib/arch/neon32/codec.c')") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | Copyright (c) 2005-2007, Nick Galbreath | |
| 2 | - Copyright (c) 2013-2019, Alfred Klomp | ||
| 3 | - Copyright (c) 2015-2017, Wojciech Mula | ||
| 2 | + Copyright (c) 2015-2018, Wojciech Muła | ||
| 4 | 3 | Copyright (c) 2016-2017, Matthieu Darbois | |
| 4 | + Copyright (c) 2013-2022, Alfred Klomp | ||
| 5 | 5 | All rights reserved. | |
| 6 | 6 | ||
| 7 | 7 | Redistribution and use in source and binary forms, with or without | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ CFLAGS += -std=c99 -O3 -Wall -Wextra -pedantic | |||
| 4 | 4 | OBJCOPY ?= objcopy | |
| 5 | 5 | ||
| 6 | 6 | OBJS = \ | |
| 7 | + lib/arch/avx512/codec.o \ | ||
| 7 | 8 | lib/arch/avx2/codec.o \ | |
| 8 | 9 | lib/arch/generic/codec.o \ | |
| 9 | 10 | lib/arch/neon32/codec.o \ | |
@@ -16,6 +17,7 @@ OBJS = \ | |||
| 16 | 17 | lib/codec_choose.o \ | |
| 17 | 18 | lib/tables/tables.o | |
| 18 | 19 | ||
| 20 | + HAVE_AVX512 = 0 | ||
| 19 | 21 | HAVE_AVX2 = 0 | |
| 20 | 22 | HAVE_NEON32 = 0 | |
| 21 | 23 | HAVE_NEON64 = 0 | |
@@ -26,6 +28,9 @@ HAVE_AVX = 0 | |||
| 26 | 28 | ||
| 27 | 29 | # The user should supply compiler flags for the codecs they want to build. | |
| 28 | 30 | # Check which codecs we're going to include: | |
| 31 | + ifdef AVX512_CFLAGS | ||
| 32 | + HAVE_AVX512 = 1 | ||
| 33 | + endif | ||
| 29 | 34 | ifdef AVX2_CFLAGS | |
| 30 | 35 | HAVE_AVX2 = 1 | |
| 31 | 36 | endif | |
@@ -64,7 +69,8 @@ lib/libbase64.o: $(OBJS) | |||
| 64 | 69 | $(OBJCOPY) --keep-global-symbols=lib/exports.txt $@ | |
| 65 | 70 | ||
| 66 | 71 | lib/config.h: | |
| 67 | - @echo "#define HAVE_AVX2 $(HAVE_AVX2)" > $@ | ||
| 72 | + @echo "#define HAVE_AVX512 $(HAVE_AVX512)" > $@ | ||
| 73 | + @echo "#define HAVE_AVX2 $(HAVE_AVX2)" >> $@ | ||
| 68 | 74 | @echo "#define HAVE_NEON32 $(HAVE_NEON32)" >> $@ | |
| 69 | 75 | @echo "#define HAVE_NEON64 $(HAVE_NEON64)" >> $@ | |
| 70 | 76 | @echo "#define HAVE_SSSE3 $(HAVE_SSSE3)" >> $@ | |
@@ -75,6 +81,7 @@ lib/config.h: | |||
| 75 | 81 | $(OBJS): lib/config.h | |
| 76 | 82 | $(OBJS): CFLAGS += -Ilib | |
| 77 | 83 | ||
| 84 | + lib/arch/avx512/codec.o: CFLAGS += $(AVX512_CFLAGS) | ||
| 78 | 85 | lib/arch/avx2/codec.o: CFLAGS += $(AVX2_CFLAGS) | |
| 79 | 86 | lib/arch/neon32/codec.o: CFLAGS += $(NEON32_CFLAGS) | |
| 80 | 87 | lib/arch/neon64/codec.o: CFLAGS += $(NEON64_CFLAGS) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | [](https://github.com/aklomp/base64/actions/workflows/test.yml) | |
| 4 | 4 | ||
| 5 | 5 | This is an implementation of a base64 stream encoding/decoding library in C99 | |
| 6 | - with SIMD (AVX2, NEON, AArch64/NEON, SSSE3, SSE4.1, SSE4.2, AVX) and | ||
| 6 | + with SIMD (AVX2, AVX512, NEON, AArch64/NEON, SSSE3, SSE4.1, SSE4.2, AVX) and | ||
| 7 | 7 | [OpenMP](http://www.openmp.org) acceleration. It also contains wrapper functions | |
| 8 | 8 | to encode/decode simple length-delimited strings. This library aims to be: | |
| 9 | 9 | ||
@@ -19,6 +19,10 @@ will pick an optimized codec that lets it encode/decode 12 or 24 bytes at a | |||
| 19 | 19 | time, which gives a speedup of four or more times compared to the "plain" | |
| 20 | 20 | bytewise codec. | |
| 21 | 21 | ||
| 22 | + AVX512 support is only for encoding at present, utilizing the AVX512 VL and VBMI | ||
| 23 | + instructions. Decoding part reused AVX2 implementations. For CPUs later than | ||
| 24 | + Cannonlake (manufactured in 2018) supports these instructions. | ||
| 25 | + | ||
| 22 | 26 | NEON support is hardcoded to on or off at compile time, because portable | |
| 23 | 27 | runtime feature detection is unavailable on ARM. | |
| 24 | 28 | ||
@@ -59,6 +63,9 @@ optimizations described by Wojciech Muła in a | |||
| 59 | 63 | [articles](http://0x80.pl/notesen/2016-01-17-sse-base64-decoding.html). | |
| 60 | 64 | His own code is [here](https://github.com/WojciechMula/toys/tree/master/base64). | |
| 61 | 65 | ||
| 66 | + The AVX512 encoder is based on code from Wojciech Muła's | ||
| 67 | + [base64simd](https://github.com/WojciechMula/base64simd) library. | ||
| 68 | + | ||
| 62 | 69 | The OpenMP implementation was added by Ferry Toth (@htot) from [Exalon Delft](http://www.exalondelft.nl). | |
| 63 | 70 | ||
| 64 | 71 | ## Building | |
@@ -76,8 +83,8 @@ To compile just the "plain" library without SIMD codecs, type: | |||
| 76 | 83 | make lib/libbase64.o | |
| 77 | 84 | ``` | |
| 78 | 85 | ||
| 79 | - Optional SIMD codecs can be included by specifying the `AVX2_CFLAGS`, `NEON32_CFLAGS`, `NEON64_CFLAGS`, | ||
| 80 | - `SSSE3_CFLAGS`, `SSE41_CFLAGS`, `SSE42_CFLAGS` and/or `AVX_CFLAGS` environment variables. | ||
| 86 | + Optional SIMD codecs can be included by specifying the `AVX2_CFLAGS`, `AVX512_CFLAGS`, | ||
| 87 | + `NEON32_CFLAGS`, `NEON64_CFLAGS`, `SSSE3_CFLAGS`, `SSE41_CFLAGS`, `SSE42_CFLAGS` and/or `AVX_CFLAGS` environment variables. | ||
| 81 | 88 | A typical build invocation on x86 looks like this: | |
| 82 | 89 | ||
| 83 | 90 | ```sh | |
@@ -93,6 +100,15 @@ Example: | |||
| 93 | 100 | AVX2_CFLAGS=-mavx2 make | |
| 94 | 101 | ``` | |
| 95 | 102 | ||
| 103 | + ### AVX512 | ||
| 104 | + | ||
| 105 | + To build and include the AVX512 codec, set the `AVX512_CFLAGS` environment variable to a value that will turn on AVX512 support in your compiler, typically `-mavx512vl -mavx512vbmi`. | ||
| 106 | + Example: | ||
| 107 | + | ||
| 108 | + ```sh | ||
| 109 | + AVX512_CFLAGS="-mavx512vl -mavx512vbmi" make | ||
| 110 | + ``` | ||
| 111 | + | ||
| 96 | 112 | The codec will only be used if runtime feature detection shows that the target machine supports AVX2. | |
| 97 | 113 | ||
| 98 | 114 | ### SSSE3 | |
@@ -208,6 +224,7 @@ Mainly there for testing purposes, this is also useful on ARM where the only way | |||
| 208 | 224 | The following constants can be used: | |
| 209 | 225 | ||
| 210 | 226 | - `BASE64_FORCE_AVX2` | |
| 227 | + - `BASE64_FORCE_AVX512` | ||
| 211 | 228 | - `BASE64_FORCE_NEON32` | |
| 212 | 229 | - `BASE64_FORCE_NEON64` | |
| 213 | 230 | - `BASE64_FORCE_PLAIN` | |
@@ -434,7 +451,7 @@ x86 processors | |||
| 434 | 451 | | i7-4770 @ 3.4 GHz DDR1600 OPENMP 4 thread | 4884\* | 7099\* | 4917\* | 7057\* | 4799\* | 7143\* | 4902\* | 7219\* | | |
| 435 | 452 | | i7-4770 @ 3.4 GHz DDR1600 OPENMP 8 thread | 5212\* | 8849\* | 5284\* | 9099\* | 5289\* | 9220\* | 4849\* | 9200\* | | |
| 436 | 453 | | i7-4870HQ @ 2.5 GHz | 1471\* | 3066\* | 6721\* | 6962\* | 7015\* | 8267\* | 8328\* | 11576\* | | |
| 437 | - | i5-4590S @ 3.0 GHz | 3356 | 3197 | 4363 | 6104 | 4243 | 6233 | 4160 | 6344 | | ||
| 454 | + | i5-4590S @ 3.0 GHz | 3356 | 3197 | 4363 | 6104 | 4243\* | 6233 | 4160\* | 6344 | | ||
| 438 | 455 | | Xeon X5570 @ 2.93 GHz | 2161 | 1508 | 3160 | 3915 | - | - | - | - | | |
| 439 | 456 | | Pentium4 @ 3.4 GHz | 896 | 740 | - | - | - | - | - | - | | |
| 440 | 457 | | Atom N270 | 243 | 266 | 508 | 387 | - | - | - | - | | |
| Back | FazBrowse Home | New Git URL |
0 commit comments