Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Enable precompiled headers for CPU and GPU plugins (#30919)

Oleg Pipikin6b9d105c4eeb
diff --git a/cmake/developer_package/cross_compile/cross_compiled_func.cmake b/cmake/developer_package/cross_compile/cross_compiled_func.cmake
index 6605404e747..5f814fb207c 100644
--- a/cmake/developer_package/cross_compile/cross_compiled_func.cmake
+++ b/cmake/developer_package/cross_compile/cross_compiled_func.cmake
@@ -97,7 +97,7 @@ function(cross_compiled_file TARGET)
message(FATAL_ERROR "Missed arguments in 'cross_compiled_file'")
endif()
- ## format: ARCH1 ARCH2 <src1> ARCH3 <src2> ...
+ ## X_ARCH list format: ARCH1 ARCH2 <src1> ARCH3 <src2> ...
foreach(_it IN LISTS X_ARCH)
if(_it IN_LIST _AVAILABLE_ARCHS_LIST)
## that is arch ID
@@ -113,7 +113,7 @@ function(cross_compiled_file TARGET)
_remove_source_from_target(${TARGET} ${_src_name})
if(_CUR_ARCH_SET)
- _clone_source_to_target(${TARGET} ${_src_name} "${_CUR_ARCH_SET}")
+ _clone_source_to_target_with_archs(${TARGET} ${_src_name} "${_CUR_ARCH_SET}")
unset(_CUR_ARCH_SET)
endif()
endif()
@@ -125,10 +125,10 @@ endfunction()
##########################################
#
-# Add source multiple time per each element in ARCH_SET.
+# Add source to the TARGET per each element in ARCH_SET.
# Also provide corresponding arch specific flags and defines.
#
-function(_clone_source_to_target TARGET SOURCE ARCH_SET)
+function(_clone_source_to_target_with_archs TARGET SOURCE ARCH_SET)
foreach(_arch ${ARCH_SET})
set(_arch_dir cross-compiled/${_arch})
@@ -159,6 +159,9 @@ function(_clone_source_to_target TARGET SOURCE ARCH_SET)
set_property(SOURCE ${ARCH_SOURCE} APPEND PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/${ARCH_INCLUDE_DIR}")
+ ## disable pch for the source due to incompatibility with cross compilation
+ set_property(SOURCE ${ARCH_SOURCE} PROPERTY SKIP_PRECOMPILE_HEADERS ON)
+
list(APPEND _ARCH_SOURCES ${ARCH_SOURCE})
endforeach()
diff --git a/cmake/developer_package/faster_build.cmake b/cmake/developer_package/faster_build.cmake
index 61db001a314..54c198d1a98 100644
--- a/cmake/developer_package/faster_build.cmake
+++ b/cmake/developer_package/faster_build.cmake
@@ -16,17 +16,15 @@ function(ov_build_target_faster TARGET_NAME)
set_target_properties(${TARGET_NAME} PROPERTIES UNITY_BUILD ON)
endif()
- if((FASTER_BUILD_PCH OR FASTER_BUILD_PCH_HEADER) AND ENABLE_FASTER_BUILD)
+ if(ENABLE_FASTER_BUILD)
if (FASTER_BUILD_PCH_HEADER)
target_precompile_headers(${TARGET_NAME} PRIVATE ${FASTER_BUILD_PCH_HEADER})
- else()
+ elseif(FASTER_BUILD_PCH)
get_target_property(pch_core_header_path openvino::util PCH_CORE_HEADER_PATH)
if(NOT pch_core_header_path STREQUAL "pch_core_header_path-NOTFOUND")
target_precompile_headers(${TARGET_NAME} PRIVATE ${pch_core_header_path})
endif()
endif()
- foreach(exclude_src IN LISTS FASTER_BUILD_PCH_EXCLUDE)
- set_source_files_properties(${exclude_src} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
- endforeach()
+ set_source_files_properties(${FASTER_BUILD_PCH_EXCLUDE} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
endif()
endfunction()
diff --git a/src/plugins/intel_cpu/CMakeLists.txt b/src/plugins/intel_cpu/CMakeLists.txt
index cfe289f1a46..cf43559d679 100644
--- a/src/plugins/intel_cpu/CMakeLists.txt
+++ b/src/plugins/intel_cpu/CMakeLists.txt
@@ -361,6 +361,18 @@ ov_add_api_validator_post_build_step(TARGET ${TARGET_NAME})
# LTO
set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
+set(PCH_EXCLUDE_FILES
+ src/emitters/plugin/x64/debug_capabilities.cpp
+ src/nodes/executors/printers.cpp
+ src/emitters/snippets/x64/jit_debug_emitter.cpp
+ src/emitters/snippets/x64/jit_debug_emitter.cpp
+ src/emitters/snippets/x64/jit_perf_count_rdtsc_emitters.cpp
+ src/emitters/snippets/x64/jit_segfault_detector_emitter.cpp
+ src/emitters/snippets/x64/verbose.cpp
+ src/transformations/snippets/x64/op/perf_count_rdtsc.cpp)
+
+ov_build_target_faster(${TARGET_NAME} PCH PCH_EXCLUDE ${PCH_EXCLUDE_FILES})
+
#
# add test object library
#
@@ -416,6 +428,8 @@ if(BUILD_SHARED_LIBS)
# LTO
set_target_properties(${TARGET_NAME}_obj PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
+
+ ov_build_target_faster(${TARGET_NAME}_obj PCH PCH_EXCLUDE ${PCH_EXCLUDE_FILES})
endif()
if(ENABLE_TESTS)
diff --git a/src/plugins/intel_cpu/src/nodes/executors/deconv.cpp b/src/plugins/intel_cpu/src/nodes/executors/deconv.cpp
deleted file mode 100644
index d332de7194a..00000000000
--- a/src/plugins/intel_cpu/src/nodes/executors/deconv.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// Copyright (C) 2023 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
diff --git a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt
index 2e3a18c8472..4e90eae412f 100644
--- a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt
+++ b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt
@@ -111,6 +111,8 @@ ov_add_test_target(
ov_set_threading_interface_for(${TARGET_NAME})
+ov_build_target_faster(${TARGET_NAME} PCH)
+
include(cmake/specific_tests.cmake)
include(cmake/target_per_test.cmake)
diff --git a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt
index 1f1986190aa..67982358b98 100644
--- a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt
+++ b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt
@@ -105,6 +105,7 @@ endif()
ov_build_target_faster(${TARGET_NAME}
UNITY
+ PCH
)
function(group_source_file GROUP_NAME GROUP_DIR)
@@ -114,7 +115,7 @@ function(group_source_file GROUP_NAME GROUP_DIR)
endforeach()
endfunction()
-if(ENABLE_FASTER_BUILD)
+if(ENABLE_UNITY_BUILD)
set_target_properties(${TARGET_NAME} PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE GROUP)
group_source_file(unit_src_nodes ${CMAKE_CURRENT_SOURCE_DIR}/nodes)
group_source_file(unit_src_snippets_transformations ${CMAKE_CURRENT_SOURCE_DIR}/snippets_transformations)
diff --git a/src/plugins/intel_gpu/CMakeLists.txt b/src/plugins/intel_gpu/CMakeLists.txt
index 1731e4b868d..9556ab5873c 100644
--- a/src/plugins/intel_gpu/CMakeLists.txt
+++ b/src/plugins/intel_gpu/CMakeLists.txt
@@ -86,6 +86,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
LINK_FLAGS_RELWITHDEBINFO "-Wno-error=maybe-uninitialized -Wno-maybe-uninitialized -Wno-stringop-overflow")
endif()
+ov_build_target_faster(${TARGET_NAME} PCH)
+
if(ENABLE_TESTS)
add_subdirectory(tests)
endif()
diff --git a/src/plugins/intel_gpu/src/graph/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/CMakeLists.txt
index 6943c1cf4e7..b3ee51e242d 100644
--- a/src/plugins/intel_gpu/src/graph/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/graph/CMakeLists.txt
@@ -132,6 +132,8 @@ ov_add_target(
ADD_CPPLINT
)
+ov_build_target_faster(${TARGET_NAME} PCH)
+
target_compile_options(${TARGET_NAME} PRIVATE ${COMMON_COMPILE_OPTIONS})
ov_set_threading_interface_for(${TARGET_NAME})
diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/impls/cpu/CMakeLists.txt
index fc3a591cd1a..8f969feccda 100644
--- a/src/plugins/intel_gpu/src/graph/impls/cpu/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/CMakeLists.txt
@@ -15,3 +15,5 @@ if(ENABLE_SSE42)
COMPILE_FLAGS "${sse4_2_flags}"
COMPILE_DEFINITIONS "HAVE_SSE")
endif()
+
+ov_build_target_faster(${TARGET_NAME} PCH PCH_EXCLUDE detection_output.cpp)
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/impls/ocl/CMakeLists.txt
index 0bc093d9a49..5c6a00d6836 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/CMakeLists.txt
@@ -7,3 +7,5 @@ set(TARGET_NAME "openvino_intel_gpu_ocl_obj")
ov_gpu_add_backend_target(
NAME ${TARGET_NAME}
)
+
+ov_build_target_faster(${TARGET_NAME} PCH)
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/CMakeLists.txt
index a0f9f538d9a..8ed62189c21 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/CMakeLists.txt
@@ -51,3 +51,5 @@ ov_gpu_add_backend_target(
DEPENDENCIES run_ocl_codegen
ADD_CLANG_FORMAT
)
+
+ov_build_target_faster(${TARGET_NAME} PCH)
diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/impls/onednn/CMakeLists.txt
index 7f4f8390026..20381caf934 100644
--- a/src/plugins/intel_gpu/src/graph/impls/onednn/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/CMakeLists.txt
@@ -12,3 +12,5 @@ ov_gpu_add_backend_target(
NAME ${TARGET_NAME}
LINK_LIBRARIES onednn_gpu_tgt
)
+
+ov_build_target_faster(${TARGET_NAME} PCH)
diff --git a/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt b/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt
index 4ddc019cd0b..34b62d232c7 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt
@@ -92,6 +92,8 @@ else()
set(TUNING_CACHE_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/")
endif()
+ov_build_target_faster(${TARGET_NAME} PCH)
+
add_custom_command(
TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/cache/cache.json ${TUNING_CACHE_PATH}/cache.json)
diff --git a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
index ddccadfa338..85dfec05c41 100644
--- a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
+++ b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt
@@ -75,4 +75,6 @@ elseif((NOT ANDROID) AND (UNIX))
target_link_libraries(${TARGET_NAME} PRIVATE pthread)
endif()
+ov_build_target_faster(${TARGET_NAME} PCH)
+
ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE})
diff --git a/src/plugins/intel_gpu/tests/functional/CMakeLists.txt b/src/plugins/intel_gpu/tests/functional/CMakeLists.txt
index e4483000fa9..c89083a026a 100644
--- a/src/plugins/intel_gpu/tests/functional/CMakeLists.txt
+++ b/src/plugins/intel_gpu/tests/functional/CMakeLists.txt
@@ -58,3 +58,5 @@ if(WIN32)
target_compile_definitions(${TARGET_NAME} PRIVATE ENABLE_DX11)
target_link_libraries(${TARGET_NAME} PRIVATE d3d11 dxgi)
endif()
+
+ov_build_target_faster(${TARGET_NAME} PCH)
diff --git a/src/plugins/intel_gpu/tests/unit/CMakeLists.txt b/src/plugins/intel_gpu/tests/unit/CMakeLists.txt
index f07609ab042..aa40a800295 100644
--- a/src/plugins/intel_gpu/tests/unit/CMakeLists.txt
+++ b/src/plugins/intel_gpu/tests/unit/CMakeLists.txt
@@ -91,9 +91,11 @@ endif()
if(ENABLE_SSE42)
ov_sse42_optimization_flags(sse4_2_flags)
- set_source_files_properties(${SOURCES_ALL} PROPERTIES COMPILE_FLAGS "${sse4_2_flags}")
+ target_compile_options(${TARGET_NAME} PRIVATE ${sse4_2_flags})
endif()
+ov_build_target_faster(${TARGET_NAME} PCH)
+
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION tests
COMPONENT tests