-
-
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
7b4fa29
commit fe92aea
Showing
7 changed files
with
184 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// | ||
/// @file check_enable_cpuid_popcnt.hpp | ||
/// @brief Check if runtime POPCNT detection should be enabled on | ||
/// x86 and x64 CPUs. | ||
/// | ||
/// 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 CHECK_ENABLE_CPUID_POPCNT_HPP | ||
#define CHECK_ENABLE_CPUID_POPCNT_HPP | ||
|
||
// Enable CPUID on x86 and x86-64 CPUs | ||
#if defined(__x86_64__) || \ | ||
defined(__i386__) || \ | ||
defined(_M_X64) || \ | ||
defined(_M_IX86) | ||
|
||
// Both GCC and Clang (even Clang on Windows) define the __POPCNT__ | ||
// macro if the user compiles with -mpopcnt. The __POPCNT__ | ||
// macro is even defined if the user compiles with other flags | ||
// such as -mavx or -march=native. | ||
#if defined(__POPCNT__) | ||
#define HAS_POPCNT | ||
// The MSVC compiler does not support a POPCNT macro, but if the user | ||
// compiles with e.g. /arch:AVX or /arch:AVX512 then MSVC defines | ||
// the __AVX__ macro and POPCNT is also supported. | ||
#elif defined(_MSC_VER) && defined(__AVX__) | ||
#define HAS_POPCNT | ||
#endif | ||
|
||
#if !defined(HAS_POPCNT) | ||
#define ENABLE_CPUID_POPCNT | ||
#endif | ||
|
||
#endif // x86 CPUs | ||
|
||
#endif |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// | ||
/// @file cpuid.cpp | ||
/// @brief CPUID for x86 and x86-64 CPUs. | ||
/// | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
/// | ||
|
||
// Enable CPUID on x86 and x86-64 CPUs | ||
#if defined(__x86_64__) || \ | ||
defined(__i386__) || \ | ||
defined(_M_X64) || \ | ||
defined(_M_IX86) | ||
|
||
#include <cpuid.hpp> | ||
|
||
#endif |