From: Nathan Moinvaziri Date: Thu, 30 Apr 2020 17:14:32 +0000 (-0700) Subject: Added X86 AVX2, SSE2, SSE4, and PCLMULQDQ cmake options and CI configurations. X-Git-Tag: 1.9.9-b1~318 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de936977c964eb7bbde7039ee168420fe209bdec;p=thirdparty%2Fzlib-ng.git Added X86 AVX2, SSE2, SSE4, and PCLMULQDQ cmake options and CI configurations. --- diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8bd218633..6ae7b717d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -10,15 +10,21 @@ jobs: name: [ Ubuntu 18.04 GCC, Ubuntu 18.04 GCC OSB -O1, + Ubuntu 18.04 GCC No AVX2, + Ubuntu 18.04 GCC No SSE2, + Ubuntu 18.04 GCC No SSE4, + Ubuntu 18.04 GCC No PCLMULQDQ, Ubuntu 18.04 GCC No Opt, Ubuntu 18.04 GCC Compat, Ubuntu 18.04 GCC Compat No Opt, Ubuntu 18.04 GCC Compat, Ubuntu 18.04 GCC ARM SF, + Ubuntu 18.04 GCC ARM SF No ACLE, Ubuntu 18.04 GCC ARM SF No Opt, Ubuntu 18.04 GCC ARM SF Compat, Ubuntu 18.04 GCC ARM SF Compat No Opt, Ubuntu 18.04 GCC ARM HF, + Ubuntu 18.04 GCC ARM HF No NEON, Ubuntu 18.04 GCC ARM HF No Opt, Ubuntu 18.04 GCC ARM HF Compat, Ubuntu 18.04 GCC ARM HF Compat No Opt, @@ -57,6 +63,30 @@ jobs: codecov: ubuntu_gcc_osb cflags: -O1 -g3 + - name: Ubuntu 18.04 GCC No AVX2 + os: ubuntu-18.04 + compiler: gcc + cmake-args: -DWITH_SANITIZERS=ON -DWITH_AVX2=OFF + codecov: ubuntu_gcc_no_avx2 + + - name: Ubuntu 18.04 GCC No SSE2 + os: ubuntu-18.04 + compiler: gcc + cmake-args: -DWITH_SANITIZERS=ON -DWITH_SSE2=OFF + codecov: ubuntu_gcc_no_sse2 + + - name: Ubuntu 18.04 GCC No SSE4 + os: ubuntu-18.04 + compiler: gcc + cmake-args: -DWITH_SANITIZERS=ON -DWITH_SSE4=OFF + codecov: ubuntu_gcc_no_sse4 + + - name: Ubuntu 18.04 GCC No PCLMULQDQ + os: ubuntu-18.04 + compiler: gcc + cmake-args: -DWITH_SANITIZERS=ON -DWITH_PCLMULQDQ=OFF + codecov: ubuntu_gcc_no_pclmulqdq + - name: Ubuntu 18.04 GCC No Opt os: ubuntu-18.04 compiler: gcc @@ -88,6 +118,13 @@ jobs: packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross codecov: ubuntu_gcc_armsf + - name: Ubuntu 18.04 GCC ARM SF No ACLE + os: ubuntu-18.04 + compiler: arm-linux-gnueabi-gcc + cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DWITH_SANITIZERS=ON -DWITH_ACLE=OFF + packages: qemu gcc-arm-linux-gnueabi libc-dev-armel-cross + codecov: ubuntu_gcc_armsf_no_acle + - name: Ubuntu 18.04 GCC ARM SF No Opt os: ubuntu-18.04 compiler: arm-linux-gnueabi-gcc @@ -116,6 +153,13 @@ jobs: packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross codecov: ubuntu_gcc_armhf + - name: Ubuntu 18.04 GCC ARM HF No NEON + os: ubuntu-18.04 + compiler: arm-linux-gnueabihf-gcc + cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_SANITIZERS=ON -DWITH_NEON=OFF + packages: qemu gcc-arm-linux-gnueabihf libc-dev-armel-cross + codecov: ubuntu_gcc_armhf_no_neon + - name: Ubuntu 18.04 GCC ARM HF No Opt os: ubuntu-18.04 compiler: arm-linux-gnueabihf-gcc diff --git a/CMakeLists.txt b/CMakeLists.txt index d90335106..ddeb46f0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,15 +88,24 @@ option(WITH_OPTIM "Build with optimisation" ON) option(WITH_NEW_STRATEGIES "Use new strategies" ON) option(WITH_NATIVE_INSTRUCTIONS "Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF) +option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF) +option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF) + if(BASEARCH_ARM_FOUND) - option(WITH_ACLE "Build with ACLE CRC" ON) + option(WITH_ACLE "Build with ACLE" ON) option(WITH_NEON "Build with NEON intrinsics" ON) elseif(BASEARCH_S360_FOUND AND "${ARCH}" MATCHES "s390x") option(WITH_DFLTCC_DEFLATE "Use DEFLATE CONVERSION CALL instruction for compression on IBM Z" OFF) option(WITH_DFLTCC_INFLATE "Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z" OFF) +elseif(BASEARCH_X86_FOUND) + option(WITH_AVX2 "Build with AVX2" ON) + option(WITH_SSE2 "Build with SSE2" ON) + option(WITH_SSE4 "Build with SSE4" ON) + option(WITH_PCLMULQDQ "Build with PCLMULQDQ" ON) endif() -option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF) -option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF) + +mark_as_advanced(FORCE WITH_ACLE WITH_NEON WITH_DFLTCC_DEFLATE WITH_DFLTCC_INFLATE + WITH_AVX2 WITH_SSE2 WITH_SSE4 WITH_PCLMULQDQ) add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Provide a zlib-compatible API") add_feature_info(WITH_GZFILEOP WITH_GZFILEOP "Compile with support for gzFile-related functions") @@ -654,13 +663,13 @@ if(WITH_OPTIM) if(MSVC) list(APPEND ZLIB_ARCH_HDRS fallback_builtins.h) endif() - if(HAVE_AVX2_INTRIN) + if(WITH_AVX2 AND HAVE_AVX2_INTRIN) add_definitions(-DX86_AVX2) list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/slide_avx.c) add_feature_info(AVX2_SLIDEHASH 1 "Support AVX2-optimized slide_hash, using \"${AVX2FLAG}\"") add_intrinsics_option("${AVX2FLAG}") endif() - if(HAVE_SSE42CRC_INLINE_ASM OR HAVE_SSE42CRC_INTRIN) + if(WITH_SSE4 AND (HAVE_SSE42CRC_INLINE_ASM OR HAVE_SSE42CRC_INTRIN)) add_definitions(-DX86_SSE42_CRC_HASH) list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/insert_string_sse.c) add_feature_info(SSE42_CRC 1 "Support CRC hash generation using the SSE4.2 instruction set, using \"${SSE4FLAG}\"") @@ -674,7 +683,7 @@ if(WITH_OPTIM) add_feature_info(SSE42_DEFLATE_QUICK 1 "Support SSE4.2-accelerated quick compression") endif() endif() - if(HAVE_SSE2_INTRIN) + if(WITH_SSE2 AND HAVE_SSE2_INTRIN) add_definitions(-DX86_SSE2) list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/fill_window_sse.c ${ARCHDIR}/slide_sse.c) if(NOT ${ARCH} MATCHES "x86_64") @@ -685,7 +694,7 @@ if(WITH_OPTIM) endif() endif() endif() - if(HAVE_PCLMULQDQ_INTRIN) + if(WITH_PCLMULQDQ AND HAVE_PCLMULQDQ_INTRIN) add_definitions(-DX86_PCLMULQDQ_CRC) list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/crc_folding.c) add_intrinsics_option("${PCLMULFLAG}") diff --git a/README.md b/README.md index aca0cbf27..e01e5ba5a 100644 --- a/README.md +++ b/README.md @@ -84,25 +84,19 @@ make test Build Options ------------- - -| CMake | configure | Description | Default | -|:-------------------------|:-------------------------|:---------------------------------------------------------------------------------------------|----------------------------------| -| ZLIB_COMPAT | --zlib-compat | Compile with zlib compatible API | OFF | -| ZLIB_ENABLE_TESTS | | Build test binaries | ON | -| WITH_GZFILEOP | --with-gzfileops | Compile with support for gzFile related functions | OFF | -| WITH_MSAN | --with-msan | Build with memory sanitizer | OFF | -| WITH_OPTIM | --without-optimizations | Build with optimisations | ON | -| WITH_NEW_STRATEGIES | --without-new-strategies | Use new strategies | ON | -| WITH_NATIVE_INSTRUCTIONS | | Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native) | OFF | -| | --force-sse2 | Assume SSE2 instructions are always available | DISABLED (x86), ENABLED (x86_64) | -| WITH_ACLE | --without-acle | Build with ACLE CRC | ON | -| WITH_NEON | --without-neon | Build with NEON intrinsics | ON | -| WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Use DEFLATE COMPRESSION CALL instruction for compression on IBM Z | OFF | -| WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Use DEFLATE COMPRESSION CALL instruction for decompression on IBM Z | OFF | -| WITH_SANITIZERS | --with-sanitizers | Build with address sanitizer and all supported sanitizers other than memory sanitizer | OFF | -| WITH_FUZZERS | --with-fuzzers | Build test/fuzz | OFF | -| WITH_MAINTAINER_WARNINGS | | Build with project maintainer warnings | OFF | -| WITH_CODE_COVERAGE | | Enable code coverage reporting | OFF | +| CMake | configure | Description | Default | +|:-------------------------|:-------------------------|:---------------------------------------------------------------------------------------------|---------| +| ZLIB_COMPAT | --zlib-compat | Compile with zlib compatible API | OFF | +| ZLIB_ENABLE_TESTS | | Build test binaries | ON | +| WITH_GZFILEOP | --with-gzfileops | Compile with support for gzFile related functions | OFF | +| WITH_MSAN | --with-msan | Build with memory sanitizer | OFF | +| WITH_OPTIM | --without-optimizations | Build with optimisations | ON | +| WITH_NEW_STRATEGIES | --without-new-strategies | Use new strategies | ON | +| WITH_NATIVE_INSTRUCTIONS | | Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native) | OFF | +| WITH_SANITIZERS | --with-sanitizers | Build with address sanitizer and all supported sanitizers other than memory sanitizer | OFF | +| WITH_FUZZERS | --with-fuzzers | Build test/fuzz | OFF | +| WITH_MAINTAINER_WARNINGS | | Build with project maintainer warnings | OFF | +| WITH_CODE_COVERAGE | | Enable code coverage reporting | OFF | Install ------- @@ -168,6 +162,21 @@ The deflate and zlib specifications were written by L. Peter Deutsch. zlib was originally created by Jean-loup Gailly (compression) and Mark Adler (decompression). +Advanced Build Options +---------------------- +| CMake | configure | Description | Default | +|:--------------------|:----------------------|:--------------------------------------------------------------------|------------------------| +| UNALIGNED_OK | | Allow unaligned reads | ON (x86, arm) | +| | --force-sse2 | Assume SSE2 instructions are always available | ON (x86), OFF (x86_64) | +| WITH_AVX2 | | Build with AVX2 intrinsics | ON | +| WITH_SSE2 | | Build with SSE2 intrinsics | ON | +| WITH_SSE4 | | Build with SSE4 intrinsics | ON | +| WITH_PCLMULQDQ | | Build with PCLMULQDQ intrinsics | ON | +| WITH_ACLE | --without-acle | Build with ACLE intrinsics | ON | +| WITH_NEON | --without-neon | Build with NEON intrinsics | ON | +| WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Use DEFLATE COMPRESSION CALL instruction for compression on IBM Z | OFF | +| WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Use DEFLATE COMPRESSION CALL instruction for decompression on IBM Z | OFF | + Contents -------- @@ -205,4 +214,4 @@ Contents | zendian.h | BYTE_ORDER for endian tests | | zlib.3 | Man page for zlib | | zlib.map | Linux symbol information | -| zlib.pc.in | Pkg-config template | +| zlib.pc.in | Pkg-config template | \ No newline at end of file