diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c20423448fb41..0447b5514947d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,32 @@ # SPDX-License-Identifier: Apache-2.0 # -if (NOT ENABLE_INTEL_GNA) - return() -endif() +cmake_minimum_required(VERSION 3.22) + +project(OpenvinoGnaPlugin) + +find_package(OpenVINODeveloperPackage REQUIRED) + +set(GNA_LIB_VERSION "03.05.00.1906" CACHE STRING "GNA Library version number") +set(GNA_ROOT_DIR ${OpenVINO_SOURCE_DIR}/temp/gna_${GNA_LIB_VERSION}) + +set(GNA_PATH ${GNA_ROOT_DIR}/win64/x64) +set(GNA_EXT_DIR ${GNA_ROOT_DIR}) +set(GNA_PLUGIN_OUTPUT_DIR ${CMAKE_BINARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${GNA_PLUGIN_OUTPUT_DIR}/${BIN_FOLDER}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GNA_PLUGIN_OUTPUT_DIR}/${BIN_FOLDER}) +set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${GNA_PLUGIN_OUTPUT_DIR}/${BIN_FOLDER}) +set(CMAKE_PDB_OUTPUT_DIRECTORY ${GNA_PLUGIN_OUTPUT_DIR}/${BIN_FOLDER}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GNA_PLUGIN_OUTPUT_DIR}/${BIN_FOLDER}) + +message("OpenVINO source directory = ${OpenVINO_SOURCE_DIR}") +message("GNA package directory = ${GNA_ROOT_DIR}") +message("Artifacts directory = ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + +enable_testing() + +#deal with setup of legacy projects first... add_subdirectory(legacy) set(TARGET_NAME "openvino_intel_gna_plugin") @@ -76,13 +98,17 @@ target_compile_definitions(${TARGET_NAME}_test_static INTEGER_LOW_P USE_STATIC_IE) -target_link_libraries(${TARGET_NAME}_test_static PUBLIC inference_engine_s inference_engine_transformations libGNA::API) + +target_link_libraries(${TARGET_NAME}_test_static + PUBLIC debug inference_engine_sd optimized inference_engine_s + PUBLIC libGNA::API) target_include_directories(${TARGET_NAME}_test_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src $ PRIVATE - $) + $ + $) set_target_properties(${TARGET_NAME} ${TARGET_NAME}_test_static PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) diff --git a/README.md b/README.md new file mode 100644 index 00000000000000..624367e9bc092c --- /dev/null +++ b/README.md @@ -0,0 +1,92 @@ +## Plugin Compilation + + +#### Assumptions + +- OpenVINO version used 2023.0 (**branch releases/2023/0**) +- Commands syntax is bash-based +- There are following (environmental) variables defined: +````bash +export openvino_source_dir = +export developer_package_dir = +export build_type = +export gna_plugin_source_dir = +export gna_plugin_build_dir = +```` + + +#### Prerequisties + +Switch to respective version of openvino +````bash +cd $openvino_source_dir +git checkout releases/2023/0 +```` + +Prepare openvino developer package (build openvino) +````bash +cmake -S $openvino_source_dir -B $developer_package_dir -D CMAKE_BUILD_TYPE=$build_type -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON +cmake --build $developer_package_dir --target ov_dev_targets --config $build_type +```` +> **Note** +> - It's important to keep in mind that `CMAKE_BUILD_TYPE` has no effect for multi-configuration generators such as Visual Studio. Therefore in this case config type has to be provided to build command as above. +> - There is yet another target `ie_dev_targets` can be used, but it seems to have identical result as `ov_dev_targets` + +Clone **gna.plugin** repository +````bash +git clone https://github.com/intel-innersource/frameworks.ai.gna.plugin.git $gna_plugin_source_dir +```` + + +#### Plugin build + +Create **gna.plugin** solution +````bash +cmake -S $gna_plugin_source_dir -B $gna_plugin_build_dir -D OpenVINODeveloperPackage_DIR=$developer_package_dir -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON +```` + +It happens often that for development purposes many versions of gna library exist in openvino `temp\` directory. Therefore it is possible to use specific version of the library by defining `GNA_LIB_VERSION` otherwise default version defined in main `CMakeLists.txt` will be applied +````bash +export gna_version= +cmake -S $gna_plugin_source_dir -B $gna_plugin_build_dir -D OpenVINODeveloperPackage_DIR=$developer_package_dir -D ENABLE_TESTS=ON -D ENABLE_FUNCTIONAL_TESTS=ON -D GNA_LIB_VERSION=$gna_version +```` + + +Run build +````bash +cmake --build $gna_plugin_build_dir --config $build_type +```` +> **Note** +> Developer package has bo be built for respective configuration type otherwise gna plugin build will fail. + +#### Plugin's tests build and run + +By default all tests are compiled during plugin build, however there is a possibility to selectively compile selected tests by using `--target` option. + +For example to compile unit tests use `ov_gna_unit_tests` target run +````bash +cmake --build $gna_plugin_build_dir --config $build_type --target ov_gna_unit_tests +```` + +In order to run tests do +````bash +cd $gna_plugin_build_dir +ctest -C $build_type +```` + +> **Note** +> Currently only `ov_gna_unit_tests` are supported + +#### Handy tips + +Sometimes it is handy to run cmake project generation in trace mode in order to figure out what happened. In order to do this add cmake's `--trace-source=` option. Besides option `--trace-expand` will expand variable into their values. + +For example command below will print out trace messsages from `libGNAConfig.cmake` file +````bash +cmake -S $gna_plugin_source_dir -B $gna_plugin_build_dir -D OpenVINODeveloperPackage_DIR=$developer_package_dir -D OV_ROOT_DIR=$openvino_source_dir --trace-source=libGNAConfig.cmake --trace-expand +```` + +#### References + +https://docs.openvino.ai/2022.1/openvino_docs_ie_plugin_dg_plugin_build.html +https://docs.openvino.ai/2022.3/openvino_docs_ie_plugin_dg_plugin_build.html diff --git a/legacy/CMakeLists.txt b/legacy/CMakeLists.txt index ac53784b1e493f..aca0a5228926e3 100644 --- a/legacy/CMakeLists.txt +++ b/legacy/CMakeLists.txt @@ -34,12 +34,12 @@ ie_faster_build(${TARGET_NAME}_obj target_include_directories(${TARGET_NAME}_obj PRIVATE ${PUBLIC_HEADERS_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src - $/src # For CNNNetworkNGraphImpl + ${OpenVINO_SOURCE_DIR}/src/inference/src #For CNNNetworkNGraphImpl. ptomasz1: Dirty hack, but inference_engine_obj is not exported in developer package $ $ $/src/ops) -target_compile_definitions(${TARGET_NAME}_obj PRIVATE $) +target_compile_definitions(${TARGET_NAME}_obj PRIVATE $) target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt) @@ -69,7 +69,7 @@ target_include_directories(${TARGET_NAME}_s $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - $/src # For CNNNetworkNGraphImpl + ${OpenVINO_SOURCE_DIR}/src/inference/src #For CNNNetworkNGraphImpl. ptomasz1: Dirty hack, but inference_engine_obj is not exported in developer package $ $ $/src/ops) diff --git a/legacy/tests/CMakeLists.txt b/legacy/tests/CMakeLists.txt index b07cd7090cc6d6..73b4ab7ed6092f 100644 --- a/legacy/tests/CMakeLists.txt +++ b/legacy/tests/CMakeLists.txt @@ -9,24 +9,36 @@ endif() set(TARGET_NAME ov_legacy_transformations_tests) -ov_add_test_target( - NAME ${TARGET_NAME} - ROOT ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDENCIES - LINK_LIBRARIES - gmock - func_test_utils - sharedTestClasses - lptNgraphFunctions - inference_engine_legacy - ADD_CLANG_FORMAT - INCLUDES - $/src - LABELS - TRANSFORMATIONS +file(GLOB MODULE_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp" +) + +add_executable(${TARGET_NAME} ${MODULE_SOURCES}) + +target_include_directories(${TARGET_NAME} PRIVATE + $ + ${OV_ROOT_DIR}/src/inference/src #For CNNNetworkNGraphImpl. ptomasz1: Dirty hack, but inference_engine_obj is not exported in developer package +) + +target_link_libraries(${TARGET_NAME} + openvino::gmock + openvino::gtest + openvino::gtest_main + openvino::ngraphFunctions + openvino::commonTestUtils + openvino::funcTestUtils + inference_engine_legacy ) if(WIN32) string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") endif() + +set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${OpenVINO_SOURCE_DIR}/temp/tbb/bin;${OpenVINO_SOURCE_DIR}/${BIN_FOLDER}/$") + +add_test(NAME ${TARGET_NAME}_run COMMAND ${TARGET_NAME}) +set_tests_properties(${TARGET_NAME}_run PROPERTIES ENVIRONMENT "PATH=${OpenVINO_SOURCE_DIR}/temp/tbb/bin") +set_tests_properties(${TARGET_NAME}_run PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_append:${OpenVINO_SOURCE_DIR}/${BIN_FOLDER}/$") + diff --git a/legacy/tests/keep_constant_inputs_tests.cpp b/legacy/tests/keep_constant_inputs_tests.cpp index 6a7025d7e427a4..10368fecbcf43e 100644 --- a/legacy/tests/keep_constant_inputs_tests.cpp +++ b/legacy/tests/keep_constant_inputs_tests.cpp @@ -22,7 +22,6 @@ #include #include "ngraph_functions/subgraph_builders.hpp" -#include "shared_test_classes/base/low_precision_transformations/layer_transformation.hpp" using namespace testing; using namespace InferenceEngine; diff --git a/legacy/tests/mul_add_conversion_test.cpp b/legacy/tests/mul_add_conversion_test.cpp index 10dc436ed7f666..697609128aa59a 100644 --- a/legacy/tests/mul_add_conversion_test.cpp +++ b/legacy/tests/mul_add_conversion_test.cpp @@ -26,7 +26,6 @@ #include "common_test_utils/ngraph_test_utils.hpp" #include "common_test_utils/test_common.hpp" -#include "lpt_ngraph_functions/common/builders.hpp" using namespace testing; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cd02a93f74b151..f7edfb547fc8ab 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,8 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # -enable_testing() - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") ie_add_compiler_flags(/wd4244) ie_add_compiler_flags(/wd4267) @@ -20,13 +18,11 @@ else() endif() if(ENABLE_TESTS) - add_subdirectory(deprecated/readers) - add_subdirectory(deprecated/helpers) - add_subdirectory(unit) - add_subdirectory(deprecated/unit) +# add_subdirectory(deprecated/unit) endif() if(ENABLE_FUNCTIONAL_TESTS) - add_subdirectory(functional) +# add_subdirectory(deprecated/functional) +# add_subdirectory(functional) endif() diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 912d28d728b41d..7e318f9c53cf4e 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -12,32 +12,52 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) endif() -# TODO: fix CVS-71010 and remove BUILD_SHARED_LIBS -if(NOT BUILD_SHARED_LIBS) - set(exclude_path EXCLUDED_SOURCE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/(gna_api_stub|gna_wait_test|gna_export_import_test|gna_infer_request_test|gna_plugin_load_network_test|gna_mock_api_initializer|gna_extra_pwl_segments_tests).cpp") -endif() +file(GLOB MODULE_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/**/*.hpp" +) + +add_executable(${TARGET_NAME} ${MODULE_SOURCES}) + +target_link_libraries(${TARGET_NAME} + openvino::gmock + openvino::gtest + openvino::gtest_main + openvino::ngraphFunctions + openvino::commonTestUtils + inference_engine_legacy_s + openvino_intel_gna_plugin_test_static +) -addIeTargetTest( - NAME ${TARGET_NAME} - ROOT ${CMAKE_CURRENT_SOURCE_DIR} - ${exclude_path} - LINK_LIBRARIES - PRIVATE - ngraphFunctions - gmock - common_test_utils_s - openvino_intel_gna_plugin_test_static - inference_engine_legacy_s - ADD_CLANG_FORMAT - LABELS - GNA +target_include_directories(${TARGET_NAME} + PRIVATE ${OpenVINO_SOURCE_DIR}/src/inference/src +) + +#needed in order to locate inference_engine_s.lib +target_link_directories(${TARGET_NAME} + PRIVATE "${OpenVINO_SOURCE_DIR}/bin/intel64/$" ) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS -IGNORE:4286) + + #FIXME the flag allows to solve linker error 2005 (Symbol already defined) + # by taking into account first occurence of the symbol and ignoring rest of them. + # In this case the problem ocucrs in Release version only. + # Duplicated symbol definitions are generated by all source files include "ie_common.h" header + # Very likely the issue is caused by IE_ASSERT definition in ie_common.h:450-452. + target_link_options(${TARGET_NAME} PRIVATE "/FORCE") endif() if(SUGGEST_OVERRIDE_SUPPORTED) set_source_files_properties(gna_model_serial_test.cpp PROPERTIES COMPILE_OPTIONS -Wno-suggest-override) endif() + +set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${OpenVINO_SOURCE_DIR}/temp/tbb/bin;${OpenVINO_SOURCE_DIR}/${BIN_FOLDER}/$") + +add_test(NAME ${TARGET_NAME}_run COMMAND ${TARGET_NAME}) +set_tests_properties(${TARGET_NAME}_run PROPERTIES ENVIRONMENT "PATH=${OpenVINO_SOURCE_DIR}/temp/tbb/bin") +set_tests_properties(${TARGET_NAME}_run PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_append:${OpenVINO_SOURCE_DIR}/${BIN_FOLDER}/$")