-
-
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.
Move x86 CPUID code from cpuid.hpp to cpuid.cpp (#73)
- Loading branch information
1 parent
f4f3c91
commit ae31111
Showing
18 changed files
with
268 additions
and
246 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
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,53 @@ | ||
# On x86 CPUs we need to enable the use of cpuid.cpp. | ||
# If cpuid.cpp compiles we assume it is a x86 CPU. | ||
|
||
include(CheckCXXSourceCompiles) | ||
include(CMakePushCheckState) | ||
|
||
cmake_push_check_state() | ||
set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}") | ||
|
||
check_cxx_source_compiles(" | ||
// Enable CPUID for POPCNT on x86 and x86-64 CPUs. | ||
// This is required because not all x86 and x86-64 CPUs | ||
// support the POPCNT instruction. | ||
#if !(defined(__x86_64__) || \ | ||
defined(__i386__) || \ | ||
defined(_M_X64) || \ | ||
defined(_M_IX86)) | ||
Error: x86 POPCNT multiarch not needed! | ||
#endif | ||
// 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__) | ||
Error: x86 POPCNT multiarch not needed! | ||
// 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__) | ||
Error: x86 POPCNT multiarch not needed! | ||
#endif | ||
#include <src/x86/cpuid.cpp> | ||
#include <iostream> | ||
int main() | ||
{ | ||
if (primecount::has_cpuid_popcnt()) | ||
std::cout << \"CPU supports POPCNT!\" << std::endl; | ||
else | ||
std::cout << \"CPU does not support POPCNT!\" << std::endl; | ||
return 0; | ||
} | ||
" multiarch_x86_popcnt) | ||
|
||
if(multiarch_x86_popcnt) | ||
list(APPEND PRIMECOUNT_COMPILE_DEFINITIONS "ENABLE_MULTIARCH_x86_POPCNT") | ||
endif() | ||
|
||
cmake_pop_check_state() |
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
Oops, something went wrong.