forked from kimwalisch/primesieve
-
Notifications
You must be signed in to change notification settings - Fork 0
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 (kimwalisch#150)
- Loading branch information
1 parent
f2aa68c
commit 863dc86
Showing
26 changed files
with
667 additions
and
568 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
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 (primesieve::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 PRIMESIEVE_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
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,7 +1,7 @@ | ||
/// | ||
/// @file CpuInfo.hpp | ||
/// | ||
/// Copyright (C) 2023 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -22,7 +22,6 @@ class CpuInfo | |
public: | ||
CpuInfo(); | ||
bool hasCpuName() const; | ||
bool hasAVX512() const; | ||
bool hasLogicalCpuCores() const; | ||
bool hasL1Cache() const; | ||
bool hasL2Cache() const; | ||
|
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,7 +1,7 @@ | ||
/// | ||
/// @file Erat.hpp | ||
/// | ||
/// Copyright (C) 2023 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -15,8 +15,8 @@ | |
#include "EratMedium.hpp" | ||
#include "EratBig.hpp" | ||
#include "macros.hpp" | ||
#include "intrinsics.hpp" | ||
#include "Vector.hpp" | ||
#include "ctz.hpp" | ||
|
||
#include <stdint.h> | ||
|
||
|
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.