OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[AUTO] Link IPF ClientApi statically (#37502)
Wang, Yanga4840caac959
diff --git a/cmake/toolchains/mt.runtime.win32.toolchain.cmake b/cmake/toolchains/mt.runtime.win32.toolchain.cmakeindex 1b5ead8b86a..b9dc428a7b1 100644--- a/cmake/toolchains/mt.runtime.win32.toolchain.cmake+++ b/cmake/toolchains/mt.runtime.win32.toolchain.cmake@@ -67,10 +67,6 @@ ov_set_msvc_runtime(CLDNN__COMPILE_LINK_USE_STATIC_RUNTIME ${use_static_runtime}ov_set_msvc_runtime(USE_DYNAMIC_VCXX_RUNTIME ${use_dynamic_runtime})# google-testov_set_msvc_runtime(gtest_force_shared_crt ${use_dynamic_runtime})-# AUTO plugin IPF telemetry client (ClientApi is only built against dynamic CRT)-if(use_static_runtime)- ov_set_msvc_runtime(ENABLE_IPF_CLIENT_API OFF)-endif()unset(use_static_runtime)unset(use_dynamic_runtime)diff --git a/src/plugins/auto/CMakeLists.txt b/src/plugins/auto/CMakeLists.txtindex 6f578744479..e31db2356e4 100644--- a/src/plugins/auto/CMakeLists.txt+++ b/src/plugins/auto/CMakeLists.txt@@ -45,13 +45,10 @@ endif()find_package(Threads REQUIRED)target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads)-# Enable the IPF-backed device utilization monitor when IPF was built.-# ClientApi is linked as an ordinary DLL import library and called only through its-# plain-C ABI (ClientApiC.h). No IPF-compiled objects are embedded into this plugin,-# so ${TARGET_NAME} keeps following OpenVINO's normal /MD (Release) or /MDd (Debug)-# convention regardless of IPF's own (fixed /MD) runtime library choice.+# Enable IPF support with the statically linked C API.+# ClientApi_IMPORTS must remain undefined for static linking.if(TARGET openvino::ipf_client_api)- target_compile_definitions(${TARGET_NAME} PRIVATE OV_AUTO_ENABLE_IPF ClientApi_IMPORTS)+ target_compile_definitions(${TARGET_NAME} PRIVATE OV_AUTO_ENABLE_IPF)target_link_libraries(${TARGET_NAME} PRIVATE openvino::ipf_client_api)target_include_directories(${TARGET_NAME} SYSTEM PRIVATE$<TARGET_PROPERTY:nlohmann_json::nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>)diff --git a/src/plugins/auto/src/utils/device_telemetry.cpp b/src/plugins/auto/src/utils/device_telemetry.cppindex 53d620bf0f7..24f12e4828e 100644--- a/src/plugins/auto/src/utils/device_telemetry.cpp+++ b/src/plugins/auto/src/utils/device_telemetry.cpp@@ -90,9 +90,7 @@ std::optional<float> parse_utilization_from_aiselector_json_impl(const std::stri} // namespace-// Calls into ClientApi.dll through the plain-C ABI (ClientApiC.h).-// The callback context is a heap-allocated shared_ptr<atomic<int>>; Impl deletes it only after-// IpfUnregisterEvent returns, ensuring no in-flight callback can outlive the pointed-to memory.+// Calls into the statically linked IPF ClientApi through the plain-C ABI (ClientApiC.h).class TelemetryClient::Impl {public:static void handle_gear_changed_event(void* context, const std::string& gear_str) {diff --git a/src/plugins/auto/tests/unit/CMakeLists.txt b/src/plugins/auto/tests/unit/CMakeLists.txtindex c350c4ea7f7..5e92a672d6b 100644--- a/src/plugins/auto/tests/unit/CMakeLists.txt+++ b/src/plugins/auto/tests/unit/CMakeLists.txt@@ -29,7 +29,7 @@ ov_add_test_target(ov_add_version_defines(${OpenVINO_SOURCE_DIR}/src/plugins/auto/src/plugin.cpp ${TARGET_NAME})if(TARGET openvino::ipf_client_api)- target_compile_definitions(${TARGET_NAME} PRIVATE OV_AUTO_ENABLE_IPF ClientApi_IMPORTS)+ target_compile_definitions(${TARGET_NAME} PRIVATE OV_AUTO_ENABLE_IPF)target_link_libraries(${TARGET_NAME} PRIVATE openvino::ipf_client_api)target_include_directories(${TARGET_NAME} SYSTEM PRIVATE$<TARGET_PROPERTY:nlohmann_json::nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>)diff --git a/src/plugins/auto/thirdparty/CMakeLists.txt b/src/plugins/auto/thirdparty/CMakeLists.txtindex 4077b7bbe9e..ff113479e18 100644--- a/src/plugins/auto/thirdparty/CMakeLists.txt+++ b/src/plugins/auto/thirdparty/CMakeLists.txt@@ -2,10 +2,9 @@# SPDX-License-Identifier: Apache-2.0#-# Intel Platform Framework (IPF) telemetry client from submodule (MSVC only).-# ClientApi requires dynamic CRT (/MD); static CRT toolchain sets-# ENABLE_IPF_CLIENT_API=OFF.-# Only ClientApi shared library is linked via ClientApiC.h.+# Intel Platform Framework (IPF) telemetry client (MSVC only).+# ClientApiLib is linked statically into openvino_auto_plugin.+# IPF requires the dynamic CRT (/MD); static CRT toolchains disable IPF.set(_ipf_ef_dir "${CMAKE_CURRENT_SOURCE_DIR}/ipf/IPF_EF")@@ -30,26 +29,38 @@ if(TARGET nlohmann_json::nlohmann_json OR TARGET nlohmann_json)set_property(GLOBAL PROPERTY _FetchContent_nlohmann_json_populated TRUE)endif()+# Use the same configuration-specific dynamic CRT for ClientApiLib and the plugin.+if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)+ set(_ov_msvc_runtime "${CMAKE_MSVC_RUNTIME_LIBRARY}")+else()+ set(_ov_msvc_runtime "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")+endif()+add_subdirectory("${_ipf_ef_dir}" "${CMAKE_CURRENT_BINARY_DIR}/ipf" EXCLUDE_FROM_ALL)-if(NOT TARGET ClientApi)- message(STATUS "[AUTO] IPF: ClientApi target not produced by submodule, device utilization monitoring disabled")+if(NOT TARGET ClientApiLib)+ message(STATUS "[AUTO] IPF: ClientApiLib target not produced by submodule, device utilization monitoring disabled")return()endif()-set_target_properties(ClientApi PROPERTIES EXPORT_NAME ipf_client_api)-add_library(openvino::ipf_client_api ALIAS ClientApi)+set_target_properties(ClientApiLib PROPERTIES EXPORT_NAME ipf_client_api+ MSVC_RUNTIME_LIBRARY "${_ov_msvc_runtime}")+add_library(openvino::ipf_client_api ALIAS ClientApiLib)-if(NOT BUILD_SHARED_LIBS)- install(TARGETS ClientApi EXPORT OpenVINOTargets- RUNTIME DESTINATION ${OV_CPACK_PLUGINSDIR} COMPONENT ${OV_CPACK_COMP_CORE} ${OV_CPACK_COMP_CORE_EXCLUDE_ALL}- ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE_DEV} ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL})- export(TARGETS ClientApi NAMESPACE openvino::- APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")-else()- install(TARGETS ClientApi- RUNTIME DESTINATION ${OV_CPACK_PLUGINSDIR} COMPONENT ${OV_CPACK_COMP_CORE} ${OV_CPACK_COMP_CORE_EXCLUDE_ALL}- ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE_DEV} ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL})+# The submodule also defines the stand-alone ClientApi DLL, which OpenVINO does not ship.+if(TARGET ClientApi)+ set_target_properties(ClientApi PROPERTIES EXCLUDE_FROM_ALL TRUE+ EXCLUDE_FROM_DEFAULT_BUILD TRUE)endif()-message(STATUS "[AUTO] IPF: successfully configured")+# Keep the header-only nlohmann/json dependency out of the exported link interface.+get_target_property(_ipf_link_interface ClientApiLib INTERFACE_LINK_LIBRARIES)+if(_ipf_link_interface)+ list(FILTER _ipf_link_interface EXCLUDE REGEX "^(\\$<LINK_ONLY:)?nlohmann_json(::nlohmann_json)?>?$")+ set_property(TARGET ClientApiLib PROPERTY INTERFACE_LINK_LIBRARIES "${_ipf_link_interface}")+endif()++# Install ClientApiLib for static OpenVINO builds.+ov_install_static_lib(ClientApiLib ${OV_CPACK_COMP_CORE_DEV} ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL})++message(STATUS "[AUTO] IPF: successfully configured (ClientApiLib linked statically)")