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

[cpuid] Let the user perform runtime checks for CPU features #12

Open
Lokathor opened this issue May 6, 2020 · 1 comment
Open

[cpuid] Let the user perform runtime checks for CPU features #12

Lokathor opened this issue May 6, 2020 · 1 comment

Comments

@Lokathor
Copy link
Owner

Lokathor commented May 6, 2020

Even if the user wants to enable features at compile time or not, it's helpful as an extra sanity check to be able to check at program start that the features really are available and maybe print an error message or something if the actual CPU isn't ready to handle what you're doing.


  • first call __get_cpuid_max(0) and check ret.0 for the max leaf.
  • If a leaf has sub-leaves you need to know the max of, call __get_cpuid_max(leaf) and check ret.1 for that max.
  • once you know your limits, particular features can be checked for by getting the info for a leaf and checking the bits of a particular return register. Which bit you need to look for in what register in what leaf is mostly covered in the CPUID wikipedia article.
@Lokathor Lokathor added this to the v1.0 milestone May 14, 2020
@Soveu
Copy link
Sponsor Contributor

Soveu commented May 15, 2020

I think rust-cpuid crate can be used for this

@Lokathor Lokathor changed the title Let the user perform runtime checks for CPU features [cpuid] Let the user perform runtime checks for CPU features May 15, 2020
@Lokathor Lokathor modified the milestones: v1.0, v0.5 Jun 16, 2020
@Lokathor Lokathor modified the milestones: v0.5, v1.0 Jun 24, 2020
@Lokathor Lokathor removed this from the v1.0 milestone May 30, 2021
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

2 participants