diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 538dd51..61c765c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,11 +73,12 @@ jobs: -DBASE64_BUILD_TESTS=ON ${{ runner.os != 'Windows' && '-DCMAKE_BUILD_TYPE=Release' || '' }} ${{ runner.os == 'Windows' && matrix.platform == 'i686' && '-A Win32' || '' }} - -DBASE64_WITH_AVX512=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 + env: + BASE64_TEST_SKIP_AVX512: "1" alpine-makefile-test: name: makefile-alpine-amd64-gcc @@ -112,13 +113,14 @@ jobs: -B out -Werror=dev -DBASE64_BUILD_TESTS=ON - -DBASE64_WITH_AVX512=OFF -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 + env: + BASE64_TEST_SKIP_AVX512: "1" alpine-alt-arch-makefile-test: name: makefile-alpine-${{matrix.arch}}-${{matrix.cc}} @@ -206,13 +208,14 @@ jobs: -Werror=dev -DBASE64_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release - -DBASE64_WITH_AVX512=OFF - name: CMake Build shell: msys2 {0} run: cmake --build out --config Release --verbose - name: CTest shell: msys2 {0} run: ctest --no-tests=error --test-dir out -VV --build-config Release + env: + BASE64_TEST_SKIP_AVX512: "1" - name: Test demo utility with unicode filenames and file contents on Windows shell: msys2 {0} run: | diff --git a/lib/codec_choose.c b/lib/codec_choose.c index 0bf8fb6..a98b947 100644 --- a/lib/codec_choose.c +++ b/lib/codec_choose.c @@ -82,7 +82,7 @@ #define _XCR_XMM_AND_YMM_STATE_ENABLED_BY_OS (bit_XMM | bit_YMM) -#define _AVX_512_ENABLED_BY_OS (bit_XMM | bit_YMM | bit_OPMASK | bit_ZMM | bit bit_HIGH_ZMM) +#define _AVX_512_ENABLED_BY_OS (bit_XMM | bit_YMM | bit_OPMASK | bit_ZMM | bit_HIGH_ZMM) #endif diff --git a/test/benchmark.c b/test/benchmark.c index e78b696..238d081 100644 --- a/test/benchmark.c +++ b/test/benchmark.c @@ -271,10 +271,12 @@ main () sizes[i].label, sizes[i].repeat, sizes[i].batch); // Loop over all codecs: - for (size_t j = 0; codecs[j]; j++) - if (codec_supported(1 << j)) - codec_bench(&b, &sizes[i], codecs[j], 1 << j); - }; + for (size_t j = 0; codecs[j]; j++) { + int flags = codec_supported(j); + if (flags) + codec_bench(&b, &sizes[i], codecs[j], flags); + } + } // Free memory: err2: free(b.enc); diff --git a/test/ci/analysis.sh b/test/ci/analysis.sh index f7da185..9fb3b52 100755 --- a/test/ci/analysis.sh +++ b/test/ci/analysis.sh @@ -15,8 +15,9 @@ for USE_ASSEMBLY in 0 1; do export SSE42_CFLAGS="-msse4.2 -DBASE64_SSE42_USE_ASM=${USE_ASSEMBLY}" export AVX_CFLAGS="-mavx -DBASE64_AVX_USE_ASM=${USE_ASSEMBLY}" export AVX2_CFLAGS="-mavx2 -DBASE64_AVX2_USE_ASM=${USE_ASSEMBLY}" + export AVX512_CFLAGS="-mavx512vl -mavx512vbmi" # Temporarily disable AVX512; it is not available in CI yet. - # export AVX512_CFLAGS="-mavx512vl -mavx512vbmi" + export BASE64_TEST_SKIP_AVX512=1 elif [ "${MACHINE}" == "aarch64" ]; then export NEON64_CFLAGS="-march=armv8-a" elif [ "${MACHINE}" == "armv7l" ]; then diff --git a/test/ci/test.sh b/test/ci/test.sh index fb18841..27b6812 100755 --- a/test/ci/test.sh +++ b/test/ci/test.sh @@ -7,12 +7,10 @@ if [ "${MACHINE}" == "x86_64" ]; then export SSE41_CFLAGS=-msse4.1 export SSE42_CFLAGS=-msse4.2 export AVX_CFLAGS=-mavx - # no AVX2 or AVX512 on GHA macOS - if [ "$(uname -s)" != "Darwin" ]; then - export AVX2_CFLAGS=-mavx2 - # Temporarily disable AVX512; it is not available in CI yet. - # export AVX512_CFLAGS="-mavx512vl -mavx512vbmi" - fi + export AVX2_CFLAGS=-mavx2 + export AVX512_CFLAGS="-mavx512vl -mavx512vbmi" + # Temporarily disable AVX512; it is not available in CI yet. + export BASE64_TEST_SKIP_AVX512=1 elif [ "${MACHINE}" == "aarch64" ]; then export NEON64_CFLAGS="-march=armv8-a" elif [ "${MACHINE}" == "armv7l" ]; then diff --git a/test/codec_supported.c b/test/codec_supported.c index f68c766..e90d820 100644 --- a/test/codec_supported.c +++ b/test/codec_supported.c @@ -1,3 +1,5 @@ +#include +#include #include #include "../include/libbase64.h" @@ -18,12 +20,21 @@ static char *_codecs[] = char **codecs = _codecs; int -codec_supported (int flags) +codec_supported (size_t index) { + if (index >= (sizeof(_codecs) / sizeof(_codecs[0])) - 1) { + return 0; + } // Check if given codec is supported by trying to decode a test string: char *a = "aGVsbG8="; char b[10]; size_t outlen; - - return (base64_decode(a, strlen(a), b, &outlen, flags) != -1); + char envVariable[32]; + sprintf(envVariable, "BASE64_TEST_SKIP_%s", _codecs[index]); + const char* envOverride = getenv(envVariable); + if ((envOverride != NULL) && (strcmp(envOverride, "1") == 0)) { + return 0; + } + int flags = 1 << index; + return (base64_decode(a, strlen(a), b, &outlen, flags) != -1) ? flags : 0; } diff --git a/test/codec_supported.h b/test/codec_supported.h index 18baec0..870d397 100644 --- a/test/codec_supported.h +++ b/test/codec_supported.h @@ -1,3 +1,3 @@ extern char **codecs; -int codec_supported (int flags); +int codec_supported (size_t index); diff --git a/test/test_base64.c b/test/test_base64.c index 94aad2d..ae5e663 100644 --- a/test/test_base64.c +++ b/test/test_base64.c @@ -313,14 +313,16 @@ test_invalid_dec_input (int flags) } static int -test_one_codec (const char *codec, int flags) +test_one_codec (size_t codec_index) { bool fail = false; + const char *codec = codecs[codec_index]; printf("Codec %s:\n", codec); // Skip if this codec is not supported: - if (!codec_supported(flags)) { + int flags = codec_supported(codec_index); + if (flags == 0) { puts(" skipping"); return false; } @@ -376,12 +378,8 @@ main () // Loop over all codecs: for (size_t i = 0; codecs[i]; i++) { - - // Flags to invoke this codec: - int codec_flags = (1 << i); - // Test this codec, merge the results: - fail |= test_one_codec(codecs[i], codec_flags); + fail |= test_one_codec(i); } return (fail) ? 1 : 0;