diff options
| author | Ilya Leoshkevich <iii@linux.ibm.com> | 2025-09-10 11:28:03 +0200 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-01-27 20:22:17 -0800 |
| commit | 07f2d4237eade624182b1cf11f1f516985aed620 (patch) | |
| tree | fad27d61fc7e05c8bc08662fd1caa4fb2bea928e /configure | |
| parent | 3382ba45561ea82a1d8976578b2a41facff3b8bc (diff) | |
| download | zlib-07f2d4237eade624182b1cf11f1f516985aed620.tar.gz zlib-07f2d4237eade624182b1cf11f1f516985aed620.tar.bz2 zlib-07f2d4237eade624182b1cf11f1f516985aed620.zip | |
Vectorize the CRC-32 calculation on the s390x.
Use vector extensions when compiling for s390x and binutils knows
about them. At runtime, check whether kernel supports vector
extensions (it has to be not just the CPU, but also the kernel)
and choose between the regular and the vectorized implementations.
Co-authored-by: Eduard Stefes <eddy@linux.ibm.com>
Diffstat (limited to 'configure')
| -rwxr-xr-x | configure | 70 |
1 files changed, 70 insertions, 0 deletions
| @@ -95,6 +95,7 @@ memory=0 | |||
| 95 | undefined=0 | 95 | undefined=0 |
| 96 | insecure=0 | 96 | insecure=0 |
| 97 | unknown=0 | 97 | unknown=0 |
| 98 | enable_crcvx=1 | ||
| 98 | old_cc="$CC" | 99 | old_cc="$CC" |
| 99 | old_cflags="$CFLAGS" | 100 | old_cflags="$CFLAGS" |
| 100 | OBJC='$(OBJZ) $(OBJG)' | 101 | OBJC='$(OBJZ) $(OBJG)' |
| @@ -122,6 +123,7 @@ case "$1" in | |||
| 122 | echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log | 123 | echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log |
| 123 | echo ' [--insecure] [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log | 124 | echo ' [--insecure] [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log |
| 124 | echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log | 125 | echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log |
| 126 | echo ' [--disable-crcvx]' | tee -a configure.log | ||
| 125 | exit 0 ;; | 127 | exit 0 ;; |
| 126 | -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; | 128 | -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; |
| 127 | -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; | 129 | -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; |
| @@ -150,6 +152,7 @@ case "$1" in | |||
| 150 | --memory) memory=1; shift ;; | 152 | --memory) memory=1; shift ;; |
| 151 | --undefined) undefined=1; shift ;; | 153 | --undefined) undefined=1; shift ;; |
| 152 | --insecure) insecure=1; shift ;; | 154 | --insecure) insecure=1; shift ;; |
| 155 | --disable-crcvx) enable_crcvx=0; shift ;; | ||
| 153 | *) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;; | 156 | *) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;; |
| 154 | esac | 157 | esac |
| 155 | done | 158 | done |
| @@ -888,6 +891,70 @@ EOF | |||
| 888 | fi | 891 | fi |
| 889 | fi | 892 | fi |
| 890 | 893 | ||
| 894 | # check for ibm s390x build | ||
| 895 | HAVE_S390X=0 | ||
| 896 | cat > $test.c << EOF | ||
| 897 | #ifndef __s390x__ | ||
| 898 | #error | ||
| 899 | #endif | ||
| 900 | EOF | ||
| 901 | if try $CC -c $CFLAGS $test.c; then | ||
| 902 | echo "Checking for s390x build ... Yes." | tee -a configure.log | ||
| 903 | HAVE_S390X=1 | ||
| 904 | else | ||
| 905 | echo "Checking for s390x build ... No." | tee -a configure.log | ||
| 906 | fi | ||
| 907 | |||
| 908 | # check for ibm s390x vx vector extensions | ||
| 909 | HAVE_S390X_VX=0 | ||
| 910 | if test $HAVE_S390X -eq 1 && test $enable_crcvx -eq 1 ; then | ||
| 911 | # preset the compiler specific flags | ||
| 912 | if test $clang -eq 1; then | ||
| 913 | VGFMAFLAG=-fzvector | ||
| 914 | else | ||
| 915 | VGFMAFLAG=-mzarch | ||
| 916 | fi | ||
| 917 | |||
| 918 | cat > $test.c <<EOF | ||
| 919 | #ifndef __s390x__ | ||
| 920 | #error | ||
| 921 | #endif | ||
| 922 | #include <vecintrin.h> | ||
| 923 | int main(void) { | ||
| 924 | unsigned long long a __attribute__((vector_size(16))) = { 0 }; | ||
| 925 | unsigned long long b __attribute__((vector_size(16))) = { 0 }; | ||
| 926 | unsigned char c __attribute__((vector_size(16))) = { 0 }; | ||
| 927 | c = vec_gfmsum_accum_128(a, b, c); | ||
| 928 | return c[0]; | ||
| 929 | } | ||
| 930 | EOF | ||
| 931 | |||
| 932 | # cflags already contains a valid march | ||
| 933 | if try $CC -c $CFLAGS $VGFMAFLAG $test.c; then | ||
| 934 | echo "Checking for s390x vx vector extension ... Yes." | tee -a configure.log | ||
| 935 | HAVE_S390X_VX=1 | ||
| 936 | # or set march for our compile units | ||
| 937 | elif try $CC -c $CFLAGS $VGFMAFLAG -march=z13 $test.c; then | ||
| 938 | echo "Checking for s390x vx vector extension (march=z13) ... Yes." | tee -a configure.log | ||
| 939 | HAVE_S390X_VX=1 | ||
| 940 | VGFMAFLAG="$VGFMAFLAG -march=z13" | ||
| 941 | # else we are not on s390x | ||
| 942 | else | ||
| 943 | echo "Checking for s390x vx vector extension ... No." | tee -a configure.log | ||
| 944 | fi | ||
| 945 | |||
| 946 | # prepare compiling for s390x | ||
| 947 | if test $HAVE_S390X_VX -eq 1; then | ||
| 948 | CFLAGS="$CFLAGS -DHAVE_S390X_VX" | ||
| 949 | SFLAGS="$SFLAGS -DHAVE_S390X_VX" | ||
| 950 | OBJC="$OBJC crc32_vx.o" | ||
| 951 | PIC_OBJC="$PIC_OBJC crc32_vx.lo" | ||
| 952 | else | ||
| 953 | # target has no vx extension | ||
| 954 | VGFMAFLAG="" | ||
| 955 | fi | ||
| 956 | fi | ||
| 957 | |||
| 891 | # show the results in the log | 958 | # show the results in the log |
| 892 | echo >> configure.log | 959 | echo >> configure.log |
| 893 | echo ALL = $ALL >> configure.log | 960 | echo ALL = $ALL >> configure.log |
| @@ -919,6 +986,9 @@ echo mandir = $mandir >> configure.log | |||
| 919 | echo prefix = $prefix >> configure.log | 986 | echo prefix = $prefix >> configure.log |
| 920 | echo sharedlibdir = $sharedlibdir >> configure.log | 987 | echo sharedlibdir = $sharedlibdir >> configure.log |
| 921 | echo uname = $uname >> configure.log | 988 | echo uname = $uname >> configure.log |
| 989 | echo HAVE_S390X = $HAVE_S390X >> configure.log | ||
| 990 | echo HAVE_S390X_VX = $HAVE_S390X_VX >> configure.log | ||
| 991 | echo VGFMAFLAG = $VGFMAFLAG >> configure.log | ||
| 922 | 992 | ||
| 923 | # update Makefile with the configure results | 993 | # update Makefile with the configure results |
| 924 | sed < ${SRCDIR}Makefile.in " | 994 | sed < ${SRCDIR}Makefile.in " |
