Live data from Hacker News

Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor

lemire.me

1–10 of 51 posts

Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor

#4
Is all this worth it when you may have only a few chars of whitespace at most?

When I was looking at something related to this recently I noticed gcc doing a pretty cool optimisation [0], where it converted the whitespace chars into a bitfield and leveraged the `bt` instruction. It seems quite sensitive to the char string though and falls back to worse code easily (e.g add "\f\v" to the string) but it's easy to manually write the code so that gcc always generates the same.

https://godbolt.org/z/Tzr8e7x6q

Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor

#7
post #6

> char * init_out{out}; Are the curly braces in the initialization some new C++ syntax? I haven't been keeping up with C++ developments in the last decade or so. Based on the code that follows I would expect char* init_out = out;

Yes, I was going to comment on that both code samples are C++, even though they are not clearly labelled as such. List initialization seems to be the recommended syntax to use nowadays in C++ [1].

I'm a fan of the type of optimization and exploration that Lemire often publishes, it's really cool and impressive. I just have a pet peeve about people lumping together C and C++ as if they're interchangable when they are (more clearly than ever, and growing further apart) not.

[1]: https://en.cppreference.com/w/cpp/language/list_initializati...

Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor

#8
post #6

> char * init_out{out}; Are the curly braces in the initialization some new C++ syntax? I haven't been keeping up with C++ developments in the last decade or so. Based on the code that follows I would expect char* init_out = out;

Yes, it is called "Uniform Initialization". https://isocpp.org/wiki/faq/cpp11-language#uniform-init

Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor

#9
post #6

> char * init_out{out}; Are the curly braces in the initialization some new C++ syntax? I haven't been keeping up with C++ developments in the last decade or so. Based on the code that follows I would expect char* init_out = out;

That's been around since C++11 although it's kind of weird to see it used for a char*

Re: Trimming spaces from strings faster with SVE on an Amazon Graviton 3 processor

#10
Thanks for sharing. Is understanding how best to utilize computer hardware part of a classic CS program or is most learned on the job?

I studied Econ in college and been a python guy for last 8 years but have no knowledge of how the machine actually interacts with my code. Is there a formal name for understanding that?

Post reply on HN