Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<charconv>: Investigate using KholdStare/qnd-integer-parsing-experiments SIMD #870

Open
StephanTLavavej opened this issue May 29, 2020 · 5 comments
Assignees
Labels
performance Must go faster

Comments

@StephanTLavavej
Copy link
Member

See "Faster Integer Parsing" and KholdStare/qnd-integer-parsing-experiments.

KholdStare has graciously licensed this code under the Boost Software License. 😸

@StephanTLavavej StephanTLavavej added the performance Must go faster label May 29, 2020
@StephanTLavavej StephanTLavavej self-assigned this May 29, 2020
@sylveon
Copy link
Contributor

sylveon commented May 30, 2020

uhhh from_chars takes an explicit length?

@KholdStare
Copy link

Hi,

I've made a new commit to the repo with some preliminary SIMD verification: KholdStare/qnd-integer-parsing-experiments@205fa91

Unfortunately the instructions that would be perfect don't exist so I had to cobble some things together. No we can parse from 1 to 16 chars with SIMD, with input validation. The two "wishlist" instructions would be "count trailing zeros" for __m128i type, and a left shift with a non-immediate value. I had to emulate both, and unfortunately there is one branch now. The running time is ~2.5 ns for any number of digits up to 16, up from 0.75ns for exactly 16 digits.

I'll continue thinking about other ways to do the same thing, with some other SSE instructions - I'm sure there's a way to get that lower.

@Kristine1975
Copy link

Kristine1975 commented Nov 11, 2020

re. validation: this function from Daniel Lemire's fast_float library (Apache 2.0) validates 8 characters at once. It's only for base 10, though:

https://github.com/lemire/fast_float/blob/7eae925b51fd0f570ccd5c880c12e3e27a23b86f/include/fast_float/ascii_number.h#L27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

5 participants
@KholdStare @StephanTLavavej @sylveon @Kristine1975 and others