MCPcopy Create free account
hub / github.com/apache/arrow / ArchParseUserSimdLevel

Function ArchParseUserSimdLevel

cpp/src/arrow/util/cpu_info.cc:276–316  ·  view source on GitHub ↗

------------------------------ X86_64 ------------------------------//

Source from the content-addressed store, hash-verified

274#if XSIMD_TARGET_X86
275//------------------------------ X86_64 ------------------------------//
276bool ArchParseUserSimdLevel(const std::string& simd_level, int64_t* hardware_flags) {
277 enum {
278 USER_SIMD_NONE,
279 USER_SIMD_SSE4_2,
280 USER_SIMD_AVX,
281 USER_SIMD_AVX2,
282 USER_SIMD_AVX512,
283 USER_SIMD_MAX,
284 };
285
286 int level = USER_SIMD_MAX;
287 // Parse the level
288 if (simd_level == "AVX512") {
289 level = USER_SIMD_AVX512;
290 } else if (simd_level == "AVX2") {
291 level = USER_SIMD_AVX2;
292 } else if (simd_level == "AVX") {
293 level = USER_SIMD_AVX;
294 } else if (simd_level == "SSE4_2") {
295 level = USER_SIMD_SSE4_2;
296 } else if (simd_level == "NONE") {
297 level = USER_SIMD_NONE;
298 } else {
299 return false;
300 }
301
302 // Disable feature as the level
303 if (level < USER_SIMD_AVX512) {
304 *hardware_flags &= ~CpuInfo::AVX512;
305 }
306 if (level < USER_SIMD_AVX2) {
307 *hardware_flags &= ~(CpuInfo::AVX2 | CpuInfo::BMI2);
308 }
309 if (level < USER_SIMD_AVX) {
310 *hardware_flags &= ~CpuInfo::AVX;
311 }
312 if (level < USER_SIMD_SSE4_2) {
313 *hardware_flags &= ~(CpuInfo::SSE4_2 | CpuInfo::BMI1);
314 }
315 return true;
316}
317
318void ArchVerifyCpuRequirements(const CpuInfo* ci) {
319# if defined(ARROW_HAVE_SSE4_2)

Callers 1

CpuInfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected