aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2025-09-10 11:28:03 +0200
committerMark Adler <git@madler.net>2026-01-27 20:22:17 -0800
commit07f2d4237eade624182b1cf11f1f516985aed620 (patch)
treefad27d61fc7e05c8bc08662fd1caa4fb2bea928e /configure
parent3382ba45561ea82a1d8976578b2a41facff3b8bc (diff)
downloadzlib-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-xconfigure70
1 files changed, 70 insertions, 0 deletions
diff --git a/configure b/configure
index 3770b03d..05bee1f4 100755
--- a/configure
+++ b/configure
@@ -95,6 +95,7 @@ memory=0
95undefined=0 95undefined=0
96insecure=0 96insecure=0
97unknown=0 97unknown=0
98enable_crcvx=1
98old_cc="$CC" 99old_cc="$CC"
99old_cflags="$CFLAGS" 100old_cflags="$CFLAGS"
100OBJC='$(OBJZ) $(OBJG)' 101OBJC='$(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
155done 158done
@@ -888,6 +891,70 @@ EOF
888 fi 891 fi
889fi 892fi
890 893
894# check for ibm s390x build
895HAVE_S390X=0
896cat > $test.c << EOF
897#ifndef __s390x__
898 #error
899#endif
900EOF
901if try $CC -c $CFLAGS $test.c; then
902 echo "Checking for s390x build ... Yes." | tee -a configure.log
903 HAVE_S390X=1
904else
905 echo "Checking for s390x build ... No." | tee -a configure.log
906fi
907
908# check for ibm s390x vx vector extensions
909HAVE_S390X_VX=0
910if 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>
923int 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}
930EOF
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
956fi
957
891# show the results in the log 958# show the results in the log
892echo >> configure.log 959echo >> configure.log
893echo ALL = $ALL >> configure.log 960echo ALL = $ALL >> configure.log
@@ -919,6 +986,9 @@ echo mandir = $mandir >> configure.log
919echo prefix = $prefix >> configure.log 986echo prefix = $prefix >> configure.log
920echo sharedlibdir = $sharedlibdir >> configure.log 987echo sharedlibdir = $sharedlibdir >> configure.log
921echo uname = $uname >> configure.log 988echo uname = $uname >> configure.log
989echo HAVE_S390X = $HAVE_S390X >> configure.log
990echo HAVE_S390X_VX = $HAVE_S390X_VX >> configure.log
991echo VGFMAFLAG = $VGFMAFLAG >> configure.log
922 992
923# update Makefile with the configure results 993# update Makefile with the configure results
924sed < ${SRCDIR}Makefile.in " 994sed < ${SRCDIR}Makefile.in "