Skip to content

Commit

Permalink
Merge pull request intel#212 from VectorCamp/bugfix/fix-simde-build
Browse files Browse the repository at this point in the history
SIMDe on Clang needs SIMDE_NO_CHECK_IMMEDIATE_CONSTANT defined and other SIMDe related fixes now that SIMDe is part of the CI pipeline.

Some issue with SIMDe on x86 still remains because of an upstream bug:

simd-everywhere/simde#1119

Similarly SIMDe native with clang on Arm also poses a non-high priority build failure:

https://buildbot-ci.vectorcamp.gr/#/builders/129/builds/11

Possibly a SIMDe issue as well, need to investigate but will merge this PR as these are non-blockers.
  • Loading branch information
markos committed Dec 21, 2023
2 parents a26bed9 + 10d9574 commit 3113d1c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 29 deletions.
20 changes: 17 additions & 3 deletions cmake/archdetect.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
42 changes: 20 additions & 22 deletions cmake/osdetection.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,32 @@ 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()
if (NOT RELEASE_BUILD)
message(FATAL_ERROR "Fat runtime is only built on Release builds")
endif()
endif ()


10 changes: 8 additions & 2 deletions cmake/simde.cmake
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
5 changes: 5 additions & 0 deletions src/util/arch/arm/bitutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/util/arch/ppc64el/bitutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 6 additions & 1 deletion src/util/arch/x86/bitutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/util/bitutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 3113d1c

Please sign in to comment.