ClickHouse/src/Common/TargetSpecific.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.5 KiB
C++
Raw Normal View History

#include <base/defines.h>
2022-04-04 12:07:05 +00:00
#include <Common/TargetSpecific.h>
2020-04-02 13:48:14 +00:00
#include <Common/CpuId.h>
2020-04-06 07:31:26 +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
{
UInt32 result = 0;
if (Cpu::CpuFlagsCache::have_SSE42)
result |= static_cast<UInt32>(TargetArch::SSE42);
if (Cpu::CpuFlagsCache::have_AVX)
result |= static_cast<UInt32>(TargetArch::AVX);
if (Cpu::CpuFlagsCache::have_AVX2)
result |= static_cast<UInt32>(TargetArch::AVX2);
if (Cpu::CpuFlagsCache::have_AVX512F)
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);
if (Cpu::CpuFlagsCache::have_AVX512VBMI2)
result |= static_cast<UInt32>(TargetArch::AVX512VBMI2);
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";
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";
case TargetArch::AVX512BW: return "avx512bw";
case TargetArch::AVX512VBMI: return "avx512vbmi";
case TargetArch::AVX512VBMI2: return "avx512vbmi";
2020-05-15 10:10:34 +00:00
}
UNREACHABLE();
2020-05-15 10:10:34 +00:00
}
2020-05-16 06:59:08 +00:00
}