MCPcopy Create free account
hub / github.com/cwida/FastLanes / CpuFeatureCheck

Function CpuFeatureCheck

src/utl/cpu/info.cpp:48–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46#elif defined(ARM)
47 unsigned long b, i;
48#endif
49
50#if defined(X86_64)
51 if ((feature & CPU_FEATURE_CPU_MASK) != CPU_FEATURE_X86) { return 0; }
52#elif defined(ARM)
53#else
54 return 0;
55#endif
56
57 feature = static_cast<CPUFeature>(~static_cast<uint32_t>(CPUFeature::CPU_MASK) & static_cast<uint32_t>(feature));
58#if defined(_MSC_VER)
59#pragma warning(push)
60#pragma warning(disable : 4152)
61#endif
62#if defined(_MSC_VER)
63#pragma warning(pop)
64#endif
65
66#if defined(X86_64)
67 i = (feature >> 16) & 0xff;
68 r = (feature >> 8) & 0xff;
69 b = (feature) & 0xff;
70
71 if (i > 7 || r > 3 || b > 31) { return 0; }
72
73 return (duckdb_cpuinfo[(i * 4) + r] >> b) & 1;
74#elif defined(ARM)
75 b = 1 << ((feature & 0xff) - 1);
76 i = cpuinfo[(feature >> 0x08) & 0xff];
77 return (cpuinfo[(feature >> 0x08) & 0xff] & b) == b;
78#endif
79}
80
81CpuInfo::CpuInfo() { Initialize(); }
82
83const std::vector<CPUFeature>& CpuInfo::GetAvailFeatures() const { return avail_features; }
84void CpuInfo::Initialize() {
85 // to make sure CpuFeatureCheck used at least once
86 CpuFeatureCheck(CPUFeature::FALLBACK);
87 best_feature = CPUFeature::FALLBACK;

Callers 2

InitializeMethod · 0.85
HasFeatureMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected