r/programming • • May 25 '19

Making the obvious code fast

https://jackmott.github.io/programming/2016/07/22/making-obvious-fast.html
1.3k Upvotes

263 comments sorted by

View all comments

Show parent comments

4

u/warlockface May 26 '19

How do you get that from this article? In that code the Rust compiler doesn't optimize to SIMD instructions automatically like the C compiler. The Rust code is half as fast as the C code until it is manually rewritten with code in an "unsafe" block using what the author refers to as "unstable" features which "might make it problematic to use this feature for any important production project".

It's specifically demonstrates that the Rust compiler does not optimise as effectively as the C compiler.

2

u/steveklabnik1 May 26 '19

1

u/warlockface May 26 '19 edited May 27 '19

SSE2 yes, but there are no packed AVX instructions in the output from 1.35 with `target-feature=+avx,+fma`, How do I force this without running a nightly build? Btw you have a couple of "target-features" in the examples in the target-feature section of the rustc docs that hinder the scan and copy pasta workflow.

edit: AVX not AVX2 for avx

1

u/steveklabnik1 May 27 '19

You need nightly for that? I thought those were stable flags.

Can you file a bug please? Thanks!

1

u/warlockface May 27 '19

The flags don't need nightly but the compiler only produces scalar SIMD instructions with them. Nightly appears to be needed to get the performance shown in this article, because I can't get near it with Rust stable.

→ More replies (0)