From: Ilya Lavrenov Date: Mon, 2 Nov 2020 21:55:49 +0000 (+0300) Subject: Compilation with MSVC for ARM (#2928) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a1451ed8f3c0b8c69460b7dac6f8a9d60703e43;p=platform%2Fupstream%2Fdldt.git Compilation with MSVC for ARM (#2928) * Enable compilation with MSVC for ARM / ARM64 * Condition fix --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ae1fbf..f9ac086 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ function(build_ngraph) ngraph_set(NGRAPH_UNIT_TEST_ENABLE FALSE) endif() - if(NOT (ANDROID OR WINDOWS_STORE)) + if(NOT (ANDROID OR WINDOWS_STORE OR (MSVC AND (ARM OR AARCH64)) )) ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE TRUE) else() ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE FALSE) diff --git a/cmake/check_features.cmake b/cmake/check_features.cmake index 798d46b..6932270 100644 --- a/cmake/check_features.cmake +++ b/cmake/check_features.cmake @@ -15,10 +15,6 @@ else() SET(ARCH_64 OFF) endif() -if (NOT ENABLE_MKL_DNN) - set(ENABLE_MKL OFF) -endif() - if(ENABLE_AVX512F) if ((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") AND (MSVC_VERSION VERSION_LESS 1920)) # 1920 version of MSVC 2019. In MSVC 2017 AVX512F not work diff --git a/cmake/developer_package.cmake b/cmake/developer_package.cmake index e8f6966..cda7afd 100644 --- a/cmake/developer_package.cmake +++ b/cmake/developer_package.cmake @@ -4,10 +4,27 @@ cmake_minimum_required(VERSION 3.13) +# Detect target +include(target_flags) + +string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH_FOLDER) +if(X86_64) + set(ARCH_FOLDER intel64) +elseif(X86) + set(ARCH_FOLDER ia32) +elseif(MSVC AND ARM) + set(ARCH_FOLDER arm) +elseif(MSVC AND AARCH64) + set(ARCH_FOLDER arm64) +endif() + list(APPEND CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake/download" - "${OpenVINO_MAIN_SOURCE_DIR}/cmake/cross_compile" - ) + "${OpenVINO_MAIN_SOURCE_DIR}/cmake/cross_compile") + +# +# CPack +# include(CPackComponent) unset(IE_CPACK_COMPONENTS_ALL CACHE) @@ -33,21 +50,14 @@ endif() # Set library directory for cpack # function(ie_cpack_set_library_dir) - string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH) - if(ARCH STREQUAL "x86_64" OR ARCH STREQUAL "amd64") # Windows detects Intel's 64-bit CPU as AMD64 - set(ARCH intel64) - elseif(ARCH STREQUAL "i386") - set(ARCH ia32) - endif() - if(WIN32) - set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) - set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/bin/${ARCH}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) - set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) + set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) + set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/bin/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) + set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) else() - set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE) - set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE) - set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE) + set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER} PARENT_SCOPE) + set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER} PARENT_SCOPE) + set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER} PARENT_SCOPE) endif() endfunction() @@ -109,28 +119,19 @@ function(set_temp_directory temp_variable source_tree_dir) endif() endfunction() +# +# Common scripts +# + include(coverage/coverage) include(shellcheck/shellcheck) # External dependencies find_package(Threads) -# Detect target -include(target_flags) - # printing debug messages include(debug) -# linking libraries without discarding symbols -include(whole_archive) - -string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH_FOLDER) -if(X86_64) - set(ARCH_FOLDER intel64) -elseif(X86) - set(ARCH_FOLDER ia32) -endif() - if(OS_FOLDER) message ("**** OS FOLDER IS: [${OS_FOLDER}]") if("${OS_FOLDER}" STREQUAL "ON") @@ -237,6 +238,7 @@ include(os_flags) include(sanitizer) include(cross_compiled_func) include(faster_build) +include(whole_archive) include(api_validator/api_validator) function(set_ci_build_number) diff --git a/cmake/features.cmake b/cmake/features.cmake index 91d30c4..e25d72f 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -17,11 +17,11 @@ ie_option (ENABLE_TESTS "unit, behavior and functional tests" OFF) ie_option (ENABLE_MKL_DNN "MKL-DNN plugin for inference engine" ${ENABLE_MKL_DNN_DEFAULT}) -ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON "WIN32 OR X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE; NOT WINDOWS_PHONE" OFF) +ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON "X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) # FIXME: there are compiler failures with LTO and Cross-Compile toolchains. Disabling for now, but # this must be addressed in a proper way -ie_dependent_option (ENABLE_LTO "Enable Link Time Optimization" OFF "LINUX OR WIN32;NOT CMAKE_CROSSCOMPILING; CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9" OFF) +ie_dependent_option (ENABLE_LTO "Enable Link Time Optimization" OFF "LINUX;NOT CMAKE_CROSSCOMPILING; CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9" OFF) ie_option (OS_FOLDER "create OS dedicated folder in output" OFF) diff --git a/cmake/os_flags.cmake b/cmake/os_flags.cmake index c91aaa9..09ae20a 100644 --- a/cmake/os_flags.cmake +++ b/cmake/os_flags.cmake @@ -127,8 +127,10 @@ function(ie_avx512_optimization_flags flags) endfunction() function(ie_arm_neon_optimization_flags flags) - if(WIN32 OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # nothing elseif(ANDROID) if(ANDROID_ABI STREQUAL "arm64-v8a") set(${flags} "-mfpu=neon" PARENT_SCOPE) diff --git a/cmake/target_flags.cmake b/cmake/target_flags.cmake index c51e0df..030fcbf 100644 --- a/cmake/target_flags.cmake +++ b/cmake/target_flags.cmake @@ -16,10 +16,25 @@ if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() endif() +macro(_ie_process_msvc_generator_platform flag_name) + # if cmake -A is passed + if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") + set(AARCH64 ON) + elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") + set(ARM ON) + elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x64") + set(X86_64 ON) + elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32") + set(X86 ON) + else() + set(${flag_name} ON) + endif() +endmacro() + if(MSVC64 OR MINGW64) - set(X86_64 ON) + _ie_process_msvc_generator_platform(X86_64) elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING)) - set(X86 ON) + _ie_process_msvc_generator_platform(X86) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") set(X86_64 ON) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*") diff --git a/cmake/vs_version/vs_version.cmake b/cmake/vs_version/vs_version.cmake index 7b9f45f..d857e2e 100644 --- a/cmake/vs_version/vs_version.cmake +++ b/cmake/vs_version/vs_version.cmake @@ -7,15 +7,15 @@ macro(ie_parse_ci_build_number) set(IE_VERSION_MAJOR ${CMAKE_MATCH_1}) set(IE_VERSION_MINOR ${CMAKE_MATCH_2}) set(IE_VERSION_PATCH ${CMAKE_MATCH_3}) - set(IE_VS_VER_HAS_WELL_DEFINED_VERSION 1) + set(IE_VS_VER_HAS_VERSION 1) else() - set(IE_VS_VER_HAS_WELL_DEFINED_VERSION 0) + set(IE_VS_VER_HAS_VERSION 0) endif() endmacro() ie_parse_ci_build_number() -if(IE_VS_VER_HAS_WELL_DEFINED_VERSION) +if(IE_VS_VER_HAS_VERSION) set(IE_VS_VER_FILEVERSION_QUAD "${IE_VERSION_MAJOR},${IE_VERSION_MINOR},${IE_VERSION_PATCH},0") set(IE_VS_VER_PRODUCTVERSION_QUAD "${IE_VERSION_MAJOR},${IE_VERSION_MINOR},${IE_VERSION_PATCH},0") set(IE_VS_VER_FILEVERSION_STR "${IE_VERSION_MAJOR}.${IE_VERSION_MINOR}.${IE_VERSION_PATCH}.0") diff --git a/cmake/vs_version/vs_version.rc.in b/cmake/vs_version/vs_version.rc.in index 96b545f..037247e 100644 --- a/cmake/vs_version/vs_version.rc.in +++ b/cmake/vs_version/vs_version.rc.in @@ -1,7 +1,7 @@ #include VS_VERSION_INFO VERSIONINFO -#if IE_VS_VER_HAS_WELL_DEFINED_VERSION +#if @IE_VS_VER_HAS_VERSION@ FILEVERSION @IE_VS_VER_FILEVERSION_QUAD@ PRODUCTVERSION @IE_VS_VER_PRODUCTVERSION_QUAD@ #endif @@ -20,7 +20,7 @@ BEGIN BLOCK "040904E4" BEGIN VALUE "FileDescription", "@IE_VS_VER_FILEDESCRIPTION_STR@\0" -#if IE_VS_VER_HAS_WELL_DEFINED_VERSION +#if @IE_VS_VER_HAS_VERSION@ VALUE "FileVersion", "@IE_VS_VER_FILEVERSION_STR@\0" #endif VALUE "InternalName", "@IE_VS_VER_INTERNALNAME_STR@\0" diff --git a/inference-engine/cmake/dependencies.cmake b/inference-engine/cmake/dependencies.cmake index 216d943..f863764 100644 --- a/inference-engine/cmake/dependencies.cmake +++ b/inference-engine/cmake/dependencies.cmake @@ -185,7 +185,7 @@ if (ENABLE_OPENCV) set(OPENCV_BUILD "36") set(OPENCV_BUILD_YOCTO "337") - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + if (AARCH64) if(DEFINED ENV{THIRDPARTY_SERVER_PATH}) set(IE_PATH_TO_DEPS "$ENV{THIRDPARTY_SERVER_PATH}") elseif(DEFINED THIRDPARTY_SERVER_PATH) @@ -220,10 +220,10 @@ if (ENABLE_OPENCV) ENVIRONMENT "OpenCV_DIR" VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*") elseif(LINUX) - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + if (AARCH64) set(OPENCV_SUFFIX "yocto_kmb") set(OPENCV_BUILD "${OPENCV_BUILD_YOCTO}") - elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") + elseif (ARM) set(OPENCV_SUFFIX "debian9arm") elseif (LINUX_OS_NAME STREQUAL "CentOS 7" OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9") set(OPENCV_SUFFIX "centos7") diff --git a/inference-engine/cmake/features_ie.cmake b/inference-engine/cmake/features_ie.cmake index ded5e71..df4105c 100644 --- a/inference-engine/cmake/features_ie.cmake +++ b/inference-engine/cmake/features_ie.cmake @@ -29,7 +29,7 @@ if (ENABLE_MKL_DNN) endif() # "MKL-DNN library based on OMP or TBB or Sequential implementation: TBB|OMP|SEQ" -if(ARM) +if(ARM OR (MSVC AND (ARM OR AARCH64)) ) set(THREADING_DEFAULT "SEQ") else() set(THREADING_DEFAULT "TBB") diff --git a/inference-engine/ie_bridges/c/samples/object_detection_sample_ssd/c_w_dirent.h b/inference-engine/ie_bridges/c/samples/object_detection_sample_ssd/c_w_dirent.h index 35aa9d3..ae24b5c 100644 --- a/inference-engine/ie_bridges/c/samples/object_detection_sample_ssd/c_w_dirent.h +++ b/inference-engine/ie_bridges/c/samples/object_detection_sample_ssd/c_w_dirent.h @@ -24,6 +24,14 @@ # define _AMD64_ #endif +#if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_) +# define _ARM_ +#endif + +#if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_) +# define _ARM64_ +#endif + #include #include #include diff --git a/inference-engine/samples/CMakeLists.txt b/inference-engine/samples/CMakeLists.txt index 94e19f2..236c17e 100644 --- a/inference-engine/samples/CMakeLists.txt +++ b/inference-engine/samples/CMakeLists.txt @@ -59,10 +59,6 @@ else () endif() if (WIN32) - if (NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - message(FATAL_ERROR "Only 64-bit supported on Windows") - endif() - set_property (DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS -DNOMINMAX") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") #no asynchronous structured exception handling diff --git a/inference-engine/samples/common/os/windows/w_dirent.h b/inference-engine/samples/common/os/windows/w_dirent.h index 495c1d2..928e190 100644 --- a/inference-engine/samples/common/os/windows/w_dirent.h +++ b/inference-engine/samples/common/os/windows/w_dirent.h @@ -24,6 +24,14 @@ # define _AMD64_ #endif +#if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_) +# define _ARM_ +#endif + +#if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_) +# define _ARM64_ +#endif + #include #include #include