diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index dae0368638f27b..660fd6160893ae 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -4,7 +4,6 @@ include(ProcessorCount) include(CheckCXXCompilerFlag) -include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) # @@ -94,11 +93,11 @@ macro(ov_dev_package_no_errors) endmacro() # -# ov_check_compiler_supports_sve(lang flags) +# ov_check_compiler_supports_sve(flags) # -# Checks whether compiler for passed language supports SVE code compilation +# Checks whether CXX compiler for passed language supports SVE code compilation # -macro(ov_check_compiler_supports_sve lang flags) +macro(ov_check_compiler_supports_sve flags) # Code to compile set(SVE_CODE " #include @@ -112,33 +111,29 @@ macro(ov_check_compiler_supports_sve lang flags) set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) # Set the flags necessary for compiling the test code with SVE support - set(CMAKE_REQUIRED_FLAGS "${CMAKE_${lang}_FLAGS_INIT} ${flags}") + set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${flags}") - # Check if the source code compiles with the given flags for the specified language (C or C++) - if(lang STREQUAL "CXX") - CHECK_CXX_SOURCE_COMPILES("${SVE_CODE}" ${lang}_HAS_SVE) - else() - CHECK_C_SOURCE_COMPILES("${SVE_CODE}" ${lang}_HAS_SVE) - endif() + # Check if the source code compiles with the given flags for C++ + CHECK_CXX_SOURCE_COMPILES("${SVE_CODE}" CXX_HAS_SVE) # If the compilation test is successful, set appropriate variables indicating support - if(${lang}_HAS_SVE) - set(${lang}_SVE_FOUND TRUE CACHE BOOL "SVE available on host") - set(${lang}_SVE_FOUND TRUE CACHE BOOL "${lang} SVE support") - set(${lang}_SVE_FLAGS "${flags}" CACHE STRING "${lang} SVE flags") + if(CXX_HAS_SVE) + set(CXX_SVE_FOUND TRUE CACHE BOOL "SVE available on host") + set(CXX_SVE_FOUND TRUE CACHE BOOL "CXX SVE support") + set(CXX_SVE_FLAGS "${flags}" CACHE STRING "CXX SVE flags") endif() # Restore the original state of required flags set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) # If the compilation test fails, indicate that the support is not found - if(NOT ${lang}_SVE_FOUND) - set(${lang}_SVE_FOUND FALSE CACHE BOOL "${lang} SVE support") - set(${lang}_SVE_FLAGS "" CACHE STRING "${lang} SVE flags") + if(NOT CXX_SVE_FOUND) + set(CXX_SVE_FOUND FALSE CACHE BOOL "CXX SVE support") + set(CXX_SVE_FLAGS "" CACHE STRING "CXX SVE flags") endif() # Mark the variables as advanced to hide them in the default CMake GUI - mark_as_advanced(${lang}_SVE_FOUND ${lang}_SVE_FLAGS) + mark_as_advanced(CXX_SVE_FOUND CXX_SVE_FLAGS) endmacro() # @@ -263,8 +258,7 @@ endmacro() # macro(ov_arm_sve_optimization_flags flags) # Check for compiler SVE support - ov_check_compiler_supports_sve(CXX "-march=armv8-a+sve") - ov_check_compiler_supports_sve(C "-march=armv8-a+sve") + ov_check_compiler_supports_sve("-march=armv8-a+sve") if(OV_COMPILER_IS_INTEL_LLVM) message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") @@ -273,7 +267,7 @@ macro(ov_arm_sve_optimization_flags flags) elseif(ANDROID) if(ANDROID_ABI STREQUAL "arm64-v8a") set(${flags} -Wno-unused-command-line-argument) - if(CXX_SVE_FOUND AND C_SVE_FOUND) + if(CXX_SVE_FOUND) list(APPEND ${flags} -march=armv8-a+sve) else() message(WARNING "SVE is not supported on this Android ABI: ${ANDROID_ABI}") @@ -286,7 +280,7 @@ macro(ov_arm_sve_optimization_flags flags) set(${flags} -O2) # Add flag for SVE if supported - if(CXX_SVE_FOUND AND C_SVE_FOUND) + if(CXX_SVE_FOUND) list(APPEND ${flags} -march=armv8-a+sve) endif() if(NOT CMAKE_CL_64) diff --git a/src/plugins/intel_cpu/CMakeLists.txt b/src/plugins/intel_cpu/CMakeLists.txt index 3aac6f98fb3a80..50158dae61d330 100644 --- a/src/plugins/intel_cpu/CMakeLists.txt +++ b/src/plugins/intel_cpu/CMakeLists.txt @@ -277,62 +277,17 @@ target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $) -# Checking for SVE support in CXX and C -INCLUDE(CheckCSourceCompiles) -INCLUDE(CheckCXXSourceCompiles) - -SET(SVE_CODE " -#include -int main() { - svfloat64_t a; - a = svdup_n_f64(0); - return 0; -} -") - -MACRO(CHECK_SVE lang flags) - # Save the current state of required flags - SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) - - # Set the flags necessary for compiling the test code with SVE support - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_${lang}_FLAGS_INIT} ${flags}") - - # Check if the source code compiles with the given flags for the specified language (C or C++) - IF(lang STREQUAL "CXX") - CHECK_CXX_SOURCE_COMPILES("${SVE_CODE}" ${lang}_HAS_SVE) - ELSE() - CHECK_C_SOURCE_COMPILES("${SVE_CODE}" ${lang}_HAS_SVE) - ENDIF() - - # If the compilation test is successful, set appropriate variables indicating support - IF(${lang}_HAS_SVE) - SET(${lang}_SVE_FOUND TRUE CACHE BOOL "SVE available on host") - SET(${lang}_SVE_FOUND TRUE CACHE BOOL "${lang} SVE support") - SET(${lang}_SVE_FLAGS "${flags}" CACHE STRING "${lang} SVE flags") - ENDIF() - - # Restore the original state of required flags - SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) - - # If the compilation test fails, indicate that the support is not found - IF(NOT ${lang}_SVE_FOUND) - SET(${lang}_SVE_FOUND FALSE CACHE BOOL "${lang} SVE support") - SET(${lang}_SVE_FLAGS "" CACHE STRING "${lang} SVE flags") - ENDIF() - - # Mark the variables as advanced to hide them in the default CMake GUI - MARK_AS_ADVANCED(${lang}_SVE_FOUND ${lang}_SVE_FLAGS) -ENDMACRO() - -CHECK_SVE(CXX "-march=armv8-a+sve") -CHECK_SVE(C "-march=armv8-a+sve") - # ARCH lists for softmax.cpp and mha_single_token.cpp # Based on result of above calls, decide whether to add SVE -set(SOFTMAX_ARCH_LIST AVX512F AVX2 NEON_FP16 ANY) -set(MHA_SINGLE_TOKEN_ARCH_LIST AVX512F AVX2 NEON_FP16 ANY) +set(SOFTMAX_ARCH_LIST AVX512F AVX2 ANY) +set(MHA_SINGLE_TOKEN_ARCH_LIST AVX512F AVX2 ANY) + +if(ENABLE_NEON_FP16) + list(APPEND SOFTMAX_ARCH_LIST NEON_FP16) + list(APPEND MHA_SINGLE_TOKEN_ARCH_LIST NEON_FP16) +endif() -if(CXX_SVE_FOUND AND C_SVE_FOUND) +if(ENABLE_SVE) list(APPEND SOFTMAX_ARCH_LIST SVE) list(APPEND MHA_SINGLE_TOKEN_ARCH_LIST SVE) endif()