diff --git a/cmake/archdetect.cmake b/cmake/archdetect.cmake index 494269c2..bd0d088c 100644 --- a/cmake/archdetect.cmake +++ b/cmake/archdetect.cmake @@ -44,7 +44,7 @@ if (USE_CPU_NATIVE) endif() elseif (CMAKE_COMPILER_IS_CLANG) if (ARCH_IA32 OR ARCH_X86_64) - set(GNUCC_ARCH x86_64_v2) + set(GNUCC_ARCH x86-64-v2) set(TUNE_FLAG generic) elseif(ARCH_AARCH64) if (BUILD_SVE2_BITPERM) @@ -68,8 +68,22 @@ if (USE_CPU_NATIVE) endif() else() if (SIMDE_BACKEND) - set(GNUCC_ARCH native) - set(TUNE_FLAG native) + if (ARCH_IA32 OR ARCH_X86_64) + set(GNUCC_ARCH x86-64-v2) + set(TUNE_FLAG generic) + elseif(ARCH_AARCH64) + set(GNUCC_ARCH armv8-a) + set(TUNE_FLAG generic) + elseif(ARCH_ARM32) + set(GNUCC_ARCH armv7a) + set(TUNE_FLAG generic) + elseif(ARCH_PPC64EL) + set(GNUCC_ARCH power8) + set(TUNE_FLAG power8) + else() + set(GNUCC_ARCH native) + set(TUNE_FLAG generic) + endif() elseif (ARCH_IA32 OR ARCH_X86_64) set(GNUCC_ARCH native) set(TUNE_FLAG generic) diff --git a/cmake/osdetection.cmake b/cmake/osdetection.cmake index 235487a9..343e16b5 100644 --- a/cmake/osdetection.cmake +++ b/cmake/osdetection.cmake @@ -7,28 +7,28 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" OFF) -message("Checking Fat Runtime Requirements...") -if (FAT_RUNTIME AND NOT LINUX) - message(FATAL_ERROR "Fat runtime is only supported on Linux OS") -endif() - -if (USE_CPU_NATIVE AND FAT_RUNTIME) - message(FATAL_ERROR "Fat runtime is not compatible with Native CPU detection") -endif() - -if (FAT_RUNTIME AND LINUX) - if (NOT (ARCH_IA32 OR ARCH_X86_64 OR ARCH_AARCH64)) - message(FATAL_ERROR "Fat runtime is only supported on Intel and Aarch64 architectures") +if (FAT_RUNTIME) + message("Checking Fat Runtime Requirements...") + if (NOT LINUX) + message(FATAL_ERROR "Fat runtime is only supported on Linux OS") else() - message(STATUS "Building Fat runtime for multiple microarchitectures") - message(STATUS "generator is ${CMAKE_GENERATOR}") - if (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR - (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) - message (FATAL_ERROR "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") + if (USE_CPU_NATIVE AND FAT_RUNTIME) + message(FATAL_ERROR "Fat runtime is not compatible with Native CPU detection") + endif() + + if (NOT (ARCH_IA32 OR ARCH_X86_64 OR ARCH_AARCH64)) + message(FATAL_ERROR "Fat runtime is only supported on Intel and Aarch64 architectures") else() - include (${CMAKE_MODULE_PATH}/attrib.cmake) - if (NOT HAS_C_ATTR_IFUNC) - message(FATAL_ERROR "Compiler does not support ifunc attribute, cannot build fat runtime") + message(STATUS "Building Fat runtime for multiple microarchitectures") + message(STATUS "generator is ${CMAKE_GENERATOR}") + if (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR + (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) + message (FATAL_ERROR "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") + else() + include (${CMAKE_MODULE_PATH}/attrib.cmake) + if (NOT HAS_C_ATTR_IFUNC) + message(FATAL_ERROR "Compiler does not support ifunc attribute, cannot build fat runtime") + endif() endif() endif() endif() @@ -36,5 +36,3 @@ if (FAT_RUNTIME AND LINUX) message(FATAL_ERROR "Fat runtime is only built on Release builds") endif() endif () - - diff --git a/cmake/simde.cmake b/cmake/simde.cmake index 8cac2bdd..0ac52832 100644 --- a/cmake/simde.cmake +++ b/cmake/simde.cmake @@ -1,10 +1,16 @@ -include_directories(${PROJECT_SOURCE_DIR}/simde/simde) +LIST(APPEND CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/simde) -CHECK_INCLUDE_FILES("simde/x86/sse4.2.h" SIMDE_SSE42_H_FOUND) +CHECK_INCLUDE_FILES(simde/x86/sse4.2.h SIMDE_SSE42_H_FOUND) if (SIMDE_SSE42_H_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVS_SIMDE_BACKEND") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVS_SIMDE_BACKEND") + include_directories(${PROJECT_SOURCE_DIR}/simde) + + if (CMAKE_COMPILER_IS_CLANG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSIMDE_NO_CHECK_IMMEDIATE_CONSTANT") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSIMDE_NO_CHECK_IMMEDIATE_CONSTANT") + endif() if (SIMDE_NATIVE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVS_SIMDE_NATIVE -DSIMDE_ENABLE_OPENMP -fopenmp-simd") diff --git a/src/util/arch/arm/bitutils.h b/src/util/arch/arm/bitutils.h index 5ef5fbf4..04d001d3 100644 --- a/src/util/arch/arm/bitutils.h +++ b/src/util/arch/arm/bitutils.h @@ -203,6 +203,11 @@ u64a pext64_impl(u64a x, u64a mask) { return pext64_impl_c(x, mask); } +static really_inline +u64a pdep64_impl(u64a x, u64a mask) { + return pdep64_impl_c(x, mask); +} + /* compilers don't reliably synthesize the 32-bit ANDN instruction here, * so we force its generation. */ diff --git a/src/util/arch/ppc64el/bitutils.h b/src/util/arch/ppc64el/bitutils.h index 10c4869b..1741b09d 100644 --- a/src/util/arch/ppc64el/bitutils.h +++ b/src/util/arch/ppc64el/bitutils.h @@ -201,7 +201,7 @@ u64a pext64_impl(u64a x, u64a mask) { } static really_inline -u64a pdep64(u64a x, u64a mask) { +u64a pdep64_impl(u64a x, u64a mask) { return pdep64_impl_c(x, mask); } diff --git a/src/util/arch/x86/bitutils.h b/src/util/arch/x86/bitutils.h index 5c15ee91..485b6512 100644 --- a/src/util/arch/x86/bitutils.h +++ b/src/util/arch/x86/bitutils.h @@ -282,9 +282,14 @@ u64a pext64_impl(u64a x, u64a mask) { #if defined(HAVE_BMI2) && defined(ARCH_64_BIT) static really_inline -u64a pdep64(u64a x, u64a mask) { +u64a pdep64_impl(u64a x, u64a mask) { return _pdep_u64(x, mask); } +#else +static really_inline +u64a pdep64_impl(u64a x, u64a mask) { + return pdep64_impl_c(x, mask); +} #endif /* compilers don't reliably synthesize the 32-bit ANDN instruction here, diff --git a/src/util/bitutils.h b/src/util/bitutils.h index c67d5a85..8e9aae9c 100644 --- a/src/util/bitutils.h +++ b/src/util/bitutils.h @@ -78,6 +78,7 @@ #define rank_in_mask64_impl rank_in_mask64_impl_c #define pext32_impl pext32_impl_c #define pext64_impl pext64_impl_c +#define pdep64_impl pdep64_impl_c #endif static really_inline @@ -207,6 +208,11 @@ u64a pext64(u64a x, u64a mask) { return pext64_impl(x, mask); } +static really_inline +u64a pdep64(u64a x, u64a mask) { + return pdep64_impl(x, mask); +} + /* compilers don't reliably synthesize the 32-bit ANDN instruction here, * so we force its generation. */