logoalt Hacker News

seddonm1today at 4:06 AM3 repliesview on HN

I would be interested to know if there is a method similar to this one in Rust [0] that allows a single binary to support multiple optimization levels depending on the executing CPU? It feels wasteful to not enable these optimizations but I don't really want to force a user to choose between a complex feature matrix.

[0] https://github.com/ronnychevalier/cargo-multivers


Replies

SkiFire13today at 5:43 AM

Note that you can do this yourself manually for single pieces of code by using `is_x86_feature_detected` [0]

[0] https://doc.rust-lang.org/stable/std/macro.is_x86_feature_de...

mikepurvistoday at 4:57 AM

I've long been surprised there isn't more multiversion stuff built right into every language compiler; I would have thought Intel would be very motivated to get more binaries lighting up the features they add to their expensive top line CPUs.

But yeah no, on the whole cost of the checks and duplicated binary size aren't seen as worth it, so instead it's piecemeal implementations mostly in numeric packages like eigen and lapack.

show 1 reply