endif()
endif()
endif()
- list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_features.h ${ARCHDIR}/arm_functions.h)
- list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/arm_features.c)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_functions.h)
+ if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_features.h)
+ list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/arm_features.c)
+ endif()
+
if(WITH_ACLE)
check_acle_compiler_flag()
if(HAVE_ACLE_FLAG)
add_definitions(-DPOWER_FEATURES)
endif()
if(HAVE_VMX OR HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
- list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_features.h ${ARCHDIR}/power_functions.h)
- list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power_features.c)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_functions.h)
+ if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_features.h)
+ list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power_features.c)
+ endif()
endif()
# VMX specific options and files
if(WITH_ALTIVEC)
if(HAVE_RVV_INTRIN)
add_definitions(-DRISCV_FEATURES)
add_definitions(-DRISCV_RVV)
- list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_features.h ${ARCHDIR}/riscv_functions.h)
- list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/riscv_features.c)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_functions.h)
+ if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_features.h)
+ list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/riscv_features.c)
+ endif()
# FIXME: we will not set compile flags for riscv_features.c when
# the kernels update hwcap or hwprobe for riscv
- set(RVV_SRCS ${ARCHDIR}/riscv_features.c ${ARCHDIR}/adler32_rvv.c ${ARCHDIR}/chunkset_rvv.c ${ARCHDIR}/compare256_rvv.c ${ARCHDIR}/slide_hash_rvv.c)
+ set(RVV_SRCS ${ARCHDIR}/adler32_rvv.c ${ARCHDIR}/chunkset_rvv.c ${ARCHDIR}/compare256_rvv.c ${ARCHDIR}/slide_hash_rvv.c)
+ if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND RVV_SRCS ${ARCHDIR}/riscv_features.c)
+ endif()
list(APPEND ZLIB_ARCH_SRCS ${RVV_SRCS})
set_property(SOURCE ${RVV_SRCS} PROPERTY COMPILE_FLAGS "${RISCVFLAG} ${NOLTOFLAG}")
else()
check_s390_intrinsics()
if(HAVE_S390_INTRIN)
add_definitions(-DS390_FEATURES)
- list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_features.h ${ARCHDIR}/s390_functions.h)
- list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/s390_features.c)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_functions.h)
+ if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_features.h)
+ list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/s390_features.c)
+ endif()
endif()
if(WITH_DFLTCC_DEFLATE OR WITH_DFLTCC_INFLATE)
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_common.c)
endif()
elseif(BASEARCH_X86_FOUND)
add_definitions(-DX86_FEATURES)
- list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_features.h ${ARCHDIR}/x86_functions.h)
- list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86_features.c)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_functions.h)
+ if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_features.h)
+ list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86_features.c)
+ endif()
if(MSVC)
list(APPEND ZLIB_ARCH_HDRS fallback_builtins.h)
endif()
check_xsave_intrinsics()
if(HAVE_XSAVE_INTRIN)
add_feature_info(XSAVE 1 "Support XSAVE intrinsics using \"${XSAVEFLAG}\"")
- set_property(SOURCE ${ARCHDIR}/x86_features.c PROPERTY COMPILE_FLAGS "${XSAVEFLAG}")
+ if(WITH_RUNTIME_CPU_DETECTION)
+ set_property(SOURCE ${ARCHDIR}/x86_features.c PROPERTY COMPILE_FLAGS "${XSAVEFLAG}")
+ endif()
if(NOT (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 8.2))
add_definitions(-DX86_HAVE_XSAVE_INTRIN)
endif()
chunkset_tpl.h
compare256_rle.h
arch_functions.h
- cpu_features.h
crc32_braid_p.h
crc32_braid_comb_p.h
crc32_braid_tbl.h
arch/generic/slide_hash_c.c
adler32.c
compress.c
- cpu_features.c
crc32.c
crc32_braid_comb.c
deflate.c
zutil.c
)
+if(WITH_RUNTIME_CPU_DETECTION)
+ list(APPEND ZLIB_PRIVATE_HDRS cpu_features.h)
+ list(APPEND ZLIB_SRCS cpu_features.c)
+endif()
+
set(ZLIB_GZFILE_PRIVATE_HDRS
gzguts.h
)
arch/generic/slide_hash_c.o \
adler32.o \
compress.o \
- cpu_features.o \
crc32.o \
crc32_braid_comb.o \
deflate.o \
trees.o \
uncompr.o \
zutil.o \
+ cpu_features.o \
$(ARCH_STATIC_OBJS)
OBJG = \
arch/generic/slide_hash_c.lo \
adler32.lo \
compress.lo \
- cpu_features.lo \
crc32.lo \
crc32_braid_comb.lo \
deflate.lo \
trees.lo \
uncompr.lo \
zutil.lo \
+ cpu_features.lo \
$(ARCH_SHARED_OBJS)
PIC_OBJG = \
#ifndef CPU_FEATURES_H_
#define CPU_FEATURES_H_
+#ifndef DISABLE_RUNTIME_CPU_DETECTION
+
#if defined(X86_FEATURES)
# include "arch/x86/x86_features.h"
#elif defined(ARM_FEATURES)
void cpu_check_features(struct cpu_features *features);
#endif
+
+#endif
BENCHMARK_ADLER32(c, adler32_c, 1);
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+BENCHMARK_ADLER32(native, native_adler32, 1);
+#else
+
#ifdef ARM_NEON
BENCHMARK_ADLER32(neon, adler32_neon, test_cpu_features.arm.has_neon);
#endif
#ifdef X86_AVX512VNNI
BENCHMARK_ADLER32(avx512_vnni, adler32_avx512_vnni, test_cpu_features.x86.has_avx512vnni);
#endif
+
+#endif
BENCHMARK_ADLER32_BASELINE_COPY(c, adler32_c, 1);
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+BENCHMARK_ADLER32_BASELINE_COPY(native, native_adler32, 1);
+#else
+
#ifdef ARM_NEON
/* If we inline this copy for neon, the function would go here */
//BENCHMARK_ADLER32_COPY(neon, adler32_neon, test_cpu_features.arm.has_neon);
BENCHMARK_ADLER32_BASELINE_COPY(avx512_vnni_baseline, adler32_avx512_vnni, test_cpu_features.x86.has_avx512vnni);
BENCHMARK_ADLER32_COPY(avx512_vnni, adler32_fold_copy_avx512_vnni, test_cpu_features.x86.has_avx512vnni);
#endif
+
+#endif
BENCHMARK_COMPARE256(c, compare256_c, 1);
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+BENCHMARK_COMPARE256(native, native_compare256, 1);
+#else
+
#if defined(UNALIGNED_OK) && BYTE_ORDER == LITTLE_ENDIAN
BENCHMARK_COMPARE256(unaligned_16, compare256_unaligned_16, 1);
#ifdef HAVE_BUILTIN_CTZ
#ifdef RISCV_RVV
BENCHMARK_COMPARE256(rvv, compare256_rvv, test_cpu_features.riscv.has_rvv);
#endif
+
+#endif
BENCHMARK_CRC32(braid, PREFIX(crc32_braid), 1);
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+BENCHMARK_CRC32(native, native_crc32, 1);
+#else
+
#ifdef ARM_ACLE
BENCHMARK_CRC32(acle, crc32_acle, test_cpu_features.arm.has_crc32);
#endif
/* CRC32 fold does a memory copy while hashing */
BENCHMARK_CRC32(vpclmulqdq, crc32_vpclmulqdq, (test_cpu_features.x86.has_pclmulqdq && test_cpu_features.x86.has_avx512 && test_cpu_features.x86.has_vpclmulqdq));
#endif
+
+#endif
# include "zbuild.h"
# include "../test_cpu_features.h"
+# ifndef DISABLE_RUNTIME_CPU_DETECTION
struct cpu_features test_cpu_features;
+# endif
}
#endif
int main(int argc, char** argv) {
#ifndef BUILD_ALT
+# ifndef DISABLE_RUNTIME_CPU_DETECTION
cpu_check_features(&test_cpu_features);
+# endif
#endif
::benchmark::Initialize(&argc, argv);
BENCHMARK_SLIDEHASH(c, slide_hash_c, 1);
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+BENCHMARK_SLIDEHASH(native, native_slide_hash, 1);
+#else
+
#ifdef ARM_SIMD
BENCHMARK_SLIDEHASH(armv6, slide_hash_armv6, test_cpu_features.arm.has_simd);
#endif
#ifdef X86_AVX2
BENCHMARK_SLIDEHASH(avx2, slide_hash_avx2, test_cpu_features.x86.has_avx2);
#endif
+
+#endif
TEST_ADLER32(c, adler32_c, 1)
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+TEST_ADLER32(native, native_adler32, 1)
+#else
+
#ifdef ARM_NEON
TEST_ADLER32(neon, adler32_neon, test_cpu_features.arm.has_neon)
#elif defined(POWER8_VSX)
#ifdef X86_AVX512VNNI
TEST_ADLER32(avx512_vnni, adler32_avx512_vnni, test_cpu_features.x86.has_avx512vnni)
#endif
+
+#endif
TEST_COMPARE256(c, compare256_c, 1)
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+TEST_COMPARE256(native, native_compare256, 1)
+#else
+
#if defined(UNALIGNED_OK) && BYTE_ORDER == LITTLE_ENDIAN
TEST_COMPARE256(unaligned_16, compare256_unaligned_16, 1)
#ifdef HAVE_BUILTIN_CTZ
#ifdef RISCV_RVV
TEST_COMPARE256(rvv, compare256_rvv, test_cpu_features.riscv.has_rvv)
#endif
+
+#endif
#ifndef TEST_CPU_FEATURES_H
#define TEST_CPU_FEATURES_H
-#include "cpu_features.h"
+#ifndef DISABLE_RUNTIME_CPU_DETECTION
+
+# include "cpu_features.h"
extern struct cpu_features test_cpu_features;
#endif
+
+#endif
TEST_CRC32(braid, PREFIX(crc32_braid), 1)
+#ifdef DISABLE_RUNTIME_CPU_DETECTION
+TEST_CRC32(native, native_crc32, 1)
+#else
+
#ifdef ARM_ACLE
TEST_CRC32(acle, crc32_acle, test_cpu_features.arm.has_crc32)
#endif
#ifdef X86_VPCLMULQDQ_CRC
TEST_CRC32(vpclmulqdq, crc32_vpclmulqdq, (test_cpu_features.x86.has_pclmulqdq && test_cpu_features.x86.has_avx512 && test_cpu_features.x86.has_vpclmulqdq))
#endif
+
+#endif
extern "C" {
# include "zbuild.h"
# include "test_cpu_features.h"
-
+# ifndef DISABLE_RUNTIME_CPU_DETECTION
struct cpu_features test_cpu_features;
+# endif
}
GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from %s\n", __FILE__);
+#ifndef DISABLE_RUNTIME_CPU_DETECTION
cpu_check_features(&test_cpu_features);
+#endif
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}