mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
dbms: porting to aarch64 [#METR-19609].
This commit is contained in:
parent
54d3af930c
commit
e522ec23f9
4
dbms/include/DB/Common/getNumberOfPhysicalCPUCores.h
Normal file
4
dbms/include/DB/Common/getNumberOfPhysicalCPUCores.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// Получить количество ядер CPU без учёта hyper-threading.
|
||||||
|
unsigned getNumberOfPhysicalCPUCores();
|
@ -82,3 +82,9 @@
|
|||||||
|
|
||||||
#define ALWAYS_INLINE __attribute__((__always_inline__))
|
#define ALWAYS_INLINE __attribute__((__always_inline__))
|
||||||
#define NO_INLINE __attribute__((__noinline__))
|
#define NO_INLINE __attribute__((__noinline__))
|
||||||
|
|
||||||
|
#define PLATFORM_NOT_SUPPORTED "The only supported platforms are x86_64 and AArch64 (work in progress)"
|
||||||
|
|
||||||
|
#if !defined(__x86_64__) && !defined(__aarch64__)
|
||||||
|
#error PLATFORM_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
#include <DB/Core/Field.h>
|
#include <DB/Core/Field.h>
|
||||||
#include <DB/IO/WriteHelpers.h>
|
#include <DB/IO/WriteHelpers.h>
|
||||||
#include <Poco/Timespan.h>
|
#include <Poco/Timespan.h>
|
||||||
#include <cpuid/libcpuid.h>
|
|
||||||
|
#include <DB/Common/getNumberOfPhysicalCPUCores.h>
|
||||||
|
|
||||||
#include <DB/IO/CompressedStream.h>
|
#include <DB/IO/CompressedStream.h>
|
||||||
#include <DB/IO/ReadHelpers.h>
|
#include <DB/IO/ReadHelpers.h>
|
||||||
|
|
||||||
@ -13,7 +15,6 @@ namespace DB
|
|||||||
|
|
||||||
namespace ErrorCodes
|
namespace ErrorCodes
|
||||||
{
|
{
|
||||||
extern const int CPUID_ERROR;
|
|
||||||
extern const int TYPE_MISMATCH;
|
extern const int TYPE_MISMATCH;
|
||||||
extern const int UNKNOWN_LOAD_BALANCING;
|
extern const int UNKNOWN_LOAD_BALANCING;
|
||||||
extern const int UNKNOWN_OVERFLOW_MODE;
|
extern const int UNKNOWN_OVERFLOW_MODE;
|
||||||
@ -151,15 +152,7 @@ struct SettingMaxThreads
|
|||||||
/// Выполняется один раз за всё время. Выполняется из одного потока.
|
/// Выполняется один раз за всё время. Выполняется из одного потока.
|
||||||
UInt64 getAutoValueImpl() const
|
UInt64 getAutoValueImpl() const
|
||||||
{
|
{
|
||||||
cpu_raw_data_t raw_data;
|
return getNumberOfPhysicalCPUCores();
|
||||||
if (0 != cpuid_get_raw_data(&raw_data))
|
|
||||||
throw Exception("Cannot cpuid_get_raw_data: " + String(cpuid_error()), ErrorCodes::CPUID_ERROR);
|
|
||||||
|
|
||||||
cpu_id_t data;
|
|
||||||
if (0 != cpu_identify(&raw_data, &data))
|
|
||||||
throw Exception("Cannot cpu_identify: " + String(cpuid_error()), ErrorCodes::CPUID_ERROR);
|
|
||||||
|
|
||||||
return data.num_cores * data.total_logical_cpus / data.num_logical_cpus;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
38
dbms/src/Common/getNumberOfPhysicalCPUCores.cpp
Normal file
38
dbms/src/Common/getNumberOfPhysicalCPUCores.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <DB/Common/getNumberOfPhysicalCPUCores.h>
|
||||||
|
|
||||||
|
#if defined(__x86_64__)
|
||||||
|
|
||||||
|
#include <cpuid/libcpuid.h>
|
||||||
|
#include <DB/Common/Exception.h>
|
||||||
|
|
||||||
|
namespace ErrorCodes
|
||||||
|
{
|
||||||
|
extern const int CPUID_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
unsigned getNumberOfPhysicalCPUCores()
|
||||||
|
{
|
||||||
|
#if defined(__x86_64__)
|
||||||
|
|
||||||
|
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()), ErrorCodes::CPUID_ERROR);
|
||||||
|
|
||||||
|
cpu_id_t data;
|
||||||
|
if (0 != cpu_identify(&raw_data, &data))
|
||||||
|
throw DB::Exception("Cannot cpu_identify: " + std::string(cpuid_error()), ErrorCodes::CPUID_ERROR);
|
||||||
|
|
||||||
|
return data.num_cores * data.total_logical_cpus / data.num_logical_cpus;
|
||||||
|
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
/// Считаем, что на этой системе нет hyper-threading.
|
||||||
|
return std::thread::hardware_concurrency();
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user