From e7a29e09157dc9753c9ea17b7813d0b0aded80b6 Mon Sep 17 00:00:00 2001 From: HedgehogInTheCPP Date: Thu, 20 Aug 2026 18:45:31 +0300 Subject: [PATCH] Documentation updated and hardware level detection cleanup. --- README.md | 4 ++-- include/fast_float/ascii_number.h | 2 +- include/fast_float/float_common.h | 22 ++++++++-------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 296fabb..706df84 100644 --- a/README.md +++ b/README.md @@ -51,10 +51,10 @@ Introduced new optional macros to minimize overhead when certain parsing feature Automatically uses std::bit_cast if available to reduce code size and speed up. * **`FASTFLOAT_X86_SIMD`** - Automatically uses reworking SSE parsing algorithms to improve performance on x86 machines. + Automatically uses reworking SSE parsing algorithms to improve performance on x86 machines. And hardware level also can be set manually by user. * **`FASTFLOAT_USE_SIMD`** - Add possibility to completely disable manual algorithms realization and give compiler more freedom + Can be set to 0 for completely disable manually optimized SIMD paths and use compiler + linker to give the best possible result automatically --- diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index fc8a94e..fdb484d 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -109,7 +109,7 @@ fastfloat_really_inline uint64_t simd_read8(char16_t const *chars) { FASTFLOAT_SIMD_RESTORE_WARNINGS } -#elif defined(FASTFLOAT_ARM_NEON) +#elif FASTFLOAT_ARM_NEON fastfloat_really_inline uint64_t simd_read8(uint16x8_t const &data) { uint8x8_t utf8_packed = vmovn_u16(data); diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 14efd3a..a0f650d 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -186,14 +186,14 @@ using parse_options = parse_options_t; #endif #endif -#ifdef FASTFLOAT_USE_SIMD // user defined -#else -#ifdef FASTFLOAT_X86_SIMD // user defined level +#ifdef FASTFLOAT_USE_SIMD +// user defined +#elif defined(FASTFLOAT_X86_SIMD) +// user defined level static_assert(FASTFLOAT_X86_SIMD == 20 || FASTFLOAT_X86_SIMD == 42 || - FASTFLOAT_X86_SIMD == 52, + FASTFLOAT_X86_SIMD == 52 || FASTFLOAT_ARM_NEON, "FASTFLOAT_X86_SIMD should be 20(SSE2), 42(SSE4.2) and 52(AVX2)"); -#else // auto detect -#if defined(__AVX2__) +#elif defined(__AVX2__) #define FASTFLOAT_X86_SIMD 52 #elif defined(__AVX__) // On MSVC there's no way to check for SSE4.2 specifically so check AVX. @@ -210,18 +210,13 @@ static_assert(FASTFLOAT_X86_SIMD == 20 || FASTFLOAT_X86_SIMD == 42 || (defined(_M_AMD64) || defined(_M_X64) || \ (defined(_M_IX86_FP) && _M_IX86_FP == 2))) #define FASTFLOAT_X86_SIMD 20 -#endif -#endif - -#if defined(__aarch64__) || defined(_M_ARM64) +#elif defined(__aarch64__) || defined(_M_ARM64) #define FASTFLOAT_ARM_NEON 1 #endif -#if defined(FASTFLOAT_X86_SIMD) || defined(FASTFLOAT_ARM_NEON) +#if FASTFLOAT_X86_SIMD || FASTFLOAT_ARM_NEON #define FASTFLOAT_USE_SIMD 1 -#endif -#if FASTFLOAT_USE_SIMD #if defined(__GNUC__) // disable -Wcast-align=strict (GCC only) #define FASTFLOAT_SIMD_DISABLE_WARNINGS \ @@ -234,7 +229,6 @@ static_assert(FASTFLOAT_X86_SIMD == 20 || FASTFLOAT_X86_SIMD == 42 || #define FASTFLOAT_SIMD_RESTORE_WARNINGS #endif #endif -#endif #ifdef FASTFLOAT_VISUAL_STUDIO #define fastfloat_really_inline __forceinline