Based on the title, I knew the issue as soon as I looked at the first table. Still, great primer for those who don't know about such CPU shenanigans, and I did appreciate the solution, since I knew high level how to solve it, but didn't come up with an actual piece of code before the author presented theirs. I didn't know about branch prediction or pipelined CPUs back when I was profiling the code I wrote - honestly…
Branchless Rust: Making a Filter 4x Faster by Removing an If
101–110 of 124 posts
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#102Earlier quoted context omitted.
Keep in mind it's UB to be: > Executing code compiled with target features that the current thread of execution does not support I.e. calling AVX512 on Neon architecture. You need to wrap it in target attributes to even dream of it being safe.
This particular UB is not one of the subtle cases. You will almost certainly get illegal instruction signals if you mess this up.
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#103Earlier quoted context omitted.
idk why this is getting downvoted, I also got this sense, plugged it into Pangram and indeed, 80% AI-written score. I guess that's fine, but after awhile I get a spidey-sense reading something that feels like a Claude session.
Sad to see you getting voted down. But I guess both the pro-AI crowd and anti-AI crowd hate Pangram.
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#104Earlier quoted context omitted.
One nice thing about English is you can just make up words with plausible etymological roots in Latin/French or Old English and often people will know what you mean. In this case though it would probably be spelled "Anglicism".
German language: hold my beer ;)
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#105Earlier quoted context omitted.
Click on their blog index page, see posts going back to early 2010s and use the same writing style. He must have been time travelling and using AI all this time!
I had a look at their blog page out of curiosity, not that you can prove much from the purported dates and text on a blog, which could be edited at any time. The blog posts from 2010s are in a completely different style and written by a human: https://www.greyblake.com/blog/vim-preview-plugin/ https://www.greyblake.com/blog/how-to-install-firefox-icewea... https://www.greyblake.com/blog/unexpected-ruby-behaviour/ ...…
[0] https://www.greyblake.com/blog/vim-preview-plugin/
[1] https://web.archive.org/web/20220516225844/https://www.greyb...
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#106This article is 100% AI written. The data was interesting, the commentary overly verbose and hard to gain useful insights from.
I find it really annoying when the LLM says “good instinct” as if I’m an animal barely able to think.
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#107This article is 100% AI written. The data was interesting, the commentary overly verbose and hard to gain useful insights from.
Agree. Interesting topic but why destroy your own credibility and reputation by shoveling llm-assisted slop to us here at hn? The post should be flagged, and in general, i wish hn would adopt a no-tolerance policy to enhanced posting like this. So what if the original text, if it existed in a human written form at all, had weird textual quirks and prose issues the author wished to hide. That texture's what makes huma…
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#108Nice post! You can do even a bit better if you're willing to use intrinsics. In particular this kind of operation is well-suited for compress-type operations, available as a first-class operation in at least AVX512, SVE and RVV; you can also emulate them reasonably quickly on NEON and AVX2. Here's an example, building on the OP's work: pub fn filter_compress(input: &[f64], threshold: f64) -> Vec { use std::arch::x86_…
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#109Nice post! You can do even a bit better if you're willing to use intrinsics. In particular this kind of operation is well-suited for compress-type operations, available as a first-class operation in at least AVX512, SVE and RVV; you can also emulate them reasonably quickly on NEON and AVX2. Here's an example, building on the OP's work: pub fn filter_compress(input: &[f64], threshold: f64) -> Vec { use std::arch::x86_…
I heard there's a way to arrange code such that the compiler can autobectorize easier. I wonder if there's a way to do that here? Would probably have to pass `-C target-cpu=native` to cargo so that llvm is allowed to use AVX512.
Re: Branchless Rust: Making a Filter 4x Faster by Removing an If
#110Earlier quoted context omitted.
Good question. I personally doubt that the compress instruction is easy to coax compilers into generating, as there are many edge cases to consider. For example, you'll notice here that we perform a full vector store of 8 elements unconditionally, even if only a few of the elements are active. This is safe , though, because the output buffer is as large as the input buffer, and we're chunking by 8, so we'll never tra…
I believe the bounds check, in particular, is devastating for autovectorization. There are ways around it, but it requires additional code in safe rust. Edit: actually looks like autovectorization is in play here [1]. Doesn't look like the bounds check gets in the way at all. [1] https://godbolt.org/z/af4qGba5o