-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af7700e
commit dcc4288
Showing
5 changed files
with
45 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/// | ||
/// @file cpu_supports_avx512_bmi2.hpp | ||
/// @brief Detect if the x86 CPU supports AVX512 and BMI2. | ||
/// @file cpu_supports_avx512_vpopcnt.hpp | ||
/// @brief Detect if the x86 CPU supports AVX512 VPOPCNT. | ||
/// | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
/// | ||
|
||
#ifndef CPU_SUPPORTS_AVX512_BMI2_HPP | ||
#define CPU_SUPPORTS_AVX512_BMI2_HPP | ||
#ifndef CPU_SUPPORTS_AVX512_VPOPCNT_HPP | ||
#define CPU_SUPPORTS_AVX512_VPOPCNT_HPP | ||
|
||
#include <cpuid.hpp> | ||
|
||
|
@@ -18,7 +18,6 @@ | |
#endif | ||
|
||
// %ebx bit flags | ||
#define bit_BMI2 (1 << 8) | ||
#define bit_AVX512F (1 << 16) | ||
|
||
// %ecx bit flags | ||
|
@@ -45,7 +44,7 @@ inline int get_xcr0() | |
return xcr0; | ||
} | ||
|
||
inline bool run_cpuid_avx512_bmi2() | ||
inline bool run_cpuid_avx512_vpopcnt() | ||
{ | ||
int abcd[4]; | ||
|
||
|
@@ -72,16 +71,13 @@ inline bool run_cpuid_avx512_bmi2() | |
|
||
run_cpuid(7, 0, abcd); | ||
|
||
if ((abcd[1] & bit_BMI2) != bit_BMI2) | ||
return false; | ||
|
||
// AVX512F, AVX512VPOPCNTDQ | ||
return ((abcd[1] & bit_AVX512F) == bit_AVX512F && | ||
(abcd[2] & bit_AVX512_VPOPCNTDQ) == bit_AVX512_VPOPCNTDQ); | ||
} | ||
|
||
/// Initialized at startup | ||
bool cpu_supports_avx512_bmi2 = run_cpuid_avx512_bmi2(); | ||
bool cpu_supports_avx512_vpopcnt = run_cpuid_avx512_vpopcnt(); | ||
|
||
} // namespace | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters