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

detect AVX-512 FMA count #125

Merged
merged 12 commits into from
Sep 22, 2020
Prev Previous commit
Next Next commit
remove curly braces from single-line conditional bodies
Signed-off-by: Hammond, Jeff R <jeff.r.hammond@intel.com>
  • Loading branch information
Hammond, Jeff R committed Sep 21, 2020
commit 8ff90a69fc8a95f895c2618a05096d728e675ebb
15 changes: 5 additions & 10 deletions src/cpuinfo_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,17 @@ static bool HasSecondFMA(uint32_t model) {
// detect Xeon
if (proc_name[9]=='X') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is testing individual character the official way? It feels like upcoming names could match and trigger false positives.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this code is within the model==0x55 conditional so it is not vulnerable to future branding changes unless they were based on the Skylake Server microarchitecture, which seems exceedingly unlikely.

In C++ implementations of this code, I do substring matching but in the C versions I just test single characters since I believe I have complete knowledge of the relevant processor names (including off-roadmap ones), in which case it should be sufficient.

Would you prefer I test multiple characters directly (test for 'X', 'e', 'o', 'n' not just 'X'), use strncmp, or use strstr? I generally avoid the latter since it doesn't have an n version.

// detect Silver or Bronze
if (proc_name[17]=='S' || proc_name[17]=='B') {
if (proc_name[17]=='S' || proc_name[17]=='B')
return false;
}
// detect Gold 5_20 and below, except for Gold 53__
if (proc_name[17]=='G' && proc_name[22]=='5') {
return ((proc_name[23]=='3') ||
(proc_name[24]=='2' && proc_name[25]=='2'));
}
if (proc_name[17]=='G' && proc_name[22]=='5')
return ((proc_name[23]=='3') || (proc_name[24]=='2' && proc_name[25]=='2'));
// detect Xeon W 210x
if (proc_name[17]=='W' && proc_name[21]=='0') {
if (proc_name[17]=='W' && proc_name[21]=='0')
return false;
}
// detect Xeon D 2xxx
if (proc_name[17]=='D' && proc_name[19]=='2' && proc_name[20]=='1') {
if (proc_name[17]=='D' && proc_name[19]=='2' && proc_name[20]=='1')
return false;
}
}
return true;
}
Expand Down