ClickHouse/src/Functions/TargetSpecific.cpp

43 lines
1.0 KiB
C++
Raw Normal View History

#include <Functions/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-05-16 06:59:08 +00:00
UInt32 GetSupportedArches()
{
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);
return result;
2020-04-06 07:31:26 +00:00
}
2020-04-02 13:48:14 +00:00
bool IsArchSupported(TargetArch arch)
{
2020-05-16 06:59:08 +00:00
static UInt32 arches = GetSupportedArches();
return arch == TargetArch::Default || (arches & static_cast<UInt32>(arch));
2020-04-02 13:48:14 +00:00
}
2020-05-15 10:10:34 +00:00
String ToString(TargetArch arch)
{
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";
2020-05-15 10:10:34 +00:00
}
__builtin_unreachable();
}
2020-05-16 06:59:08 +00:00
}