2022-10-07 19:20:14 +00:00
|
|
|
#include <base/defines.h>
|
2022-04-04 12:07:05 +00:00
|
|
|
#include <Common/TargetSpecific.h>
|
2020-04-02 13:48:14 +00:00
|
|
|
|
2020-05-16 15:43:05 +00:00
|
|
|
#include <Common/CpuId.h>
|
2020-04-06 07:31:26 +00:00
|
|
|
|
2020-04-05 19:39:12 +00:00
|
|
|
namespace DB
|
2020-04-02 13:48:14 +00:00
|
|
|
{
|
|
|
|
|
2020-06-21 18:47:16 +00:00
|
|
|
UInt32 getSupportedArchs()
|
2020-05-16 06:59:08 +00:00
|
|
|
{
|
2020-05-16 15:43:05 +00:00
|
|
|
UInt32 result = 0;
|
2020-05-17 15:13:01 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_SSE42)
|
2020-05-16 15:43:05 +00:00
|
|
|
result |= static_cast<UInt32>(TargetArch::SSE42);
|
2020-05-17 15:13:01 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_AVX)
|
2020-05-16 15:43:05 +00:00
|
|
|
result |= static_cast<UInt32>(TargetArch::AVX);
|
2020-05-17 15:13:01 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_AVX2)
|
2020-05-16 15:43:05 +00:00
|
|
|
result |= static_cast<UInt32>(TargetArch::AVX2);
|
2020-05-17 15:13:01 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_AVX512F)
|
2020-05-16 15:43:05 +00:00
|
|
|
result |= static_cast<UInt32>(TargetArch::AVX512F);
|
2022-05-27 17:54:11 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_AVX512BW)
|
2022-05-31 19:41:10 +00:00
|
|
|
result |= static_cast<UInt32>(TargetArch::AVX512BW);
|
2022-07-15 07:01:16 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_AVX512VBMI)
|
|
|
|
result |= static_cast<UInt32>(TargetArch::AVX512VBMI);
|
2022-10-24 21:11:46 +00:00
|
|
|
if (Cpu::CpuFlagsCache::have_AVX512VBMI2)
|
|
|
|
result |= static_cast<UInt32>(TargetArch::AVX512VBMI2);
|
2020-05-16 15:43:05 +00:00
|
|
|
return result;
|
2020-04-06 07:31:26 +00:00
|
|
|
}
|
|
|
|
|
2020-06-21 18:47:16 +00:00
|
|
|
bool isArchSupported(TargetArch arch)
|
2020-04-02 13:48:14 +00:00
|
|
|
{
|
2020-06-21 18:47:16 +00:00
|
|
|
static UInt32 arches = getSupportedArchs();
|
2020-05-16 06:59:08 +00:00
|
|
|
return arch == TargetArch::Default || (arches & static_cast<UInt32>(arch));
|
2020-04-02 13:48:14 +00:00
|
|
|
}
|
|
|
|
|
2020-06-21 18:47:16 +00:00
|
|
|
String toString(TargetArch arch)
|
2020-05-15 10:10:34 +00:00
|
|
|
{
|
2020-05-16 06:59:08 +00:00
|
|
|
switch (arch)
|
|
|
|
{
|
2020-05-15 10:10:34 +00:00
|
|
|
case TargetArch::Default: return "default";
|
2020-05-16 15:43:05 +00:00
|
|
|
case TargetArch::SSE42: return "sse42";
|
2020-05-15 10:10:34 +00:00
|
|
|
case TargetArch::AVX: return "avx";
|
|
|
|
case TargetArch::AVX2: return "avx2";
|
2020-05-15 12:00:20 +00:00
|
|
|
case TargetArch::AVX512F: return "avx512f";
|
2022-10-24 21:11:46 +00:00
|
|
|
case TargetArch::AVX512BW: return "avx512bw";
|
|
|
|
case TargetArch::AVX512VBMI: return "avx512vbmi";
|
|
|
|
case TargetArch::AVX512VBMI2: return "avx512vbmi";
|
2020-05-15 10:10:34 +00:00
|
|
|
}
|
|
|
|
|
2022-10-07 19:20:14 +00:00
|
|
|
UNREACHABLE();
|
2020-05-15 10:10:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 06:59:08 +00:00
|
|
|
}
|