mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-24 02:30:51 +00:00
Merge pull request #7726 from ClickHouse/fallback-for-unknown-cpus
Fallback for unknown CPUs when using libcpuid #5239
This commit is contained in:
commit
f2bbfd995a
@ -16,15 +16,11 @@ unsigned getNumberOfPhysicalCPUCores()
|
||||
{
|
||||
#if USE_CPUID
|
||||
cpu_raw_data_t raw_data;
|
||||
if (0 != cpuid_get_raw_data(&raw_data))
|
||||
throw DB::Exception("Cannot cpuid_get_raw_data: " + std::string(cpuid_error()), DB::ErrorCodes::CPUID_ERROR);
|
||||
|
||||
cpu_id_t data;
|
||||
if (0 != cpu_identify(&raw_data, &data))
|
||||
throw DB::Exception("Cannot cpu_identify: " + std::string(cpuid_error()), DB::ErrorCodes::CPUID_ERROR);
|
||||
|
||||
/// On Xen VMs, libcpuid returns wrong info (zero number of cores). Fallback to alternative method.
|
||||
if (data.num_logical_cpus == 0)
|
||||
/// Also, libcpuid does not support some CPUs like AMD Hygon C86 7151.
|
||||
if (0 != cpuid_get_raw_data(&raw_data) || 0 != cpu_identify(&raw_data, &data) || data.num_logical_cpus == 0)
|
||||
return std::thread::hardware_concurrency();
|
||||
|
||||
unsigned res = data.num_cores * data.total_logical_cpus / data.num_logical_cpus;
|
||||
@ -38,6 +34,7 @@ unsigned getNumberOfPhysicalCPUCores()
|
||||
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
#elif USE_CPUINFO
|
||||
uint32_t cores = 0;
|
||||
if (cpuinfo_initialize())
|
||||
|
Loading…
Reference in New Issue
Block a user