| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ii_count - icelake validate_utf8_with_counts: skip continuation/4-byte popcounts on pure-ASCII 64-byte blocks (use avx512_utf8_checker::check_next_input's ASCII return), matching SimdUnicode's ASCII fast path. ~1.6x on ASCII/mixed. - Remove non_ascii_count from utf8_result and all backends: it was computed in the hot loop but consumed by nothing (utf16_length needs only input, continuations, four_byte; code points need input - continuations). - Fewer popcounts per non-ASCII block across scalar/generic/icelake.
arm64 already routes validate_utf8/validate_utf8_with_errors through the generic utf8_validation kernel; do the same for validate_utf8_with_counts. Measured on Apple M4 Max (64 MB inputs, best-of-N): ascii 4.2 -> 97.5 GB/s (23x), mixed 4.2 -> 74 GB/s (18x), chinese 3.0 -> 7.3 GB/s (2.4x), emoji 3.6 -> 7.1 GB/s (2x). Brute-force equality-to-scalar test passes.
…ask+popcount NEON has no movemask; building a bitmask and popcounting it is costly. Reduce the continuation / four-byte comparison masks directly with a horizontal byte add (sum_bytes), one instruction per counter. x86 keeps movemask+popcount via the #else branch (byte-identical to before, verified unchanged on big4). Apple M4 Max, validate_utf8_with_counts, 64 MB, best-of-N: chinese 7.3 -> 10.6 GB/s (1.45x), emoji 7.1 -> 10.5 GB/s (1.48x); ascii/mixed unchanged (counting already skipped on ASCII blocks).
Replace the per-chunk horizontal reduction (sum_bytes/vaddvq) with int8x16 lane accumulators updated by cheap vertical adds; reduce across lanes only every 124 chunks, on error, and at end. Helps weak cores (Graviton 2) where cross-lane sums are slow. Arm64-guarded; x86 path unchanged.
Make the generic utf8_checker::check_next_input return whether the block was pure ASCII (matching the icelake avx512 checker). The NEON counting path uses it to gate accumulation without a redundant is_ascii() call per block. Existing validate_utf8 callers ignore the return value.
|
@BenjaminBucher This is on top of your working branch for simdutf#974 |
Sorry, something went wrong.
|
Removing non_ascii_counts cleans up a lot of stuff again, I agree that it's nicer. Interesting that NEON doesn't have a movemask instruction. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Five commits on top of simdunicode-port optimizing validate_utf8_with_counts.
(using the checker's ASCII return value), and drop the unused non_ascii_count
from utf8_result and all backends — neither utf16_length() (input −
continuations + four_byte) nor the code-point count (input − continuations)
needs it. ~1.6x on ASCII/mixed on Emerald Rapids; counting on ASCII/mixed now
matches the plain-validation floor.
(~17–23x on ASCII/mixed, 2–3.5x on multibyte vs the old scalar fallback).
SimdUnicode's deferred cross-lane reduction (int8x16 lane accumulators updated
with cheap vertical adds; reduce only every 124 chunks / on error / at end).
Fewer instructions and half the horizontal reductions than the byte-sum
version. Graviton 2 +40% on multibyte, Apple M4 +17%; tie on ASCII/mixed.
icelake avx512 checker; the NEON counter uses it to gate accumulation without
a redundant is_ascii() per block.
Net diff on the scalar/generic/icelake side is a simplification (fewer fields,
fewer popcounts).
Tested: the validate_utf8_with_counts brute-force equality-to-scalar test
passes on x86 (Emerald Rapids / icelake + haswell + westmere), arm64 (Apple M4),
and Graviton 2 (Neoverse N1); the full ctest suite is green on x86 and arm64.