Re:Parsing integers quickly with AVX-512
by anonymoushn on Monday September 25, 2023 @05:15AM
(#37641216)
It looks like the instructions handle this https://stackoverflow.com/questions/54497141/when-using-a-ma...
Re:Parsing integers quickly with AVX-512
by Findecanor on Monday September 25, 2023 @08:07AM
(#37642426)
Yes. The bounds from the std::string are used to create a read-mask which is used in a masked load that does not fault on lanes outside the mask.
If the length had been unknown (say, a C-style null-terminated string) then the code would have needed to be more complex. You would either have to find the length before-hand or done only aligned loads. BTW. ARM's SVE and RISC-V's Vector extension have special "first fault" load-instructions that make that case simpler: they instead modify the vector's mask/length to the lowest-numbered lane that would have faulted.
We had a similar case with some AVX-optimized string operation in glibc.