diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 7f2beea9d5ab89..79b66c7c3c843a 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -155,6 +155,7 @@ jobs: -DENABLE_NCC_STYLE=OFF \ -DENABLE_TESTS=ON \ -DENABLE_WHEEL=OFF \ + -DENABLE_AVX512F=OFF \ -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF \ -DENABLE_STRICT_DEPENDENCIES=OFF \ -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CMAKE_CXX_COMPILER_LAUNCHER }} \ diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index 20b9dcebb88fca..c5d7c9e544f7ea 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -119,8 +119,8 @@ macro(ov_check_compiler_supports_sve flags) # If the compilation test is successful, set appropriate variables indicating support 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_FOUND ON CACHE BOOL "SVE available on host") + set(CXX_SVE_FOUND ON CACHE BOOL "CXX SVE support") set(CXX_SVE_FLAGS "${flags}" CACHE STRING "CXX SVE flags") endif() @@ -129,7 +129,7 @@ macro(ov_check_compiler_supports_sve flags) # If the compilation test fails, indicate that the support is not found if(NOT CXX_SVE_FOUND) - set(CXX_SVE_FOUND FALSE CACHE BOOL "CXX SVE support") + set(CXX_SVE_FOUND OFF CACHE BOOL "CXX SVE support") set(CXX_SVE_FLAGS "" CACHE STRING "CXX SVE flags") endif() @@ -143,6 +143,10 @@ endmacro() # Provides SSE4.2 compilation flags depending on an OS and a compiler # macro(ov_sse42_optimization_flags flags) + if(NOT ENABLE_SSE42) + message(FATAL_ERROR "Internal error: ENABLE_SSE42 if OFF and 'ov_sse42_optimization_flags' must not be called") + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # No such option for MSVC 2019 elseif(OV_COMPILER_IS_INTEL_LLVM) @@ -167,6 +171,10 @@ endmacro() # Provides AVX2 compilation flags depending on an OS and a compiler # macro(ov_avx2_optimization_flags flags) + if(NOT ENABLE_AVX2) + message(FATAL_ERROR "Internal error: ENABLE_AVX2 if OFF and 'ov_avx2_optimization_flags' must not be called") + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(${flags} /arch:AVX2) elseif(OV_COMPILER_IS_INTEL_LLVM) @@ -189,6 +197,10 @@ endmacro() # depending on an OS and a compiler # macro(ov_avx512_optimization_flags flags) + if(NOT ENABLE_AVX512F) + message(FATAL_ERROR "Internal error: ENABLE_AVX512F if OFF and 'ov_avx512_optimization_flags' must not be called") + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(${flags} /arch:AVX512) elseif(OV_COMPILER_IS_INTEL_LLVM AND WIN32) @@ -204,6 +216,10 @@ endmacro() # ov_arm_neon_optimization_flags() # macro(ov_arm_neon_optimization_flags flags) + if(NOT (AARCH64 OR ARM)) + message(FATAL_ERROR "Internal error: platform is not ARM or AARCH64 and 'ov_arm_neon_optimization_flags' must not be called") + endif() + if(OV_COMPILER_IS_INTEL_LLVM) message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") @@ -234,6 +250,10 @@ endmacro() # ov_arm_neon_fp16_optimization_flags() # macro(ov_arm_neon_fp16_optimization_flags flags) + if(NOT ENABLE_NEON_FP16) + message(FATAL_ERROR "Internal error: ENABLE_NEON_FP16 if OFF and 'ov_arm_neon_fp16_optimization_flags' must not be called") + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID} for arm64 platform") elseif(ANDROID) @@ -258,6 +278,10 @@ endmacro() # ov_arm_sve_optimization_flags() # macro(ov_arm_sve_optimization_flags flags) + if(NOT ENABLE_SVE) + message(FATAL_ERROR "Internal error: ENABLE_SVE if OFF and 'ov_arm_sve_optimization_flags' must not be called") + endif() + # Check for compiler SVE support ov_check_compiler_supports_sve("-march=armv8-a+sve") if(OV_COMPILER_IS_INTEL_LLVM) diff --git a/cmake/developer_package/features.cmake b/cmake/developer_package/features.cmake index d4dacf28039516..6ad47f0abcadb0 100644 --- a/cmake/developer_package/features.cmake +++ b/cmake/developer_package/features.cmake @@ -118,4 +118,4 @@ if(ENABLE_SVE) if(NOT CXX_HAS_SVE) set(ENABLE_SVE OFF CACHE BOOL "" FORCE) endif() -endif() \ No newline at end of file +endif() diff --git a/src/core/reference/CMakeLists.txt b/src/core/reference/CMakeLists.txt index 5f05431427bc21..56c06bd9138e27 100644 --- a/src/core/reference/CMakeLists.txt +++ b/src/core/reference/CMakeLists.txt @@ -24,9 +24,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME reference) if(ENABLE_AVX2) ov_avx2_optimization_flags(avx2_flags) - set(OV_REFERENCE_X86_AVX2_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/convert_x86_intrinsics.cpp - ) + set(OV_REFERENCE_X86_AVX2_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/op/convert_x86_intrinsics.cpp) set_source_files_properties(${OV_REFERENCE_X86_AVX2_SRC} PROPERTIES COMPILE_OPTIONS "${avx2_flags}" SKIP_UNITY_BUILD_INCLUSION ON SKIP_PRECOMPILE_HEADERS ON) diff --git a/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt b/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt index 4a4cc3952165e2..205ec0047195b5 100644 --- a/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/unit/vectorized/CMakeLists.txt @@ -66,12 +66,20 @@ if (ENABLE_SNIPPETS_LIBXSMM_TPP) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $) endif() -if (X86_64) - ov_avx2_optimization_flags(avx2_flags) - ov_avx512_optimization_flags(avx512_flags) +if(X86_64) + if(ENABLE_AVX2) + ov_avx2_optimization_flags(avx2_flags) + list(APPEND compile_flags ${avx2_flags}) + list(APPEND definitions HAVE_AVX2) + endif() + if(ENABLE_AVX512F) + ov_avx512_optimization_flags(avx512_flags) + list(APPEND compile_flags ${avx512_flags}) + list(APPEND definitions HAVE_AVX512F) + endif() - target_compile_options(${TARGET_NAME} PRIVATE "${avx2_flags};${avx512_flags}") - target_compile_definitions(${TARGET_NAME} PRIVATE HAVE_AVX2 HAVE_AVX512F) + target_compile_options(${TARGET_NAME} PRIVATE "${compile_flags}") + target_compile_definitions(${TARGET_NAME} PRIVATE ${definitions}) endif() diff --git a/src/plugins/intel_cpu/tests/unit/vectorized/paged_attn_cache_rotation.cpp b/src/plugins/intel_cpu/tests/unit/vectorized/paged_attn_cache_rotation.cpp index f6c48796932f8e..9150a25f37240d 100644 --- a/src/plugins/intel_cpu/tests/unit/vectorized/paged_attn_cache_rotation.cpp +++ b/src/plugins/intel_cpu/tests/unit/vectorized/paged_attn_cache_rotation.cpp @@ -416,6 +416,7 @@ class CacheRotationKernelInstructionParameterizedTest switch (instruction_set) { using namespace ov::Extensions::Cpu::XARCH; +#if defined(HAVE_AVX2) case TargetInstructionSet::AVX2: rotate_kv_cache_chunk_avx2(chunk_x.data(), chunk_y.data(), @@ -424,6 +425,8 @@ class CacheRotationKernelInstructionParameterizedTest num_elements_to_process, /* is_tail = */ num_elements_to_process < vec_len_f32_avx2); break; +#endif +#if defined(HAVE_AVX512F) case TargetInstructionSet::AVX512: rotate_kv_cache_chunk_avx512(chunk_x.data(), chunk_y.data(), @@ -432,6 +435,7 @@ class CacheRotationKernelInstructionParameterizedTest num_elements_to_process, /* is_tail = */ num_elements_to_process < vec_len_f32_avx512); break; +#endif default: FAIL() << "unknown target instruction set"; } @@ -454,6 +458,7 @@ TEST_P(CacheRotationKernelInstructionParameterizedTest, OptChunkRotationGivesRef test_chunk_rotation_for_type(); } +#if defined(HAVE_AVX2) || defined(HAVE_AVX512F) auto TEST_STRUCT_TO_NAME_FN = [](const testing::TestParamInfo& info) { size_t num_elts = std::get<1>(info.param); @@ -465,19 +470,24 @@ auto TEST_STRUCT_TO_NAME_FN = } return std::string("unknown"); }; +#endif +#if defined(HAVE_AVX2) INSTANTIATE_TEST_SUITE_P(AVX2, CacheRotationKernelInstructionParameterizedTest, ::testing::Combine(::testing::Values(TargetInstructionSet::AVX2), ::testing::Range(size_t(0), ov::Extensions::Cpu::XARCH::vec_len_f32_avx2 + 1)), TEST_STRUCT_TO_NAME_FN); +#endif +#if defined(HAVE_AVX512F) INSTANTIATE_TEST_SUITE_P(AVX512, CacheRotationKernelInstructionParameterizedTest, ::testing::Combine(::testing::Values(TargetInstructionSet::AVX512), ::testing::Range(size_t(0), ov::Extensions::Cpu::XARCH::vec_len_f32_avx512 + 1)), TEST_STRUCT_TO_NAME_FN); +#endif TYPED_TEST_P(CacheRotationKernelInputTypeParameterizedTest, OptBlockRotationGivesReferenceResults) { auto raw_cache_mem_ptr = this->cache_mem.data();