diff --git a/.drone.yml b/.drone.yml index 561c60a83..90236f481 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ steps: CC: gcc CXX: g++ BUILD_FLAGS: -- -j - CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=cascadelake;haswell;westmere;fallback + CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly commands: - echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list @@ -19,7 +19,7 @@ steps: - cmake $CMAKE_FLAGS .. - cmake --build . $BUILD_FLAGS - ctest $CTEST_FLAGS -L acceptance -LE per_implementation - - SIMDJSON_FORCE_IMPLEMENTATION=cascadelake ctest $CTEST_FLAGS -L per_implementation + - SIMDJSON_FORCE_IMPLEMENTATION=icelake ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation @@ -36,7 +36,7 @@ steps: CC: clang-6.0 CXX: clang++-6.0 BUILD_FLAGS: -- -j - CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=cascadelake;haswell;westmere;fallback + CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly commands: - mkdir build @@ -44,7 +44,7 @@ steps: - cmake $CMAKE_FLAGS .. - cmake --build . $BUILD_FLAGS - ctest $CTEST_FLAGS -L acceptance -LE per_implementation - - SIMDJSON_FORCE_IMPLEMENTATION=cascadelake ctest $CTEST_FLAGS -L per_implementation + - SIMDJSON_FORCE_IMPLEMENTATION=icelake ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation @@ -102,7 +102,7 @@ steps: CC: gcc CXX: g++ BUILD_FLAGS: -- -j - CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=cascadelake;haswell;westmere;fallback + CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly commands: - echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list @@ -113,7 +113,7 @@ steps: - cmake $CMAKE_FLAGS .. - cmake --build . $BUILD_FLAGS - ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation - - SIMDJSON_FORCE_IMPLEMENTATION=cascadelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation + - SIMDJSON_FORCE_IMPLEMENTATION=icelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation @@ -129,7 +129,7 @@ steps: environment: CC: clang-9 CXX: clang++-9 - CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION=cascadelake;haswell;westmere;fallback + CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback BUILD_FLAGS: -- -j CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly commands: @@ -138,7 +138,7 @@ steps: - cmake $CMAKE_FLAGS .. - cmake --build . $BUILD_FLAGS - ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation - - SIMDJSON_FORCE_IMPLEMENTATION=cascadelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation + - SIMDJSON_FORCE_IMPLEMENTATION=icelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation - SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation diff --git a/cmake/implementation-flags.cmake b/cmake/implementation-flags.cmake index e1217c6a6..88e937bf2 100644 --- a/cmake/implementation-flags.cmake +++ b/cmake/implementation-flags.cmake @@ -1,7 +1,7 @@ # # Implementation selection # -set(SIMDJSON_ALL_IMPLEMENTATIONS fallback westmere haswell cascadelake arm64 ppc64) +set(SIMDJSON_ALL_IMPLEMENTATIONS fallback westmere haswell icelake arm64 ppc64) set( SIMDJSON_IMPLEMENTATION "" @@ -15,7 +15,7 @@ set( SIMDJSON_EXCLUDE_IMPLEMENTATION "" CACHE STRING "\ Semicolon-separated list of implementations to exclude \ -(cascadelake/haswell/westmere/arm64/ppc64/fallback). By default, excludes any \ +(icelake/haswell/westmere/arm64/ppc64/fallback). By default, excludes any \ implementations that are unsupported at compile time or cannot be selected at \ runtime." ) diff --git a/include/simdjson/builtin.h b/include/simdjson/builtin.h index 6100dea60..c0c04a557 100644 --- a/include/simdjson/builtin.h +++ b/include/simdjson/builtin.h @@ -5,8 +5,8 @@ // Determine the best builtin implementation #ifndef SIMDJSON_BUILTIN_IMPLEMENTATION -#if SIMDJSON_CAN_ALWAYS_RUN_CASCADELAKE -#define SIMDJSON_BUILTIN_IMPLEMENTATION cascadelake +#if SIMDJSON_CAN_ALWAYS_RUN_ICELAKE +#define SIMDJSON_BUILTIN_IMPLEMENTATION icelake #elif SIMDJSON_CAN_ALWAYS_RUN_HASWELL #define SIMDJSON_BUILTIN_IMPLEMENTATION haswell #elif SIMDJSON_CAN_ALWAYS_RUN_WESTMERE diff --git a/include/simdjson/cascadelake.h b/include/simdjson/cascadelake.h deleted file mode 100644 index 68de2e90e..000000000 --- a/include/simdjson/cascadelake.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef SIMDJSON_CASCADELAKE_H -#define SIMDJSON_CASCADELAKE_H - -#include "simdjson/implementation-base.h" - -#if SIMDJSON_IMPLEMENTATION_CASCADELAKE - -#if SIMDJSON_CAN_ALWAYS_RUN_CASCADELAKE -#define SIMDJSON_TARGET_CASCADELAKE -#define SIMDJSON_UNTARGET_CASCADELAKE -#else -#define SIMDJSON_TARGET_CASCADELAKE SIMDJSON_TARGET_REGION("avx512f,avx512dq,avx512cd,avx512bw,avx512vl,avx2,bmi,pclmul,lzcnt") -#define SIMDJSON_UNTARGET_CASCADELAKE SIMDJSON_UNTARGET_REGION -#endif - -namespace simdjson { -/** - * Implementation for Cascadelake (Intel AVX512). - */ -namespace cascadelake { -} // namespace cascadelake -} // namespace simdjson - -// -// These two need to be included outside SIMDJSON_TARGET_CASCADELAKE -// -#include "simdjson/cascadelake/implementation.h" -#include "simdjson/cascadelake/intrinsics.h" - -// -// The rest need to be inside the region -// -#include "simdjson/cascadelake/begin.h" - -// Declarations -#include "simdjson/generic/dom_parser_implementation.h" -#include "simdjson/cascadelake/bitmanipulation.h" -#include "simdjson/cascadelake/bitmask.h" -#include "simdjson/cascadelake/simd.h" -#include "simdjson/generic/jsoncharutils.h" -#include "simdjson/generic/atomparsing.h" -#include "simdjson/cascadelake/stringparsing.h" -#include "simdjson/cascadelake/numberparsing.h" -#include "simdjson/cascadelake/end.h" - -#endif // SIMDJSON_IMPLEMENTATION_CASCADELAKE -#endif // SIMDJSON_CASCADELAKE_H diff --git a/include/simdjson/cascadelake/begin.h b/include/simdjson/cascadelake/begin.h deleted file mode 100644 index 8f5bd2087..000000000 --- a/include/simdjson/cascadelake/begin.h +++ /dev/null @@ -1,2 +0,0 @@ -#define SIMDJSON_IMPLEMENTATION cascadelake -SIMDJSON_TARGET_CASCADELAKE diff --git a/include/simdjson/icelake.h b/include/simdjson/icelake.h new file mode 100644 index 000000000..46af87062 --- /dev/null +++ b/include/simdjson/icelake.h @@ -0,0 +1,47 @@ +#ifndef SIMDJSON_ICELAKE_H +#define SIMDJSON_ICELAKE_H + +#include "simdjson/implementation-base.h" + +#if SIMDJSON_IMPLEMENTATION_ICELAKE + +#if SIMDJSON_CAN_ALWAYS_RUN_ICELAKE +#define SIMDJSON_TARGET_ICELAKE +#define SIMDJSON_UNTARGET_ICELAKE +#else +#define SIMDJSON_TARGET_ICELAKE SIMDJSON_TARGET_REGION("avx512f,avx512dq,avx512cd,avx512bw,avx512vl,avx2,bmi,pclmul,lzcnt") +#define SIMDJSON_UNTARGET_ICELAKE SIMDJSON_UNTARGET_REGION +#endif + +namespace simdjson { +/** + * Implementation for Icelake (Intel AVX512). + */ +namespace icelake { +} // namespace icelake +} // namespace simdjson + +// +// These two need to be included outside SIMDJSON_TARGET_ICELAKE +// +#include "simdjson/icelake/implementation.h" +#include "simdjson/icelake/intrinsics.h" + +// +// The rest need to be inside the region +// +#include "simdjson/icelake/begin.h" + +// Declarations +#include "simdjson/generic/dom_parser_implementation.h" +#include "simdjson/icelake/bitmanipulation.h" +#include "simdjson/icelake/bitmask.h" +#include "simdjson/icelake/simd.h" +#include "simdjson/generic/jsoncharutils.h" +#include "simdjson/generic/atomparsing.h" +#include "simdjson/icelake/stringparsing.h" +#include "simdjson/icelake/numberparsing.h" +#include "simdjson/icelake/end.h" + +#endif // SIMDJSON_IMPLEMENTATION_ICELAKE +#endif // SIMDJSON_ICELAKE_H diff --git a/include/simdjson/icelake/begin.h b/include/simdjson/icelake/begin.h new file mode 100644 index 000000000..2f5c07063 --- /dev/null +++ b/include/simdjson/icelake/begin.h @@ -0,0 +1,2 @@ +#define SIMDJSON_IMPLEMENTATION icelake +SIMDJSON_TARGET_ICELAKE diff --git a/include/simdjson/cascadelake/bitmanipulation.h b/include/simdjson/icelake/bitmanipulation.h similarity index 93% rename from include/simdjson/cascadelake/bitmanipulation.h rename to include/simdjson/icelake/bitmanipulation.h index a50d31114..51a8aa340 100644 --- a/include/simdjson/cascadelake/bitmanipulation.h +++ b/include/simdjson/icelake/bitmanipulation.h @@ -1,5 +1,5 @@ -#ifndef SIMDJSON_CASCADELAKE_BITMANIPULATION_H -#define SIMDJSON_CASCADELAKE_BITMANIPULATION_H +#ifndef SIMDJSON_ICELAKE_BITMANIPULATION_H +#define SIMDJSON_ICELAKE_BITMANIPULATION_H namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { @@ -58,4 +58,4 @@ simdjson_really_inline bool add_overflow(uint64_t value1, uint64_t value2, } // namespace SIMDJSON_IMPLEMENTATION } // namespace simdjson -#endif // SIMDJSON_CASCADELAKE_BITMANIPULATION_H +#endif // SIMDJSON_ICELAKE_BITMANIPULATION_H diff --git a/include/simdjson/cascadelake/bitmask.h b/include/simdjson/icelake/bitmask.h similarity index 83% rename from include/simdjson/cascadelake/bitmask.h rename to include/simdjson/icelake/bitmask.h index 2f633a93e..7aead6faf 100644 --- a/include/simdjson/cascadelake/bitmask.h +++ b/include/simdjson/icelake/bitmask.h @@ -1,5 +1,5 @@ -#ifndef SIMDJSON_CASCADELAKE_BITMASK_H -#define SIMDJSON_CASCADELAKE_BITMASK_H +#ifndef SIMDJSON_ICELAKE_BITMASK_H +#define SIMDJSON_ICELAKE_BITMASK_H namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { @@ -22,4 +22,4 @@ simdjson_really_inline uint64_t prefix_xor(const uint64_t bitmask) { } // namespace SIMDJSON_IMPLEMENTATION } // namespace simdjson -#endif // SIMDJSON_CASCADELAKE_BITMASK_H +#endif // SIMDJSON_ICELAKE_BITMASK_H diff --git a/include/simdjson/cascadelake/end.h b/include/simdjson/icelake/end.h similarity index 50% rename from include/simdjson/cascadelake/end.h rename to include/simdjson/icelake/end.h index 76c651d87..b32c1075d 100644 --- a/include/simdjson/cascadelake/end.h +++ b/include/simdjson/icelake/end.h @@ -1,2 +1,2 @@ -SIMDJSON_UNTARGET_CASCADELAKE +SIMDJSON_UNTARGET_ICELAKE #undef SIMDJSON_IMPLEMENTATION diff --git a/include/simdjson/cascadelake/implementation.h b/include/simdjson/icelake/implementation.h similarity index 79% rename from include/simdjson/cascadelake/implementation.h rename to include/simdjson/icelake/implementation.h index 079c09584..87e9f05f9 100644 --- a/include/simdjson/cascadelake/implementation.h +++ b/include/simdjson/icelake/implementation.h @@ -1,20 +1,20 @@ -#ifndef SIMDJSON_CASCADELAKE_IMPLEMENTATION_H -#define SIMDJSON_CASCADELAKE_IMPLEMENTATION_H +#ifndef SIMDJSON_ICELAKE_IMPLEMENTATION_H +#define SIMDJSON_ICELAKE_IMPLEMENTATION_H #include "simdjson/implementation.h" -// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_CASCADELAKE +// The constructor may be executed on any host, so we take care not to use SIMDJSON_TARGET_ICELAKE namespace simdjson { -namespace cascadelake { +namespace icelake { using namespace simdjson; class implementation final : public simdjson::implementation { public: simdjson_really_inline implementation() : simdjson::implementation( - "cascadelake", + "icelake", "Intel/AMD AVX512", - internal::instruction_set::AVX2 | internal::instruction_set::PCLMULQDQ | internal::instruction_set::BMI1 | internal::instruction_set::BMI2 | internal::instruction_set::AVX512F | internal::instruction_set::AVX512DQ | internal::instruction_set::AVX512CD | internal::instruction_set::AVX512BW | internal::instruction_set::AVX512VL + internal::instruction_set::AVX2 | internal::instruction_set::PCLMULQDQ | internal::instruction_set::BMI1 | internal::instruction_set::BMI2 | internal::instruction_set::AVX512F | internal::instruction_set::AVX512DQ | internal::instruction_set::AVX512CD | internal::instruction_set::AVX512BW | internal::instruction_set::AVX512VL | internal::instruction_set::AVX512VBMI2 ) {} simdjson_warn_unused error_code create_dom_parser_implementation( size_t capacity, @@ -25,7 +25,7 @@ public: simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) const noexcept final; }; -} // namespace cascadelake +} // namespace icelake } // namespace simdjson -#endif // SIMDJSON_CASCADELAKE_IMPLEMENTATION_H +#endif // SIMDJSON_ICELAKE_IMPLEMENTATION_H diff --git a/include/simdjson/cascadelake/intrinsics.h b/include/simdjson/icelake/intrinsics.h similarity index 90% rename from include/simdjson/cascadelake/intrinsics.h rename to include/simdjson/icelake/intrinsics.h index cc8d5f691..31935c0df 100644 --- a/include/simdjson/cascadelake/intrinsics.h +++ b/include/simdjson/icelake/intrinsics.h @@ -1,5 +1,5 @@ -#ifndef SIMDJSON_CASCADELAKE_INTRINSICS_H -#define SIMDJSON_CASCADELAKE_INTRINSICS_H +#ifndef SIMDJSON_ICELAKE_INTRINSICS_H +#define SIMDJSON_ICELAKE_INTRINSICS_H #include "simdjson/base.h" @@ -41,12 +41,12 @@ // has it as a macro. #ifndef _blsr_u64 // we roll our own -SIMDJSON_TARGET_CASCADELAKE +SIMDJSON_TARGET_ICELAKE static simdjson_really_inline uint64_t _blsr_u64(uint64_t n) { return (n - 1) & n; } -SIMDJSON_UNTARGET_CASCADELAKE +SIMDJSON_UNTARGET_ICELAKE #endif // _blsr_u64 #endif // SIMDJSON_CLANG_VISUAL_STUDIO -#endif // SIMDJSON_CASCADELAKE_INTRINSICS_H +#endif // SIMDJSON_ICELAKE_INTRINSICS_H diff --git a/include/simdjson/cascadelake/numberparsing.h b/include/simdjson/icelake/numberparsing.h similarity index 89% rename from include/simdjson/cascadelake/numberparsing.h rename to include/simdjson/icelake/numberparsing.h index c30757563..a88ced593 100644 --- a/include/simdjson/cascadelake/numberparsing.h +++ b/include/simdjson/icelake/numberparsing.h @@ -1,5 +1,5 @@ -#ifndef SIMDJSON_CASCADELAKE_NUMBERPARSING_H -#define SIMDJSON_CASCADELAKE_NUMBERPARSING_H +#ifndef SIMDJSON_ICELAKE_NUMBERPARSING_H +#define SIMDJSON_ICELAKE_NUMBERPARSING_H namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { @@ -31,4 +31,4 @@ static simdjson_really_inline uint32_t parse_eight_digits_unrolled(const uint8_t #include "simdjson/generic/numberparsing.h" -#endif // SIMDJSON_CASCADELAKE_NUMBERPARSING_H +#endif // SIMDJSON_ICELAKE_NUMBERPARSING_H diff --git a/include/simdjson/cascadelake/simd.h b/include/simdjson/icelake/simd.h similarity index 98% rename from include/simdjson/cascadelake/simd.h rename to include/simdjson/icelake/simd.h index 3d0fe128f..1e70fc5f9 100644 --- a/include/simdjson/cascadelake/simd.h +++ b/include/simdjson/icelake/simd.h @@ -1,5 +1,5 @@ -#ifndef SIMDJSON_CASCADELAKE_SIMD_H -#define SIMDJSON_CASCADELAKE_SIMD_H +#ifndef SIMDJSON_ICELAKE_SIMD_H +#define SIMDJSON_ICELAKE_SIMD_H #include "simdjson/internal/simdprune_tables.h" @@ -346,7 +346,7 @@ namespace simd { template struct simd8x64 { static constexpr int NUM_CHUNKS = 64 / sizeof(simd8); - static_assert(NUM_CHUNKS == 1, "Cascadelake kernel should use one register per 64-byte block."); + static_assert(NUM_CHUNKS == 1, "Icelake kernel should use one register per 64-byte block."); const simd8 chunks[NUM_CHUNKS]; simd8x64(const simd8x64& o) = delete; // no copy allowed @@ -398,4 +398,4 @@ namespace simd { } // namespace SIMDJSON_IMPLEMENTATION } // namespace simdjson -#endif // SIMDJSON_CASCADELAKE_SIMD_H +#endif // SIMDJSON_ICELAKE_SIMD_H diff --git a/include/simdjson/cascadelake/stringparsing.h b/include/simdjson/icelake/stringparsing.h similarity index 87% rename from include/simdjson/cascadelake/stringparsing.h rename to include/simdjson/icelake/stringparsing.h index 44f6fe1c0..13feed474 100644 --- a/include/simdjson/cascadelake/stringparsing.h +++ b/include/simdjson/icelake/stringparsing.h @@ -1,9 +1,9 @@ -#ifndef SIMDJSON_CASCADELAKE_STRINGPARSING_H -#define SIMDJSON_CASCADELAKE_STRINGPARSING_H +#ifndef SIMDJSON_ICELAKE_STRINGPARSING_H +#define SIMDJSON_ICELAKE_STRINGPARSING_H #include "simdjson/base.h" -#include "simdjson/cascadelake/simd.h" -#include "simdjson/cascadelake/bitmanipulation.h" +#include "simdjson/icelake/simd.h" +#include "simdjson/icelake/bitmanipulation.h" namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { @@ -45,4 +45,4 @@ simdjson_really_inline backslash_and_quote backslash_and_quote::copy_and_find(co #include "simdjson/generic/stringparsing.h" -#endif // SIMDJSON_CASCADELAKE_STRINGPARSING_H +#endif // SIMDJSON_ICELAKE_STRINGPARSING_H diff --git a/include/simdjson/implementations.h b/include/simdjson/implementations.h index 0ea952734..713adda42 100644 --- a/include/simdjson/implementations.h +++ b/include/simdjson/implementations.h @@ -14,19 +14,19 @@ #define SIMDJSON_CAN_ALWAYS_RUN_ARM64 SIMDJSON_IMPLEMENTATION_ARM64 && SIMDJSON_IS_ARM64 -// Default Cascadelake to on if this is x86-64. Even if we're not compiled for it, it could be selected +// Default Icelake to on if this is x86-64. Even if we're not compiled for it, it could be selected // at runtime. -#ifndef SIMDJSON_IMPLEMENTATION_CASCADELAKE -#define SIMDJSON_IMPLEMENTATION_CASCADELAKE ((SIMDJSON_IS_X86_64) && (SIMDJSON_AVX512_ALLOWED)) +#ifndef SIMDJSON_IMPLEMENTATION_ICELAKE +#define SIMDJSON_IMPLEMENTATION_ICELAKE ((SIMDJSON_IS_X86_64) && (SIMDJSON_AVX512_ALLOWED)) #endif #ifdef _MSC_VER // To see why (__BMI__) && (__PCLMUL__) && (__LZCNT__) are not part of this next line, see // https://github.com/simdjson/simdjson/issues/1247 -#define SIMDJSON_CAN_ALWAYS_RUN_CASCADELAKE ((SIMDJSON_IS_X86_64) && (__AVX2__) && (__AVX512F__) && (__AVX512DQ__) && (__AVX512CD__) && (__AVX512BW__) && (__AVX512VL__)) +#define SIMDJSON_CAN_ALWAYS_RUN_ICELAKE ((SIMDJSON_IS_X86_64) && (__AVX2__) && (__AVX512F__) && (__AVX512DQ__) && (__AVX512CD__) && (__AVX512BW__) && (__AVX512VL__) && (__AVX512VBMI2__)) #else -#define SIMDJSON_CAN_ALWAYS_RUN_CASCADELAKE ((SIMDJSON_IS_X86_64) && (__AVX2__) && (__BMI__) && (__PCLMUL__) && (__LZCNT__) && (__AVX512F__) && (__AVX512DQ__) && (__AVX512CD__) && (__AVX512BW__) && (__AVX512VL__)) +#define SIMDJSON_CAN_ALWAYS_RUN_ICELAKE ((SIMDJSON_IS_X86_64) && (__AVX2__) && (__BMI__) && (__PCLMUL__) && (__LZCNT__) && (__AVX512F__) && (__AVX512DQ__) && (__AVX512CD__) && (__AVX512BW__) && (__AVX512VL__) && (__AVX512VBMI2__)) #endif // Default Haswell to on if this is x86-64. Even if we're not compiled for it, it could be selected @@ -65,7 +65,7 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS // Implementations #include "simdjson/arm64.h" #include "simdjson/fallback.h" -#include "simdjson/cascadelake.h" +#include "simdjson/icelake.h" #include "simdjson/haswell.h" #include "simdjson/ppc64.h" #include "simdjson/westmere.h" diff --git a/include/simdjson/internal/isadetection.h b/include/simdjson/internal/isadetection.h index 24586b4a2..17adb43f3 100644 --- a/include/simdjson/internal/isadetection.h +++ b/include/simdjson/internal/isadetection.h @@ -75,6 +75,7 @@ enum instruction_set { AVX512CD = 0x2000, AVX512BW = 0x4000, AVX512VL = 0x8000, + AVX512VBMI2 = 0x10000 }; #if defined(__PPC64__) @@ -104,19 +105,20 @@ static inline uint32_t detect_supported_architectures() { namespace { // Can be found on Intel ISA Reference for CPUID -constexpr uint32_t cpuid_avx2_bit = 1 << 5; ///< @private Bit 5 of EBX for EAX=0x7 -constexpr uint32_t cpuid_bmi1_bit = 1 << 3; ///< @private bit 3 of EBX for EAX=0x7 -constexpr uint32_t cpuid_bmi2_bit = 1 << 8; ///< @private bit 8 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512f_bit = 1 << 16; ///< @private bit 16 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512dq_bit = 1 << 17; ///< @private bit 17 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512ifma_bit = 1 << 21; ///< @private bit 21 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512pf_bit = 1 << 26; ///< @private bit 26 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512er_bit = 1 << 27; ///< @private bit 27 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512cd_bit = 1 << 28; ///< @private bit 28 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512bw_bit = 1 << 30; ///< @private bit 30 of EBX for EAX=0x7 -constexpr uint32_t cpuid_avx512vl_bit = 1 << 31; ///< @private bit 31 of EBX for EAX=0x7 -constexpr uint32_t cpuid_sse42_bit = 1 << 20; ///< @private bit 20 of ECX for EAX=0x1 -constexpr uint32_t cpuid_pclmulqdq_bit = 1 << 1; ///< @private bit 1 of ECX for EAX=0x1 +constexpr uint32_t cpuid_avx2_bit = 1 << 5; ///< @private Bit 5 of EBX for EAX=0x7 +constexpr uint32_t cpuid_bmi1_bit = 1 << 3; ///< @private bit 3 of EBX for EAX=0x7 +constexpr uint32_t cpuid_bmi2_bit = 1 << 8; ///< @private bit 8 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512f_bit = 1 << 16; ///< @private bit 16 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512dq_bit = 1 << 17; ///< @private bit 17 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512ifma_bit = 1 << 21; ///< @private bit 21 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512pf_bit = 1 << 26; ///< @private bit 26 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512er_bit = 1 << 27; ///< @private bit 27 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512cd_bit = 1 << 28; ///< @private bit 28 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512bw_bit = 1 << 30; ///< @private bit 30 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512vl_bit = 1 << 31; ///< @private bit 31 of EBX for EAX=0x7 +constexpr uint32_t cpuid_avx512vbmi2_bit = 1 << 6; ///< @private bit 6 of ECX for EAX=0x7 +constexpr uint32_t cpuid_sse42_bit = 1 << 20; ///< @private bit 20 of ECX for EAX=0x1 +constexpr uint32_t cpuid_pclmulqdq_bit = 1 << 1; ///< @private bit 1 of ECX for EAX=0x1 } @@ -194,6 +196,10 @@ static inline uint32_t detect_supported_architectures() { host_isa |= instruction_set::AVX512VL; } + if (ecx & cpuid_avx512vbmi2_bit) { + host_isa |= instruction_set::AVX512VBMI2; + } + // EBX for EAX=0x1 eax = 0x1; cpuid(&eax, &ebx, &ecx, &edx); diff --git a/include/simdjson/portability.h b/include/simdjson/portability.h index 341a0fde9..af896b5d7 100644 --- a/include/simdjson/portability.h +++ b/include/simdjson/portability.h @@ -41,9 +41,6 @@ #if defined(__x86_64__) || defined(_M_AMD64) #define SIMDJSON_IS_X86_64 1 -#if ((__AVX512F__) && (__AVX512DQ__) && (__AVX512CD__) && (__AVX512BW__) && (__AVX512VL__)) -#define SIMDJSON_IS_AVX512 1 -#endif #elif defined(__aarch64__) || defined(_M_ARM64) #define SIMDJSON_IS_ARM64 1 #elif defined(__PPC64__) || defined(_M_PPC64) diff --git a/src/generic/stage1/utf8_lookup4_algorithm.h b/src/generic/stage1/utf8_lookup4_algorithm.h index 6f08748db..7d44419aa 100644 --- a/src/generic/stage1/utf8_lookup4_algorithm.h +++ b/src/generic/stage1/utf8_lookup4_algorithm.h @@ -111,7 +111,7 @@ using namespace simd; simdjson_really_inline simd8 is_incomplete(const simd8 input) { // If the previous input's last 3 bytes match this, they're too short (they ended at EOF): // ... 1111____ 111_____ 11______ -#if SIMDJSON_IMPLEMENTATION_CASCADELAKE +#if SIMDJSON_IMPLEMENTATION_ICELAKE static const uint8_t max_array[64] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, diff --git a/src/cascadelake/dom_parser_implementation.cpp b/src/icelake/dom_parser_implementation.cpp similarity index 96% rename from src/cascadelake/dom_parser_implementation.cpp rename to src/icelake/dom_parser_implementation.cpp index bc4f1e55c..eea29c2c6 100644 --- a/src/cascadelake/dom_parser_implementation.cpp +++ b/src/icelake/dom_parser_implementation.cpp @@ -1,4 +1,4 @@ -#include "simdjson/cascadelake/begin.h" +#include "simdjson/icelake/begin.h" // // Stage 1 @@ -172,17 +172,17 @@ simdjson_really_inline uint64_t json_string_scanner::find_escaped(uint64_t backs } // unnamed namespace simdjson_warn_unused error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept { - return cascadelake::stage1::json_minifier::minify<128>(buf, len, dst, dst_len); + return icelake::stage1::json_minifier::minify<128>(buf, len, dst, dst_len); } simdjson_warn_unused error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, stage1_mode streaming) noexcept { this->buf = _buf; this->len = _len; - return cascadelake::stage1::json_structural_indexer::index<128>(_buf, _len, *this, streaming); + return icelake::stage1::json_structural_indexer::index<128>(_buf, _len, *this, streaming); } simdjson_warn_unused bool implementation::validate_utf8(const char *buf, size_t len) const noexcept { - return cascadelake::stage1::generic_validate_utf8(buf,len); + return icelake::stage1::generic_validate_utf8(buf,len); } simdjson_warn_unused error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept { @@ -202,4 +202,4 @@ simdjson_warn_unused error_code dom_parser_implementation::parse(const uint8_t * } // namespace SIMDJSON_IMPLEMENTATION } // namespace simdjson -#include "simdjson/cascadelake/end.h" +#include "simdjson/icelake/end.h" diff --git a/src/cascadelake/implementation.cpp b/src/icelake/implementation.cpp similarity index 87% rename from src/cascadelake/implementation.cpp rename to src/icelake/implementation.cpp index 42955acc3..0a8151bd5 100644 --- a/src/cascadelake/implementation.cpp +++ b/src/icelake/implementation.cpp @@ -1,4 +1,4 @@ -#include "simdjson/cascadelake/begin.h" +#include "simdjson/icelake/begin.h" namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { @@ -20,5 +20,5 @@ simdjson_warn_unused error_code implementation::create_dom_parser_implementation } // namespace SIMDJSON_IMPLEMENTATION } // namespace simdjson -#include "simdjson/cascadelake/end.h" +#include "simdjson/icelake/end.h" diff --git a/src/implementation.cpp b/src/implementation.cpp index eecaa8d98..0a9d380aa 100644 --- a/src/implementation.cpp +++ b/src/implementation.cpp @@ -14,10 +14,10 @@ namespace internal { // Static array of known implementations. We're hoping these get baked into the executable // without requiring a static initializer. -#if SIMDJSON_IMPLEMENTATION_CASCADELAKE -static const cascadelake::implementation* get_cascadelake_singleton() { - static const cascadelake::implementation cascadelake_singleton{}; - return &cascadelake_singleton; +#if SIMDJSON_IMPLEMENTATION_ICELAKE +static const icelake::implementation* get_icelake_singleton() { + static const icelake::implementation icelake_singleton{}; + return &icelake_singleton; } #endif #if SIMDJSON_IMPLEMENTATION_HASWELL @@ -79,8 +79,8 @@ private: static const std::initializer_list& get_available_implementation_pointers() { static const std::initializer_list available_implementation_pointers { -#if SIMDJSON_IMPLEMENTATION_CASCADELAKE - get_cascadelake_singleton(), +#if SIMDJSON_IMPLEMENTATION_ICELAKE + get_icelake_singleton(), #endif #if SIMDJSON_IMPLEMENTATION_HASWELL get_haswell_singleton(), diff --git a/src/internal/simdprune_tables.cpp b/src/internal/simdprune_tables.cpp index 73a60b620..977094d8a 100644 --- a/src/internal/simdprune_tables.cpp +++ b/src/internal/simdprune_tables.cpp @@ -1,4 +1,4 @@ -#if SIMDJSON_IMPLEMENTATION_ARM64 || SIMDJSON_IMPLEMENTATION_CASCADELAKE || SIMDJSON_IMPLEMENTATION_HASWELL || SIMDJSON_IMPLEMENTATION_WESTMERE || SIMDJSON_IMPLEMENTATION_PPC64 +#if SIMDJSON_IMPLEMENTATION_ARM64 || SIMDJSON_IMPLEMENTATION_ICELAKE || SIMDJSON_IMPLEMENTATION_HASWELL || SIMDJSON_IMPLEMENTATION_WESTMERE || SIMDJSON_IMPLEMENTATION_PPC64 #include @@ -128,4 +128,4 @@ SIMDJSON_DLLIMPORTEXPORT const uint64_t thintable_epi8[256] = { } // namespace internal } // namespace simdjson -#endif // SIMDJSON_IMPLEMENTATION_ARM64 || SIMDJSON_IMPLEMENTATION_CASCADELAKE || SIMDJSON_IMPLEMENTATION_HASWELL || SIMDJSON_IMPLEMENTATION_WESTMERE || SIMDJSON_IMPLEMENTATION_PPC64 +#endif // SIMDJSON_IMPLEMENTATION_ARM64 || SIMDJSON_IMPLEMENTATION_ICELAKE || SIMDJSON_IMPLEMENTATION_HASWELL || SIMDJSON_IMPLEMENTATION_WESTMERE || SIMDJSON_IMPLEMENTATION_PPC64 diff --git a/src/simdjson.cpp b/src/simdjson.cpp index 685d96457..b094bca0d 100644 --- a/src/simdjson.cpp +++ b/src/simdjson.cpp @@ -19,9 +19,9 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS #include "fallback/implementation.cpp" #include "fallback/dom_parser_implementation.cpp" #endif -#if SIMDJSON_IMPLEMENTATION_CASCADELAKE -#include "cascadelake/implementation.cpp" -#include "cascadelake/dom_parser_implementation.cpp" +#if SIMDJSON_IMPLEMENTATION_ICELAKE +#include "icelake/implementation.cpp" +#include "icelake/dom_parser_implementation.cpp" #endif #if SIMDJSON_IMPLEMENTATION_HASWELL #include "haswell/implementation.cpp"