Set SIMDJSON_BUILTIN_IMPLEMENTATION to minimum supported
This commit is contained in:
parent
209a2e8fc3
commit
b5a328e0ca
|
@ -94,23 +94,42 @@ else()
|
||||||
target_compile_options(simdjson-internal-flags INTERFACE -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
|
target_compile_options(simdjson-internal-flags INTERFACE -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
# Optional flags
|
# Optional flags
|
||||||
|
#
|
||||||
|
|
||||||
|
# Implementation selection
|
||||||
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
|
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_HASWELL)
|
if(NOT SIMDJSON_IMPLEMENTATION_HASWELL)
|
||||||
|
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_HASWELL is deprecated. Use SIMDJSON_IMPLEMENTATION=haswell or SIMDJSON_IMPLEMENTATION=-haswell instead.")
|
||||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
|
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
|
||||||
endif()
|
endif()
|
||||||
option(SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON)
|
option(SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON)
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_WESTMERE)
|
if(NOT SIMDJSON_IMPLEMENTATION_WESTMERE)
|
||||||
|
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_WESTMERE is deprecated. SIMDJSON_IMPLEMENTATION=-westmere instead.")
|
||||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
|
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
|
||||||
endif()
|
endif()
|
||||||
option(SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON)
|
option(SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON)
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_ARM64)
|
if(NOT SIMDJSON_IMPLEMENTATION_ARM64)
|
||||||
|
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_ARM64 is deprecated. Use SIMDJSON_IMPLEMENTATION=-arm64 instead.")
|
||||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
|
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
|
||||||
endif()
|
endif()
|
||||||
option(SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON)
|
option(SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON)
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_FALLBACK)
|
if(NOT SIMDJSON_IMPLEMENTATION_FALLBACK)
|
||||||
|
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_FALLBACK is deprecated. Use SIMDJSON_IMPLEMENTATION=-fallback instead.")
|
||||||
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
|
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
|
||||||
endif()
|
endif()
|
||||||
|
# e.g. SIMDJSON_IMPLEMENTATION="haswell westmere -fallback"
|
||||||
|
set(SIMDJSON_IMPLEMENTATION "" CACHE STRING "Implementations to include/exclude: space separated list of architectures (haswell/westmere/arm64/fallback). Prepend with - to force an implementation off (e.g. -haswell). Defaults to compile-time detection.")
|
||||||
|
foreach(implementation ${SIMDJSON_IMPLEMENTATION})
|
||||||
|
string(TOUPPER ${implementation} implementation_upper)
|
||||||
|
if(string(REGEX MATCH "^-(.*)" actual_implementation ${implementation_upper}))
|
||||||
|
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_${actual_implementation} 0)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(simdjson-internal-flags INTERFACE SIMDJSON_IMPLEMENTATION_${implementation_upper} 1)
|
||||||
|
endif()
|
||||||
|
endforeach(implementation)
|
||||||
|
|
||||||
|
|
||||||
option(SIMDJSON_BASH "Allow usage of bash within CMake" ON)
|
option(SIMDJSON_BASH "Allow usage of bash within CMake" ON)
|
||||||
|
|
||||||
|
|
|
@ -70,18 +70,6 @@ use a 64-bit target such as x64 or 64-bit ARM.")
|
||||||
#define STRINGIFY_IMPLEMENTATION_(a) #a
|
#define STRINGIFY_IMPLEMENTATION_(a) #a
|
||||||
#define STRINGIFY(a) STRINGIFY_IMPLEMENTATION_(a)
|
#define STRINGIFY(a) STRINGIFY_IMPLEMENTATION_(a)
|
||||||
|
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_FALLBACK
|
|
||||||
#define SIMDJSON_IMPLEMENTATION_FALLBACK 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SIMDJSON_IS_ARM64
|
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_ARM64
|
|
||||||
#define SIMDJSON_IMPLEMENTATION_ARM64 1
|
|
||||||
#endif
|
|
||||||
#define SIMDJSON_IMPLEMENTATION_HASWELL 0
|
|
||||||
#define SIMDJSON_IMPLEMENTATION_WESTMERE 0
|
|
||||||
#endif // SIMDJSON_IS_ARM64
|
|
||||||
|
|
||||||
// Our fast kernels require 64-bit systems.
|
// Our fast kernels require 64-bit systems.
|
||||||
//
|
//
|
||||||
// On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
|
// On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
|
||||||
|
@ -91,16 +79,93 @@ use a 64-bit target such as x64 or 64-bit ARM.")
|
||||||
//
|
//
|
||||||
// The simdjson users should still have the fallback kernel. It is
|
// The simdjson users should still have the fallback kernel. It is
|
||||||
// slower, but it should run everywhere.
|
// slower, but it should run everywhere.
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enable valid runtime implementations, and select SIMDJSON_BUILTIN_IMPLEMENTATION
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// ARM 64-bit (NEON / Other)
|
||||||
|
//
|
||||||
|
#if SIMDJSON_IS_ARM64
|
||||||
|
// Default ARM64 to on: it could be selected at runtime.
|
||||||
|
#ifndef SIMDJSON_IMPLEMENTATION_ARM64
|
||||||
|
#define SIMDJSON_IMPLEMENTATION_ARM64 1
|
||||||
|
#endif
|
||||||
|
#if __ARM_NEON
|
||||||
|
//
|
||||||
|
// NEON
|
||||||
|
//
|
||||||
|
// We're compiled natively for NEON, so arm64 will *always* work (the program is going
|
||||||
|
// to fail in other ways if it's not run on a machine supporting NEON).
|
||||||
|
//
|
||||||
|
// Set builtin to arm64, and leave fallback defaulted to off.
|
||||||
|
// It can still be enabled with SIMDJSON_IMPLEMENTATION_XXX flags, though it's unclear why one
|
||||||
|
// would do so).
|
||||||
|
//
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION arm64
|
||||||
|
#endif
|
||||||
|
#endif // SIMDJSON_IS_ARM64
|
||||||
|
|
||||||
|
//
|
||||||
|
// Intel 64-bit (Haswell / Westmere / Other)
|
||||||
|
//
|
||||||
#if SIMDJSON_IS_X86_64
|
#if SIMDJSON_IS_X86_64
|
||||||
|
|
||||||
|
// Default Haswell to on: it could be selected at runtime.
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_HASWELL
|
#ifndef SIMDJSON_IMPLEMENTATION_HASWELL
|
||||||
#define SIMDJSON_IMPLEMENTATION_HASWELL 1
|
#define SIMDJSON_IMPLEMENTATION_HASWELL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __AVX2__ && __BMI__ && __PCLMUL__ && __LZCNT__ && SIMDJSON_IMPLEMENTATION_HASWELL
|
||||||
|
//
|
||||||
|
// Haswell
|
||||||
|
//
|
||||||
|
// We're compiled natively for Haswell, so Haswell will *always* work (more specifically, the
|
||||||
|
// program is going to fail in other ways if it's not run on a machine supporting AVX2).
|
||||||
|
//
|
||||||
|
// Set builtin to haswell, and leave westmere and fallback defaulted to off.
|
||||||
|
// They can still be enabled with SIMDJSON_IMPLEMENTATION_XXX flags, though it's unclear why one
|
||||||
|
// would do so).
|
||||||
|
//
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION haswell
|
||||||
|
#else // Haswell
|
||||||
|
|
||||||
|
// We're not compiled natively for Haswell. Default Westmere to on: it could be selected at runtime.
|
||||||
#ifndef SIMDJSON_IMPLEMENTATION_WESTMERE
|
#ifndef SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||||
#define SIMDJSON_IMPLEMENTATION_WESTMERE 1
|
#define SIMDJSON_IMPLEMENTATION_WESTMERE 1
|
||||||
#endif
|
#endif
|
||||||
#define SIMDJSON_IMPLEMENTATION_ARM64 0
|
#if __SSE4_2__ && __PCLMUL__ && SIMDJSON_IMPLEMENTATION_WESTMERE
|
||||||
|
//
|
||||||
|
// Westmere
|
||||||
|
//
|
||||||
|
// We're compiled natively for Westmere, so Westmere will *always* work (the program is going
|
||||||
|
// to fail in other ways if it's not run on a machine supporting SSE4.2).
|
||||||
|
//
|
||||||
|
// Set builtin to westmere, and leave fallback defaulted to off.
|
||||||
|
// It can still be enabled with SIMDJSON_IMPLEMENTATION_XXX flags, though it's unclear why one
|
||||||
|
// would do so).
|
||||||
|
//
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION westmere
|
||||||
|
#endif // Westmere
|
||||||
|
#endif // Haswell
|
||||||
#endif // SIMDJSON_IS_X86_64
|
#endif // SIMDJSON_IS_X86_64
|
||||||
|
|
||||||
|
//
|
||||||
|
// If no specific builtin architecture was discovered, set builtin to fallback and make sure it's
|
||||||
|
// enabled.
|
||||||
|
//
|
||||||
|
#ifndef SIMDJSON_BUILTIN_IMPLEMENTATION
|
||||||
|
#ifndef SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||||
|
#define SIMDJSON_IMPLEMENTATION_FALLBACK 1
|
||||||
|
#endif
|
||||||
|
#if SIMDJSON_IMPLEMENTATION_FALLBACK
|
||||||
|
#define SIMDJSON_BUILTIN_IMPLEMENTATION fallback
|
||||||
|
#else
|
||||||
|
#error "fallback architecture is disabled, but is compiled with flags that allow it to run on machines that require fallback."
|
||||||
|
#endif
|
||||||
|
#endif // SIMDJSON_BUILTIN_IMPLEMENTATION
|
||||||
|
|
||||||
// We are going to use runtime dispatch.
|
// We are going to use runtime dispatch.
|
||||||
#ifdef SIMDJSON_IS_X86_64
|
#ifdef SIMDJSON_IS_X86_64
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
|
Loading…
Reference in New Issue