Add correct core count detection for i7(and maybe i5/i3?) CPUs, and update the SysInfo screen to show more information about threads on x86/x64.

This commit is contained in:
The Dax committed 2013-10-17 19:03:33 -04:00
1 parent aa3cf34fc1
commit 0400a61d51
2 files changed
+13 -2

No files matched your search

+10 -1
View File
@@ -192,8 +192,17 @@ void CPUInfo::Detect()
int apic_id_core_id_size = (cpu_id[2] >> 12) & 0xF;
if (apic_id_core_id_size == 0) {
if (ht) {
// 0x0B is the preferred method on i7(i5, i3, too? Unsure..).
// Inspired by https://github.com/D-Programming-Language/druntime/blob/master/src/core/cpuid.d#L562.
if (vendor == VENDOR_INTEL && max_std_fn >= 0x0B) {
__cpuidex(cpu_id, 0x0B, 0);
logical_cpu_count = cpu_id[1] & 0xFFFF;
__cpuidex(cpu_id, 0x0B, 1);
int totalThreads = cpu_id[1] & 0xFFFF;
num_cores = totalThreads / logical_cpu_count;
}
// New mechanism for modern Intel CPUs.
if (vendor == VENDOR_INTEL) {
else if (vendor == VENDOR_INTEL) {
__cpuid(cpu_id, 0x00000004);
int cores_x_package = ((cpu_id[0] >> 26) & 0x3F) + 1;
HTT = (cores_x_package < logical_cpu_count);