2020-04-05 19:39:12 +00:00
|
|
|
#include <Functions/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);
|
|
|
|
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";
|
2020-05-15 10:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
2020-05-16 06:59:08 +00:00
|
|
|
}
|