Daniel Lemire
Daniel Lemire
So I think I solved the problem, although maybe not for simdzone directly. The way the problem appears in simdzone is somewhat non-standard and I wanted to work on a...
Here is my attempt: https://lemire.me/blog/2023/11/28/parsing-8-bit-integers-quickly/
(My tests suggest that you can definitively do much better than naive with SWAR.)
@k0ekk0ek I am tweaking it a bit since the initial version did not fully validate the input.
I recommend the following... ```C++ int parse_uint8_fastswar(const char *str, size_t len, uint8_t *num) { if(len == 0 || len > 3) { return 0; } union { uint8_t as_str[4]; uint32_t...
Slightly more efficient... ```C++ int parse_uint8_fastswar(const char *str, size_t len, uint8_t *num) { if(len == 0 || len > 3) { return 0; } union { uint8_t as_str[4]; uint32_t as_int;...
> There's one case we haven't covered though. Leading zeroes. i.e. 0 is allowed, but 01 is not. Note that this is true of the naïve version as well.
Let us test it out!
> keep some state as some record types The standard seems to require that bytes are encoded as pairs and that pairs are held together, so that the input is...
Using GCC11 on an Ice Lake server, I get the following results: ``` base16hex_simd : 2.78 GB/s 253.1 Ma/s 3.95 ns/d 3.20 GHz 12.63 c/d 44.49 i/d 1.2 c/b 4.06...