Fixes stub build break and maybe also arm (#31)

This commit is contained in:
sebastianstolzenberg 2018-01-20 13:34:56 +01:00 committed by Ben Gräf
parent 61db1fec72
commit b2301c07ca
5 changed files with 86 additions and 70 deletions

View file

@ -28,7 +28,6 @@
#include <algorithm>
#include <memory>
#include <libcpuid.h>
#include <iostream>
#include "Cpu.h"
@ -132,48 +131,6 @@ size_t CpuImpl::availableCache()
return cache;
}
void CpuImpl::initCommon()
{
struct cpu_raw_data_t raw = { 0 };
struct cpu_id_t data = { 0 };
cpuid_get_raw_data(&raw);
cpu_identify(&raw, &data);
strncpy(m_brand, data.brand_str, sizeof(m_brand) - 1);
m_totalThreads = data.total_logical_cpus;
m_sockets = m_totalThreads / data.num_logical_cpus;
if (m_sockets == 0) {
m_sockets = 1;
}
m_totalCores = data.num_cores * m_sockets;
m_l3_cache = data.l3_cache > 0 ? data.l3_cache * m_sockets : 0;
// Workaround for AMD CPUs https://github.com/anrieff/libcpuid/issues/97
if (data.vendor == VENDOR_AMD && data.ext_family >= 0x15 && data.ext_family < 0x17) {
m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets;
m_l2_exclusive = true;
}
else {
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0;
}
# if defined(__x86_64__) || defined(_M_AMD64)
m_flags |= Cpu::X86_64;
# endif
if (data.flags[CPU_FEATURE_AES]) {
m_flags |= Cpu::AES;
}
if (data.flags[CPU_FEATURE_BMI2]) {
m_flags |= Cpu::BMI2;
}
}
void Cpu::init()
{
CpuImpl::instance().init();