From 6d7f2f03ec4c7ee2a6ac23b3e8cfb4c26b285893 Mon Sep 17 00:00:00 2001 From: Pavel Rodionov Date: Thu, 20 Aug 2020 10:59:21 +0300 Subject: [PATCH] Revert "[GNA] Remove old GNA1 from Cmake scripts (#1686)" (#1864) This reverts commit ffe8599c309b32ef4bf6b6e73ea7a2edd2c048c0. --- inference-engine/cmake/FindlibGNA.cmake | 38 +++++++++++++++++-- .../cmake/check_features_ie.cmake | 5 +++ inference-engine/cmake/dependencies.cmake | 24 +++++++----- inference-engine/cmake/features_ie.cmake | 13 +++++-- 4 files changed, 63 insertions(+), 17 deletions(-) diff --git a/inference-engine/cmake/FindlibGNA.cmake b/inference-engine/cmake/FindlibGNA.cmake index 5968ec8624f7d7..a32466102e1cb5 100644 --- a/inference-engine/cmake/FindlibGNA.cmake +++ b/inference-engine/cmake/FindlibGNA.cmake @@ -14,20 +14,50 @@ endif () set(libGNA_FOUND TRUE) +set(GNA_KERNEL_LIB_NAME gna CACHE STRING "" FORCE) set(GNA_LIBS_LIST "libGNA::API" "libGNA::KERNEL") -set(libGNA_LIBRARIES_BASE_PATH "${GNA}/${GNA_PLATFORM_DIR}/x64" CACHE STRING "" FORCE) + +if (GNA_LIBRARY_VERSION STREQUAL "GNA1") + # use old version of GNA Library from gna_20181120 + if (WIN32) + set(GNA_LIB_DIR x64 CACHE STRING "" FORCE) + else () + list(APPEND GNA_LIBS_LIST + "libGNA::OLD_API_LIB") + set(GNA_LIB_DIR lib CACHE STRING "" FORCE) + set(GNA_KERNEL_LIB_NAME gna_kernel CACHE STRING "" FORCE) + endif() + set(libGNA_INCLUDE_DIRS "${GNA}/${GNA_PLATFORM_DIR}/include" CACHE STRING "" FORCE) +else() + # use current version of GNA library + set(GNA_LIB_DIR x64 CACHE STRING "" FORCE) + set(libGNA_INCLUDE_DIRS "${GNA}/include" CACHE STRING "" FORCE) +endif() +set(libGNA_LIBRARIES_BASE_PATH ${GNA}/${GNA_PLATFORM_DIR}/${GNA_LIB_DIR} CACHE STRING "" FORCE) add_library(libGNA::KERNEL SHARED IMPORTED) find_library(GNA_KERNEL_LIBRARY - gna + ${GNA_KERNEL_LIB_NAME} HINTS ${libGNA_LIBRARIES_BASE_PATH}) set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_LOCATION ${GNA_KERNEL_LIBRARY}) +if ((GNA_LIBRARY_VERSION STREQUAL "GNA1") AND (NOT WIN32)) + add_library(libGNA::OLD_API_LIB SHARED IMPORTED) + find_library(GNA_API_LIBRARY + gna_api + HINTS + ${libGNA_LIBRARIES_BASE_PATH}) + set_target_properties(libGNA::OLD_API_LIB PROPERTIES IMPORTED_LOCATION ${GNA_API_LIBRARY}) + target_link_libraries(libGNA::OLD_API_LIB INTERFACE libGNA::KERNEL) + set_target_properties(libGNA::OLD_API_LIB PROPERTIES IMPORTED_NO_SONAME TRUE) + set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_NO_SONAME TRUE) +endif() + add_library(libGNA::API INTERFACE IMPORTED) -set_property(TARGET libGNA::API PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GNA}/include") +set_property(TARGET libGNA::API PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${libGNA_INCLUDE_DIRS}) add_library(libGNA INTERFACE IMPORTED) foreach(_lib_name ${GNA_LIBS_LIST}) @@ -45,6 +75,6 @@ endforeach(_lib_name) if (WIN32) set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_IMPLIB ${GNA_KERNEL_LIBRARY}) -else() +elseif(NOT GNA_LIBRARY_VERSION STREQUAL "GNA1") set_target_properties(libGNA PROPERTIES INTERFACE_LINK_OPTIONS "-Wl,-rpath-link,${libGNA_LIBRARIES_BASE_PATH}") endif () diff --git a/inference-engine/cmake/check_features_ie.cmake b/inference-engine/cmake/check_features_ie.cmake index c156c7a906e291..9eccd8518f534e 100644 --- a/inference-engine/cmake/check_features_ie.cmake +++ b/inference-engine/cmake/check_features_ie.cmake @@ -25,6 +25,11 @@ endif() if (ENABLE_GNA) add_definitions(-DENABLE_GNA) + + if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4) + message(WARNING "${GNA_LIBRARY_VERSION} is not supported on GCC version ${CMAKE_CXX_COMPILER_VERSION}. Fallback to GNA1") + set(GNA_LIBRARY_VERSION GNA1) + endif() endif() if (ENABLE_SPEECH_DEMO) diff --git a/inference-engine/cmake/dependencies.cmake b/inference-engine/cmake/dependencies.cmake index 9a4302016b46fd..4555b11d256e36 100644 --- a/inference-engine/cmake/dependencies.cmake +++ b/inference-engine/cmake/dependencies.cmake @@ -274,16 +274,22 @@ if (ENABLE_GNA) GNA_LIB_DIR libGNA_INCLUDE_DIRS libGNA_LIBRARIES_BASE_PATH) - if(GNA_LIBRARY_VERSION STREQUAL "GNA1_1401") - set(GNA_VERSION "01.00.00.1401") - endif() - if(GNA_LIBRARY_VERSION STREQUAL "GNA2") - set(GNA_VERSION "02.00.00.1047") + if (GNA_LIBRARY_VERSION STREQUAL "GNA1") + RESOLVE_DEPENDENCY(GNA + ARCHIVE_UNIFIED "GNA/gna_20181120.zip" + TARGET_PATH "${TEMP}/gna") + else() + if(GNA_LIBRARY_VERSION STREQUAL "GNA1_1401") + set(GNA_VERSION "01.00.00.1401") + endif() + if(GNA_LIBRARY_VERSION STREQUAL "GNA2") + set(GNA_VERSION "02.00.00.1047") + endif() + RESOLVE_DEPENDENCY(GNA + ARCHIVE_UNIFIED "GNA/GNA_${GNA_VERSION}.zip" + TARGET_PATH "${TEMP}/gna_${GNA_VERSION}" + VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*") endif() - RESOLVE_DEPENDENCY(GNA - ARCHIVE_UNIFIED "GNA/GNA_${GNA_VERSION}.zip" - TARGET_PATH "${TEMP}/gna_${GNA_VERSION}" - VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*") update_deps_cache(GNA "${GNA}" "Path to GNA root folder") debug_message(STATUS "gna=" ${GNA}) endif() diff --git a/inference-engine/cmake/features_ie.cmake b/inference-engine/cmake/features_ie.cmake index 0d05f7bd7adbd0..948a2994984439 100644 --- a/inference-engine/cmake/features_ie.cmake +++ b/inference-engine/cmake/features_ie.cmake @@ -45,13 +45,18 @@ if (NOT THREADING STREQUAL "TBB" AND endif() if (ENABLE_GNA) - set (DEFAULT_GNA_LIB GNA2) + if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4) + set (DEFAULT_GNA_LIB GNA1) + else() + set (DEFAULT_GNA_LIB GNA2) + endif() set(GNA_LIBRARY_VERSION "${DEFAULT_GNA_LIB}" CACHE STRING "GNAVersion") - set_property(CACHE GNA_LIBRARY_VERSION PROPERTY STRINGS "GNA1_1401" "GNA2") + set_property(CACHE GNA_LIBRARY_VERSION PROPERTY STRINGS "GNA1" "GNA1_1401" "GNA2") list (APPEND IE_OPTIONS GNA_LIBRARY_VERSION) - if (NOT GNA_LIBRARY_VERSION STREQUAL "GNA1_1401" AND + if (NOT GNA_LIBRARY_VERSION STREQUAL "GNA1" AND + NOT GNA_LIBRARY_VERSION STREQUAL "GNA1_1401" AND NOT GNA_LIBRARY_VERSION STREQUAL "GNA2") - message(FATAL_ERROR "GNA_LIBRARY_VERSION should be set to GNA1_1401 or GNA2. Default option is ${DEFAULT_GNA_LIB}") + message(FATAL_ERROR "GNA_LIBRARY_VERSION should be set to GNA1, GNA1_1401 or GNA2. Default option is ${DEFAULT_GNA_LIB}") endif() endif()