Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cpuid #8

Open
bluss opened this issue Jul 2, 2015 · 8 comments
Open

Use cpuid #8

bluss opened this issue Jul 2, 2015 · 8 comments

Comments

@bluss
Copy link
Contributor

bluss commented Jul 2, 2015

I think we should use cpuid to check for presence of sse4_2

@bluss
Copy link
Contributor Author

bluss commented Jul 2, 2015

Maybe https://crates.io/crates/cpuid

@shepmaster
Copy link
Owner

Yeah, this is probably a good idea. I might rather roll our own detection, as cpuid appears to be a binding to another library, which seems like a large requirement for the simple requirement we have:

//! Rust bindings for [libpcuid](https://github.com/anrieff/libcpuid)
//! CPU detection and feature extraction library.

Since we are already doing inline assembly, adding another chunk shouldn't be that hard, right? (Famous last words). I'd also like to be cautious about performance, perhaps caching the result of the check (global mutable state... yuck).

@bluss
Copy link
Contributor Author

bluss commented Jul 2, 2015

Absolutely, it should be done only once, using the once thing from libstd I think

@shepmaster
Copy link
Owner

Basic beginning in cpuid-rs.

@bluss
Copy link
Contributor Author

bluss commented Jul 11, 2015

Cool

@shepmaster
Copy link
Owner

An interesting question - at what level should this check be done? There are two I can think of:

  1. At compile time, via a custom build script.
  2. At run time.

Compile time has the nice benefit of producing just the code appropriate for the machine. Run time means that a single compiled program could run on multiple machines, but has at least some kind of overhead on a per-call basis.

I don't actually know what the base line of support that Rust itself offers with regards to compiling and running on different architectures.

@shepmaster
Copy link
Owner

Of course, there's always "add more feature flags" to support both options...

@ArtemGr
Copy link

ArtemGr commented Jan 31, 2016

Right now rustc generates a generic executable, people expect to be able to copy it to a compatibe machine and run there. -march=native isn't widely used. So it makes sense to default to the runtime check.

When -march=native builds become a norm (e.g. supported by cargo) then it'll make sense to detect such builds and do the compile time check optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants