Skip to content

Commit

Permalink
removed SVE check for C; cmake cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NishantPrabhuFujitsu committed Nov 29, 2024
1 parent 3ccdc87 commit cfc0b07
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 76 deletions.
40 changes: 17 additions & 23 deletions cmake/developer_package/compile_flags/os_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

include(ProcessorCount)
include(CheckCXXCompilerFlag)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)

#
Expand Down Expand Up @@ -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 <arm_sve.h>
Expand All @@ -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()

#
Expand Down Expand Up @@ -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}")
Expand All @@ -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}")
Expand All @@ -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)
Expand Down
61 changes: 8 additions & 53 deletions src/plugins/intel_cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,62 +277,17 @@ target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $<TARGET_PROPERTY:dnnl,
# is not (yet) needed.
target_include_directories(${TARGET_NAME} PRIVATE $<TARGET_PROPERTY:openvino::reference,INTERFACE_INCLUDE_DIRECTORIES>)

# Checking for SVE support in CXX and C
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCXXSourceCompiles)

SET(SVE_CODE "
#include <arm_sve.h>
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()
Expand Down

0 comments on commit cfc0b07

Please sign in to comment.