News for hackers. Stuff that matters.
Re:Ask HN: Best way to learn modern C++? by AnimalMuppet on Wednesday March 07, 2018 @12:25PM (#16537962)
Will Rust have idioms for really doing SIMD in Rust? If I understand correctly, C++ has to drop into assembly to do SIMD (at least so far).
Re:Ask HN: Best way to learn modern C++? by steveklabnik on Wednesday March 07, 2018 @12:47PM (#16538178)
I don’t believe that’s correct for C++.

Regardless, yes, that’s the whole point. What’s been accepted is https://doc.rust-lang.org/nightly/core/arch/index.html , that is, intrinsics that map 1-1 to the vendor APIs. (I belive this is the same in C++ but not my area of specialty so I may be wrong)

https://doc.rust-lang.org/nightly/core/simd/index.html is the first level up the abstraction chain; this hasn’t gone through an RFC process yet, but will eventually happen.

On top of that, you have stuff like https://crates.io/crates/faster , which is very high level. Looks like they need to fix up the README... but you get the idea.

Also, autovectorization has existed this entire time. This stuff is for when that falls down.

Re:Ask HN: Best way to learn modern C++? by pjmlp on Wednesday March 07, 2018 @12:37PM (#16538078)
C++ doesn't need Assembly for SIMD.

Most compilers do a reasonable job with auto-vectorization, and if more is needed, there are instrisics.

No need to write straight Assembly.

Re:Ask HN: Best way to learn modern C++? by AnimalMuppet on Wednesday March 07, 2018 @12:46PM (#16538164)
OK. (The one time I encountered SIMD in C++ was a decade ago; we had to use assembly then. And even then, we weren't playing with an up-to-the-minute compiler. (In my experience, your comments elsewhere on this article about embedded toolchains were accurate.)

Are the intrinsics standard? If so, what version of the standard were they in? How good is compiler support for them?

Re:Ask HN: Best way to learn modern C++? by AstralStorm on Wednesday March 07, 2018 @01:21PM (#16538501)
Not standard, unless you count "supported with the same semantics in multiple compilers" as good enough.

They are not portable between CPU architectures either way

For reference, C got real alignment support in C11 and C++ in C++17. Without this, even starting on SIMD is risky.

That said, you can go really far with a good C++ math library like Eigen which has singe vectorization in the operations themselves.