host build and cross build
now cmake status:
a: host build
1: windows build -- ok
2: linux build -- ok
3: macos build -- ok
b: cross build
1: windows cross build arm-android -- ok
2: windows cross build arm-linux -- ok
3: linux cross build arm-android -- ok
4: linux cross build arm-linux -- ok
5: macos cross build arm-android -- ok
6: macos cross build arm-linux -- ok
7: macos cross build ios -- ok
GitOrigin-RevId: f7f376fe8c
tags/v0.5.0
| @@ -7,7 +7,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) | |||
| set(CMAKE_POSITION_INDEPENDENT_CODE ON) | |||
| set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) | |||
| if(NOT MSVC AND NOT APPLE) | |||
| if(NOT MSVC AND NOT APPLE AND NOT WIN32) | |||
| set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>") | |||
| set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>") | |||
| set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>") | |||
| @@ -72,7 +72,7 @@ if(CMAKE_TOOLCHAIN_FILE) | |||
| endif() | |||
| if(${MGE_ARCH} STREQUAL "AUTO") | |||
| if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") | |||
| if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") | |||
| set(MGE_ARCH "x86_64") | |||
| elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686") | |||
| set(MGE_ARCH "i386") | |||
| @@ -85,8 +85,42 @@ if(${MGE_ARCH} STREQUAL "AUTO") | |||
| endif() | |||
| endif() | |||
| if(MSVC OR WIN32) | |||
| add_compile_definitions(NOMINMAX=1 _USE_MATH_DEFINES=1 WIN32=1) | |||
| message("-- into windows build...") | |||
| message(" -- CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}") | |||
| if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang-cl") | |||
| message(FATAL_ERROR "only support clang-cl for windows build, pls check detail: scripts/cmake-build/BUILD_README.md") | |||
| endif() | |||
| # add flags for sse/avx for X86 | |||
| set(WIN_FLAGS "-msse4.2 -mavx -mavx2") | |||
| # if u CPU is cascadelake series, u can enable for performance | |||
| # set(WIN_FLAGS "{WIN_FLAGS} -march=cascadelake -mtune=cascadelake") | |||
| # set(WIN_FLAGS "{WIN_FLAGS} -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi -mavx512vnni") | |||
| # for windows build | |||
| set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=implicit-int-conversion -Wno-error=double-promotion") | |||
| set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=zero-as-null-pointer-constant -Wno-error=implicit-int-conversion") | |||
| set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=float-conversion -Wno-error=shadow-field -Wno-error=covered-switch-default") | |||
| set(WIN_FLAGS "${WIN_FLAGS} -Wno-error=deprecated -Wno-error=documentation -Wno-error=unreachable-code-break") | |||
| set(WIN_FLAGS "${WIN_FLAGS} /DWIN32 -Wno-macro-redefined /D_WIN32_WINNT=0x0601") | |||
| set(WIN_FLAGS "${WIN_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /DNOGDI /D_USE_MATH_DEFINES /bigobj") | |||
| set(WIN_FLAGS "${WIN_FLAGS} /Zm500 /EHs /wd4351 /wd4291 /wd4250 /wd4996 /wd4819 -Wno-inconsistent-dllimport") | |||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WIN_FLAGS}") | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WIN_FLAGS}") | |||
| else() | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | |||
| set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") | |||
| if(ANDROID) | |||
| set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -DNDEBUG") | |||
| else() | |||
| set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") | |||
| endif() | |||
| endif() | |||
| CHECK_CXX_COMPILER_FLAG(-fuse-ld=gold CXX_SUPPORT_GOLD) | |||
| if(CXX_SUPPORT_GOLD AND NOT ANDROID AND NOT APPLE) | |||
| if(CXX_SUPPORT_GOLD AND NOT ANDROID AND NOT APPLE AND NOT MSVC AND NOT WIN32) | |||
| message("-- Using GNU gold linker.") | |||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") | |||
| @@ -188,18 +222,6 @@ if(MGB_WITH_FLATBUFFERS) | |||
| include(cmake/flatbuffers.cmake) | |||
| endif() | |||
| if(MSVC) | |||
| add_compile_definitions(NOMINMAX=1 _USE_MATH_DEFINES=1 WIN32=1) | |||
| else() | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | |||
| set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") | |||
| if(ANDROID) | |||
| set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -DNDEBUG") | |||
| else() | |||
| set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") | |||
| endif() | |||
| endif() | |||
| if(MGE_WITH_CUDA) | |||
| include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) | |||
| foreach(path ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}) | |||
| @@ -393,6 +415,12 @@ else() | |||
| set(MGB_ENABLE_DEBUG_UTIL 0) | |||
| endif() | |||
| # FIXME: remove this after imp DEBUG UTIL for windows | |||
| if(MSVC OR WIN32) | |||
| set(MGB_ENABLE_DEBUG_UTIL 0) | |||
| message(" -- disable MGB_ENABLE_DEBUG_UTIL in windows build") | |||
| endif() | |||
| # TensorRT | |||
| set(MGB_ENABLE_TENSOR_RT ${MGE_WITH_TRT}) | |||
| @@ -1,31 +1,25 @@ | |||
| include(ExternalProject) | |||
| include(GNUInstallDirs) | |||
| set(MKLDNN_DIR "${PROJECT_SOURCE_DIR}/third_party/intel-mkl-dnn" CACHE STRING "mkldnn directory") | |||
| set(MKLDNN_BUILD_DIR ${PROJECT_BINARY_DIR}/third_party/intel-mkl-dnn) | |||
| set(MKLDNN_LIB ${MKLDNN_BUILD_DIR}/${CMAKE_INSTALL_LIBDIR}/libdnnl.a) | |||
| option(DNNL_BUILD_TESTS "" OFF) | |||
| option(DNNL_BUILD_EXAMPLES "" OFF) | |||
| set(DNNL_LIBRARY_TYPE STATIC CACHE STRING "config dnnl to STATIC") | |||
| # we do not want to use OMP now, so config to CPU mode | |||
| # if set to OMP, some dnnl algo will be more fast | |||
| set(DNNL_CPU_RUNTIME DNNL_RUNTIME_SEQ CACHE STRING "config dnnl to DNNL_RUNTIME_SEQ") | |||
| if(MGE_BLAS STREQUAL "MKL") | |||
| list(APPEND MKLDNN_BUILD_ARGS -D_DNNL_USE_MKL=ON -DMKLROOT=${MKL_ROOT_DIR}) | |||
| option(_DNNL_USE_MKL "" ON) | |||
| set(MKLROOT ${MKL_ROOT_DIR} CACHE STRING "MKL ROOT FOR DNNL") | |||
| if (WIN32) | |||
| set(MKLLIB "mkl_core" CACHE STRING "MKLLIB NAME FOR DNNL") | |||
| else() | |||
| set(MKLLIB "libmkl_core.a" CACHE STRING "MKLLIB NAME FOR DNNL") | |||
| endif() | |||
| # workround for DNNL link failed, we do not want to modify | |||
| # dnnl MKL.cmake of intel-mkl-dnn when include intel-mkl-dnn | |||
| # via add_subdirectory api | |||
| link_directories(${MKL_ROOT_DIR}/lib) | |||
| else() | |||
| list(APPEND MKLDNN_BUILD_ARGS -D_DNNL_USE_MKL=OFF) | |||
| option(_DNNL_USE_MKL "" OFF) | |||
| endif() | |||
| ExternalProject_add( | |||
| mkl_dnn | |||
| SOURCE_DIR ${MKLDNN_DIR} | |||
| PREFIX ${MKLDNN_BUILD_DIR} | |||
| CMAKE_ARGS -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DDNNL_BUILD_TESTS=OFF -DDNNL_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${MKLDNN_BUILD_DIR} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DDNNL_LIBRARY_TYPE=STATIC -DDNNL_CPU_RUNTIME=DNNL_RUNTIME_SEQ ${MKLDNN_BUILD_ARGS} | |||
| BUILD_BYPRODUCTS ${MKLDNN_LIB} | |||
| ) | |||
| set(MKLDNN_INC ${MKLDNN_BUILD_DIR}/include) | |||
| file(MAKE_DIRECTORY ${MKLDNN_INC}) | |||
| add_library(libmkl_dnn STATIC IMPORTED GLOBAL) | |||
| add_dependencies(libmkl_dnn mkl_dnn) | |||
| set_target_properties( | |||
| libmkl_dnn PROPERTIES | |||
| IMPORTED_LOCATION ${MKLDNN_LIB} | |||
| INTERFACE_INCLUDE_DIRECTORIES ${MKLDNN_INC} | |||
| ) | |||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-extra") | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-extra") | |||
| add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/intel-mkl-dnn) | |||
| @@ -2,8 +2,24 @@ if (MGE_USE_SYSTEM_LIB) | |||
| find_package(FlatBuffers REQUIRED) | |||
| return() | |||
| endif() | |||
| if(MSVC OR WIN32) | |||
| message("-- add flags flatc for clang-cl build") | |||
| set(FLATC_FLAGS "") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=unknown-argument -Wno-error=c++98-compat -Wno-error=reserved-id-macro") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=sign-conversion -Wno-error=exceptions -Wno-error=argument-outside-range") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=delete-non-virtual-dtor -Wno-error=ignored-attributes -Wno-error=format") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=sign-compare -Wno-error=unused-private-field -Wno-error=braced-scalar-init") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=return-type-c-linkage -Wno-error=invalid-noreturn -Wno-error=c++98-compat-pedantic") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=extra-semi-stmt -Wno-error=missing-prototypes -Wno-error=documentation-unknown-command") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=missing-variable-declarations -Wno-error=nonportable-system-include-path") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=exit-time-destructors -Wno-error=unused-macros -Wno-error=global-constructors") | |||
| set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=switch-enum -Wno-error=missing-noreturn -Wno-error=float-equal") | |||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLATC_FLAGS}") | |||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATC_FLAGS}") | |||
| endif() | |||
| option(FLATBUFFERS_BUILD_TESTS "" OFF) | |||
| add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/flatbuffers | |||
| ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers | |||
| EXCLUDE_FROM_ALL) | |||
| EXCLUDE_FROM_ALL) | |||
| @@ -2,6 +2,8 @@ find_path(MKL_ROOT_DIR | |||
| include/mkl_cblas.h | |||
| PATHS | |||
| ${PROJECT_SOURCE_DIR}/third_party/mkl/${MGE_ARCH} | |||
| ${PROJECT_SOURCE_DIR}/third_party/mkl/${MGE_ARCH}/Library | |||
| ${PROJECT_SOURCE_DIR}/third_party/mkl/x86_32/Library | |||
| $ENV{MKLDIR} | |||
| /opt/intel/mkl/*/ | |||
| /opt/intel/cmkl/*/ | |||
| @@ -23,20 +25,20 @@ find_path(MKL_INCLUDE_DIR | |||
| option(MGE_MKL_USE_STATIC "Build MegEngine with static MKL" ON) | |||
| if(MGE_MKL_USE_STATIC) | |||
| find_library(MKL_CORE_LIBRARY | |||
| NAMES libmkl_core.a libmkl_core.lib | |||
| NAMES libmkl_core.a mkl_core.lib | |||
| PATHS ${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR} ${MKL_ROOT_DIR}/lib/) | |||
| find_library(MKL_SEQUENTIAL_LIBRARY | |||
| NAMES libmkl_sequential.a libmkl_sequential.lib | |||
| NAMES libmkl_sequential.a mkl_sequential.lib | |||
| PATHS ${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR} ${MKL_ROOT_DIR}/lib/) | |||
| if(${MGE_ARCH} STREQUAL "x86_64") | |||
| find_library(MKL_IPL_LIBRARY | |||
| NAMES libmkl_intel_ilp64.a libmkl_intel_ilp64.lib | |||
| NAMES libmkl_intel_ilp64.a mkl_intel_ilp64.lib | |||
| PATHS ${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR} ${MKL_ROOT_DIR}/lib/) | |||
| elseif(${MGE_ARCH} STREQUAL "x86_32") | |||
| elseif(${MGE_ARCH} STREQUAL "i386") | |||
| find_library(MKL_IPL_LIBRARY | |||
| NAMES libmkl_intel_32.a libmkl_intel_32.lib | |||
| NAMES libmkl_intel_32.a mkl_intel_32.lib mkl_intel_c.lib | |||
| PATHS ${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR} ${MKL_ROOT_DIR}/lib/) | |||
| endif() | |||
| @@ -11,7 +11,7 @@ add_custom_command( | |||
| COMMAND ${PYTHON_EXECUTABLE} ${OPR_PARAM_DEFS_SCRIPT} ${OPR_PARAM_DEFS_SRCS} | |||
| ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_defs.h | |||
| COMMAND ${PYTHON_EXECUTABLE} ${OPR_PARAM_DEFS_SCRIPT} ${OPR_PARAM_DEFS_SRCS} | |||
| /dev/null --write-cppjson ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_json.h | |||
| tmp_unuse.log --write-cppjson ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_json.h | |||
| DEPENDS ${OPR_PARAM_DEFS_SRCS} ${OPR_PARAM_DEFS_SCRIPT} | |||
| VERBATIM | |||
| ) | |||
| @@ -189,6 +189,8 @@ | |||
| #include <climits> | |||
| #include <cmath> | |||
| #include <cstring> | |||
| #include <ostream> | |||
| #include <istream> | |||
| #if HALF_ENABLE_CPP11_TYPE_TRAITS | |||
| #include <type_traits> | |||
| #endif | |||
| @@ -67,7 +67,7 @@ endif() | |||
| target_compile_definitions(megdnn INTERFACE ${LIBMEGDNN_DEF}) | |||
| if(MGE_WITH_MKLDNN AND ${MGE_ARCH} STREQUAL "x86_64") | |||
| target_link_libraries(megdnn libmkl_dnn) | |||
| target_link_libraries(megdnn dnnl) | |||
| endif() | |||
| target_link_libraries(megdnn ${MGE_CUDA_LIBS}) | |||
| target_link_libraries(megdnn ${MGE_BLAS_LIBS}) | |||
| @@ -18,14 +18,15 @@ | |||
| #include "megdnn/arch.h" | |||
| #ifdef _MSC_VER | |||
| #if defined(_MSC_VER) || defined(__MINGW32__) | |||
| #include "malloc.h" | |||
| #endif | |||
| #if defined(__ANDROID__) || defined(ANDROID) | |||
| #include "malloc.h" | |||
| #define HAS_MEMALIGN | |||
| #elif !defined(_MSC_VER) | |||
| #elif !defined(_MSC_VER) && !defined(__MINGW32__) | |||
| #define HAS_POSIX_MEMALIGN | |||
| #endif | |||
| @@ -77,7 +78,7 @@ public: | |||
| return result; | |||
| #elif defined(HAS_MEMALIGN) | |||
| return (_Tp*)memalign(_align, __n * sizeof(_Tp)); | |||
| #elif defined(_MSC_VER) | |||
| #elif defined(_MSC_VER) || defined(__MINGW32__) | |||
| return (_Tp*)_aligned_malloc(__n * sizeof(_Tp), _align); | |||
| #else | |||
| #warning \ | |||
| @@ -17,7 +17,7 @@ | |||
| #include "src/x86/utils.h" | |||
| #include <immintrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avxintrin.h> | |||
| #include <fmaintrin.h> | |||
| #endif | |||
| @@ -18,7 +18,7 @@ | |||
| #include "src/x86/avx_helper.h" | |||
| #include <x86intrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avxintrin.h> | |||
| #include <smmintrin.h> | |||
| #include <avx2intrin.h> | |||
| @@ -19,7 +19,7 @@ | |||
| #include "src/x86/avx_helper.h" | |||
| #include <x86intrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avx2intrin.h> | |||
| #include <avxintrin.h> | |||
| #include <fmaintrin.h> | |||
| @@ -15,7 +15,7 @@ | |||
| #include "src/common/unroll_macro.h" | |||
| #include "src/x86/conv_bias/int8/common_helper.h" | |||
| #include "src/x86/elemwise_op.h" | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <smmintrin.h> | |||
| #endif | |||
| @@ -13,7 +13,7 @@ | |||
| #include <immintrin.h> | |||
| #include "src/common/unroll_macro.h" | |||
| #include "megdnn/arch.h" | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <smmintrin.h> | |||
| #endif | |||
| @@ -12,7 +12,7 @@ | |||
| #include "megdnn/arch.h" | |||
| #include "megdnn/basic_types.h" | |||
| #include <immintrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avxintrin.h> | |||
| #include <smmintrin.h> | |||
| #include <avx2intrin.h> | |||
| @@ -9,7 +9,7 @@ | |||
| * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| */ | |||
| #include <immintrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avxintrin.h> | |||
| #include <fmaintrin.h> | |||
| #endif | |||
| @@ -11,7 +11,7 @@ | |||
| #pragma once | |||
| #include <immintrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avx2intrin.h> | |||
| #include <avxintrin.h> | |||
| #include <fmaintrin.h> | |||
| @@ -11,7 +11,7 @@ | |||
| #pragma once | |||
| #include <x86intrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avxintrin.h> | |||
| #include <smmintrin.h> | |||
| #include <avx2intrin.h> | |||
| @@ -11,7 +11,7 @@ | |||
| #pragma once | |||
| #include <immintrin.h> | |||
| #ifdef WIN32CMAKE | |||
| #ifdef WIN32 | |||
| #include <avx2intrin.h> | |||
| #include <avxintrin.h> | |||
| #include <fmaintrin.h> | |||
| @@ -0,0 +1,106 @@ | |||
| # build support status | |||
| ## host build | |||
| * windows build (ok) | |||
| * linux build (ok) | |||
| * macos build (ok) | |||
| ## cross build | |||
| * windows cross build arm-android (ok) | |||
| * windows cross build arm-linux (ok) | |||
| * linux cross build arm-android (ok) | |||
| * linux cross build arm-linux (ok) | |||
| * macos cross build arm-android (ok) | |||
| * macos cross build arm-linux (ok but experimental) | |||
| * macos cross build ios (ok) | |||
| # build env prepare | |||
| ## package install | |||
| ### windows host build | |||
| ``` | |||
| 1: installl Visual Studio (need support LLVM/clang-cl), eg 2019 | |||
| clang-cl 9 linker have crash issue, pls install 7/8/10 | |||
| 2: install extension of VS: python/cmake/LLVM | |||
| 3: CUDA env(if enable CUDA), version detail: project_root_dir/README.md | |||
| ``` | |||
| ### linux host build | |||
| ``` | |||
| 1: cmake, which version > 3.14.4 | |||
| 2: gcc/g++, which version > 6 | |||
| 3: install build-essential git git-lfs gfortran libgfortran-6-dev autoconf gnupg flex bison gperf curl | |||
| 4: zlib1g-dev gcc-multilib g++-multilib lib32ncurses5-dev libxml2-utils xsltproc unzip libtool: | |||
| 5: librdmacm-dev rdmacm-utils python3-dev swig python3-numpy texinfo | |||
| 6: CUDA env(if enable CUDA), version detail: project_root_dir/README.md | |||
| ``` | |||
| ### macos host build | |||
| ``` | |||
| 1: cmake, which version > 3.14.4 | |||
| 2: install brew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | |||
| 3: brew install python python3 swig coreutils | |||
| 4: install at least xcode command line tool: https://developer.apple.com/xcode/ | |||
| 5: about cuda: we do not support CUDA on macos | |||
| ``` | |||
| ### cross build for arm-android | |||
| now we support windows/linux/macos cross build to arm-android | |||
| ``` | |||
| 1: install unix-like tools, eg MSYS if you are using windows(recommend) | |||
| we also support CMD.exe or powershell on windows | |||
| 1: download NDK from https://developer.android.google.cn/ndk/downloads/ | |||
| for diff OS platform package, suggested NDK20 or NDK21 | |||
| 2: export NDK_ROOT=NDK_DIR at bash-like env | |||
| 3: config NDK_ROOT to PATH env at windows control board if use CMD/powershell | |||
| ``` | |||
| ### cross build for arm-linux | |||
| now we support arm-linux on linux and windows fully, also experimental on MACOS | |||
| ``` | |||
| 1: download toolchains on https://releases.linaro.org/components/toolchain/gcc-linaro/ | |||
| or https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads | |||
| if use windows or linux | |||
| 2: download https://github.com/thinkski/osx-arm-linux-toolchains if use MACOS | |||
| ``` | |||
| ### cross build for ios | |||
| now we only support cross build to ios on MACOS | |||
| ``` | |||
| 1: install full xcode: https://developer.apple.com/xcode/ | |||
| ``` | |||
| ## third-party code prepare | |||
| ### with bash env(linux/macos/unix-like tools on windows, eg: msys etc) | |||
| ``` | |||
| ./third_party/prepare.sh | |||
| ./third_party/install-mkl.sh | |||
| ``` | |||
| ### windows shell env(eg: cmd, powershell etc) | |||
| infact if you can use git command on windows, which means you always install | |||
| bash.exe at the same dir of git.exe, find it, then you can prepare third-party | |||
| code by command: | |||
| ``` | |||
| bash.exe ./third_party/prepare.sh | |||
| bash.exe ./third_party/install-mkl.sh | |||
| ``` | |||
| # how to build | |||
| ## with bash env(linux/macos/unix-like tools on windows, eg: msys etc) | |||
| ``` | |||
| 1: host build just use scripts:scripts/cmake-build/host_build.sh | |||
| 2: cross build to arm-android: scripts/cmake-build/cross_build_android_arm_inference.sh | |||
| 3: cross build to arm-linux: scripts/cmake-build/cross_build_linux_arm_inference.sh | |||
| 4: cross build to ios: scripts/cmake-build/cross_build_ios_arm_inference.sh | |||
| ``` | |||
| ## windows shell env(eg: cmd, powershell etc) | |||
| ``` | |||
| 1: we do not provide BAT for cmd/powershlel scripts, BUT u can refs for scripts/cmake-build/*.sh | |||
| ``` | |||
| ## Visual Studio GUI(only for windows host) | |||
| ``` | |||
| 1: import megengine src to Visual Studio as a project | |||
| 2: right click CMakeLists.txt, choose config 'cmake config' | |||
| choose clang_cl_x86 or clang_cl_x64 | |||
| 3: config other CMAKE config, eg, CUDA ON OR OFF | |||
| ``` | |||
| # other arm-linux-like board support | |||
| it`s easy to support other customized arm-linux-like board, example: | |||
| 1: HISI 3516/3519, infact u can just use toolchains from arm developer or linaro | |||
| then call scripts/cmake-build/cross_build_linux_arm_inference.sh to build a ELF | |||
| binary, or if you get HISI official toolschain, you just need modify CMAKE_CXX_COMPILER | |||
| and CMAKE_C_COMPILER in toolchains/arm-linux-gnueabi* to a real name | |||
| 2: about Raspberry, just use scripts/cmake-build/cross_build_linux_arm_inference.sh | |||
| @@ -76,13 +76,18 @@ echo "ARCH: $ARCH" | |||
| echo "----------------------------------------------------" | |||
| READLINK=readlink | |||
| MAKEFILE_TYPE="Unix" | |||
| OS=$(uname -s) | |||
| if [ $OS = "Darwin" ];then | |||
| READLINK=greadlink | |||
| elif [[ $OS =~ "NT" ]]; then | |||
| echo "BUILD in NT ..." | |||
| MAKEFILE_TYPE="Unix" | |||
| fi | |||
| SRC_DIR=$($READLINK -f "`dirname $0`/../../") | |||
| source $SRC_DIR/scripts/cmake-build/utils/host_build_flatc.sh | |||
| if [ -z $NDK_ROOT ];then | |||
| echo "can not find NDK_ROOT env, pls export you NDK root dir to NDK_ROOT" | |||
| @@ -99,6 +104,7 @@ function cmake_build() { | |||
| echo "build type: $BUILD_TYPE" | |||
| echo "build ABI: $BUILD_ABI" | |||
| echo "build native level: $BUILD_NATIVE_LEVEL" | |||
| echo "BUILD MAKEFILE_TYPE: $MAKEFILE_TYPE" | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| @@ -112,7 +118,8 @@ function cmake_build() { | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| cmake -DCMAKE_TOOLCHAIN_FILE="$NDK_ROOT/build/cmake/android.toolchain.cmake" \ | |||
| cmake -G "$MAKEFILE_TYPE Makefiles" \ | |||
| -DCMAKE_TOOLCHAIN_FILE="$NDK_ROOT/build/cmake/android.toolchain.cmake" \ | |||
| -DANDROID_NDK="$NDK_ROOT" \ | |||
| -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |||
| -DANDROID_ABI=$BUILD_ABI \ | |||
| @@ -129,34 +136,7 @@ function cmake_build() { | |||
| make install/strip | |||
| } | |||
| function build_flatc() { | |||
| BUILD_DIR=$SRC_DIR/build_dir/host_flatc/build | |||
| INSTALL_DIR=$BUILD_DIR/../install | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| fi | |||
| if [ -e $INSTALL_DIR ];then | |||
| echo "clean old dir: $INSTALL_DIR" | |||
| rm -rf $INSTALL_DIR | |||
| fi | |||
| echo "create build dir" | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| cmake -DCMAKE_BUILD_TYPE=Release \ | |||
| -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ | |||
| -DFLATBUFFERS_BUILD_TESTS=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATHASH=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATLIB=OFF \ | |||
| -DFLATBUFFERS_LIBCXX_WITH_CLANG=OFF \ | |||
| $SRC_DIR/third_party/flatbuffers | |||
| make -j$(nproc) | |||
| make install/strip | |||
| } | |||
| build_flatc | |||
| build_flatc $SRC_DIR | |||
| api_level=16 | |||
| abi="armeabi-v7a with NEON" | |||
| @@ -86,6 +86,7 @@ else | |||
| fi | |||
| SRC_DIR=$($READLINK -f "`dirname $0`/../../") | |||
| source $SRC_DIR/scripts/cmake-build/utils/host_build_flatc.sh | |||
| function cmake_build() { | |||
| BUILD_DIR=$SRC_DIR/build_dir/apple/$3/$4/$1/$BUILD_TYPE/build | |||
| @@ -133,34 +134,7 @@ function cmake_build() { | |||
| make install | |||
| } | |||
| function build_flatc() { | |||
| BUILD_DIR=$SRC_DIR/build_dir/host_flatc/build | |||
| INSTALL_DIR=$BUILD_DIR/../install | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| fi | |||
| if [ -e $INSTALL_DIR ];then | |||
| echo "clean old dir: $INSTALL_DIR" | |||
| rm -rf $INSTALL_DIR | |||
| fi | |||
| echo "create build dir" | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| cmake -DCMAKE_BUILD_TYPE=Release \ | |||
| -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ | |||
| -DFLATBUFFERS_BUILD_TESTS=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATHASH=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATLIB=OFF \ | |||
| -DFLATBUFFERS_LIBCXX_WITH_CLANG=OFF \ | |||
| $SRC_DIR/third_party/flatbuffers | |||
| make -j$(nproc) | |||
| make install/strip | |||
| } | |||
| build_flatc | |||
| build_flatc $SRC_DIR | |||
| # refs for ../../toolchains/ios.toolchain.cmake | |||
| # to config this, if u want to build other, | |||
| @@ -76,13 +76,19 @@ echo "ARCH: $ARCH" | |||
| echo "----------------------------------------------------" | |||
| READLINK=readlink | |||
| MAKEFILE_TYPE="Unix" | |||
| OS=$(uname -s) | |||
| if [ $OS = "Darwin" ];then | |||
| READLINK=greadlink | |||
| elif [[ $OS =~ "NT" ]]; then | |||
| echo "BUILD in NT ..." | |||
| MAKEFILE_TYPE="Unix" | |||
| fi | |||
| SRC_DIR=$($READLINK -f "`dirname $0`/../../") | |||
| source $SRC_DIR/scripts/cmake-build/utils/host_build_flatc.sh | |||
| function cmake_build() { | |||
| BUILD_DIR=$SRC_DIR/build_dir/gnu-linux/$1/$BUILD_TYPE/build | |||
| INSTALL_DIR=$BUILD_DIR/../install | |||
| @@ -91,6 +97,7 @@ function cmake_build() { | |||
| echo "install dir: $INSTALL_DIR" | |||
| echo "build type: $BUILD_TYPE" | |||
| echo "build toolchain: $TOOLCHAIN" | |||
| echo "BUILD MAKEFILE_TYPE: $MAKEFILE_TYPE" | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| @@ -104,7 +111,8 @@ function cmake_build() { | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| cmake -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN \ | |||
| cmake -G "$MAKEFILE_TYPE Makefiles" \ | |||
| -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN \ | |||
| -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |||
| -DMGE_INFERENCE_ONLY=ON \ | |||
| -DMGE_WITH_CUDA=OFF \ | |||
| @@ -118,34 +126,7 @@ function cmake_build() { | |||
| make install/strip | |||
| } | |||
| function build_flatc() { | |||
| BUILD_DIR=$SRC_DIR/build_dir/host_flatc/build | |||
| INSTALL_DIR=$BUILD_DIR/../install | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| fi | |||
| if [ -e $INSTALL_DIR ];then | |||
| echo "clean old dir: $INSTALL_DIR" | |||
| rm -rf $INSTALL_DIR | |||
| fi | |||
| echo "create build dir" | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| cmake -DCMAKE_BUILD_TYPE=Release \ | |||
| -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ | |||
| -DFLATBUFFERS_BUILD_TESTS=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATHASH=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATLIB=OFF \ | |||
| -DFLATBUFFERS_LIBCXX_WITH_CLANG=OFF \ | |||
| $SRC_DIR/third_party/flatbuffers | |||
| make -j$(nproc) | |||
| make install/strip | |||
| } | |||
| build_flatc | |||
| build_flatc $SRC_DIR | |||
| toolchain=null | |||
| if [ "$ARCH" = "arm64-v8a" ]; then | |||
| @@ -7,6 +7,8 @@ function usage() { | |||
| echo "-d : Build with Debug mode, defaule Release mode" | |||
| echo "-c : Build with CUDA, default without CUDA" | |||
| echo "-t : Build with training mode, default inference only" | |||
| echo "-m : Build with m32 mode(only for windows build), default m64" | |||
| echo "-h : show usage" | |||
| echo "example: $0 -d" | |||
| exit -1 | |||
| } | |||
| @@ -14,8 +16,11 @@ function usage() { | |||
| BUILD_TYPE=Release | |||
| MGE_WITH_CUDA=OFF | |||
| MGE_INFERENCE_ONLY=ON | |||
| MGE_WINDOWS_BUILD_ARCH=x64 | |||
| MGE_WINDOWS_BUILD_MARCH=m64 | |||
| MGE_ARCH=x86_64 | |||
| while getopts "dct" arg | |||
| while getopts "hdctm" arg | |||
| do | |||
| case $arg in | |||
| d) | |||
| @@ -30,6 +35,16 @@ do | |||
| echo "Build with training mode" | |||
| MGE_INFERENCE_ONLY=OFF | |||
| ;; | |||
| h) | |||
| echo "show usage" | |||
| usage | |||
| ;; | |||
| m) | |||
| echo "build for m32(only use for windows)" | |||
| MGE_WINDOWS_BUILD_ARCH=x86 | |||
| MGE_WINDOWS_BUILD_MARCH=m32 | |||
| MGE_ARCH=i386 | |||
| ;; | |||
| ?) | |||
| echo "unkonw argument" | |||
| usage | |||
| @@ -51,6 +66,8 @@ if [ $OS = "Darwin" ];then | |||
| echo "MACOS DO NOT SUPPORT TensorRT, ABORT NOW!!" | |||
| exit -1 | |||
| fi | |||
| elif [[ $OS =~ "NT" ]]; then | |||
| echo "BUILD in NT ..." | |||
| fi | |||
| SRC_DIR=$($READLINK -f "`dirname $0`/../../") | |||
| @@ -88,7 +105,111 @@ function cmake_build() { | |||
| make -j$(nproc) | |||
| make install/strip | |||
| } | |||
| } | |||
| function windows_env_err() { | |||
| echo "check windows env failed!!" | |||
| echo "please install LLVM/clang-cl/cmake/python at Visual Studio Extensions" | |||
| exit -1 | |||
| } | |||
| function prepare_env_for_windows_build() { | |||
| echo "check Visual Studio install path env..." | |||
| if [[ -z $VS_PATH ]];then | |||
| echo "can not find visual_studio_path env, pls export you Visual Studio install dir to VS_PATH" | |||
| echo "examle for export Visual Studio 2019 Enterprise default install dir" | |||
| echo "export VS_PATH=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2019/Enterprise" | |||
| exit -1 | |||
| fi | |||
| echo $VS_PATH | |||
| cmake_build $MGE_WITH_CUDA $MGE_INFERENCE_ONLY $BUILD_TYPE | |||
| # only use cmake/clang-cl/Ninja install from Visual Studio, if not, may build failed | |||
| # some user env may install cmake/clang-cl/Ninja at MSYS env, so we put Visual Studio | |||
| # path at the head of PATH, and check the valid | |||
| echo "check cmake install..." | |||
| export PATH=$VS_PATH/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/:$PATH | |||
| which cmake | |||
| cmake_loc=`which cmake` | |||
| if [[ $cmake_loc =~ "Visual" ]]; then | |||
| echo "cmake valid ..." | |||
| else | |||
| echo "cmake Invalid: ..." | |||
| windows_env_err | |||
| fi | |||
| echo "check clang-cl install..." | |||
| export PATH=$VS_PATH/VC/Tools/Llvm/bin/:$PATH | |||
| which clang-cl | |||
| clang_loc=`which clang-cl` | |||
| if [[ $clang_loc =~ "Visual" ]]; then | |||
| echo "clang-cl valid ..." | |||
| else | |||
| echo "clang-cl Invalid: ..." | |||
| windows_env_err | |||
| fi | |||
| echo "check Ninja install..." | |||
| export PATH=$VS_PATH/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/:$PATH | |||
| which Ninja | |||
| ninja_loc=`which Ninja` | |||
| if [[ $ninja_loc =~ "Visual" ]]; then | |||
| echo "Ninja valid ..." | |||
| else | |||
| echo "Ninja Invalid: ..." | |||
| windows_env_er | |||
| fi | |||
| export PATH=$VS_PATH/VC/Auxiliary/Build:$PATH | |||
| echo "put vcvarsall.bat path to PATH env.." | |||
| } | |||
| function cmake_build_windows() { | |||
| # windows do not support long path, so we cache the BUILD_DIR ASAP | |||
| prepare_env_for_windows_build | |||
| BUILD_DIR=$SRC_DIR/build_dir/host/build | |||
| INSTALL_DIR=$BUILD_DIR/../install | |||
| MGE_WITH_CUDA=$1 | |||
| MGE_INFERENCE_ONLY=$2 | |||
| BUILD_TYPE=$3 | |||
| echo "build dir: $BUILD_DIR" | |||
| echo "install dir: $INSTALL_DIR" | |||
| echo "build type: $BUILD_TYPE" | |||
| echo "MGE_WITH_CUDA: $MGE_WITH_CUDA" | |||
| echo "MGE_INFERENCE_ONLY: $MGE_INFERENCE_ONLY" | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| fi | |||
| if [ -e $INSTALL_DIR ];then | |||
| echo "clean old dir: $INSTALL_DIR" | |||
| rm -rf $INSTALL_DIR | |||
| fi | |||
| echo "create build dir" | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| echo "now try build windows native with cmake/clang-ci/Ninja/Visual Studio ....." | |||
| export CFLAGS=-$MGE_WINDOWS_BUILD_MARCH | |||
| export CXXFLAGS=-$MGE_WINDOWS_BUILD_MARCH | |||
| cmd.exe /c " \ | |||
| vcvarsall.bat $MGE_WINDOWS_BUILD_ARCH && cmake -G "Ninja" \ | |||
| -DMGE_ARCH=$MGE_ARCH \ | |||
| -DMGE_INFERENCE_ONLY=$MGE_INFERENCE_ONLY \ | |||
| -DMGE_WITH_CUDA=$MGE_WITH_CUDA \ | |||
| -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ | |||
| -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_DIR \ | |||
| -DCMAKE_C_COMPILER=clang-cl.exe \ | |||
| -DCMAKE_CXX_COMPILER=clang-cl.exe \ | |||
| -DCMAKE_MAKE_PROGRAM=ninja.exe \ | |||
| ../../.. && \ | |||
| echo \"start Ninja build log to build.log, may take serval min...\" && \ | |||
| Ninja load_and_run > build.log" | |||
| } | |||
| if [[ $OS =~ "NT" ]]; then | |||
| cmake_build_windows $MGE_WITH_CUDA $MGE_INFERENCE_ONLY $BUILD_TYPE | |||
| else | |||
| cmake_build $MGE_WITH_CUDA $MGE_INFERENCE_ONLY $BUILD_TYPE | |||
| fi | |||
| @@ -0,0 +1,39 @@ | |||
| #!/usr/bin/env bash | |||
| set -e | |||
| MAKEFILE_TYPE="Unix" | |||
| OS=$(uname -s) | |||
| if [[ $OS =~ "NT" ]]; then | |||
| echo "BUILD in NT ..." | |||
| MAKEFILE_TYPE="Unix" | |||
| fi | |||
| function build_flatc() { | |||
| BUILD_DIR=$1/build_dir/host_flatc/build | |||
| INSTALL_DIR=$BUILD_DIR/../install | |||
| if [ -e $BUILD_DIR ];then | |||
| echo "clean old dir: $BUILD_DIR" | |||
| rm -rf $BUILD_DIR | |||
| fi | |||
| if [ -e $INSTALL_DIR ];then | |||
| echo "clean old dir: $INSTALL_DIR" | |||
| rm -rf $INSTALL_DIR | |||
| fi | |||
| echo "create build dir" | |||
| mkdir -p $BUILD_DIR | |||
| mkdir -p $INSTALL_DIR | |||
| cd $BUILD_DIR | |||
| cmake -G "$MAKEFILE_TYPE Makefiles" \ | |||
| -DCMAKE_BUILD_TYPE=Release \ | |||
| -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ | |||
| -DFLATBUFFERS_BUILD_TESTS=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATHASH=OFF \ | |||
| -DFLATBUFFERS_BUILD_FLATLIB=OFF \ | |||
| -DFLATBUFFERS_LIBCXX_WITH_CLANG=OFF \ | |||
| $SRC_DIR/third_party/flatbuffers | |||
| make -j$(nproc) | |||
| make install/strip | |||
| } | |||
| @@ -106,7 +106,7 @@ if (MGB_WITH_FLATBUFFERS) | |||
| target_compile_definitions(megbrain PUBLIC MGB_ENABLE_FBS_SERIALIZATION=1) | |||
| target_link_libraries(megbrain flatbuffers) | |||
| set (GENERATED_FLATBUFFERS_CONVERTER_PATH ${CMAKE_CURRENT_BINARY_DIR}/genfiles/this/should/be/added/to/sereg_caller/target/only/but/hey/yolo/there/are/no/fine/grained/targets/let/us/just/make/this/path/unreasonably/long/to/avoid/collision) | |||
| set (GENERATED_FLATBUFFERS_CONVERTER_PATH ${CMAKE_CURRENT_BINARY_DIR}/genfiles) | |||
| set (GEN_FLATBUFFERS_CONVERTER_PY ${PROJECT_SOURCE_DIR}/dnn/scripts/gen_flatbuffers_converter.py) | |||
| file (MAKE_DIRECTORY ${GENERATED_FLATBUFFERS_CONVERTER_PATH}) | |||
| add_custom_command( | |||
| @@ -17,7 +17,7 @@ | |||
| #include <iostream> | |||
| #ifdef _WIN32 | |||
| #if defined(WIN32) | |||
| static inline void unsetenv(std::string name) { | |||
| name += "="; | |||
| _putenv(name.c_str()); | |||
| @@ -2,19 +2,50 @@ | |||
| cd $(dirname $0) | |||
| #FIXME: anaconda just upload serval lastest version, so this version may lose efficacy | |||
| echo "this script only for linux/macos/windows-unix-like-env(MSYS etc) prepare MKL env" | |||
| echo "if you build windows for native at cmd.exe, powershell env or Visual Studio GUI," | |||
| echo "u need download MKL package and untar manually" | |||
| echo "refs: https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library/choose-download/windows.html" | |||
| MKL_VERSION=2019.5 | |||
| MKL_PATCH=281 | |||
| CONDA_BASE_URL=https://anaconda.org/intel | |||
| OS=$(uname -s) | |||
| FILE_PREFIX=null | |||
| TAR=tar | |||
| if [ $OS = "Darwin" ];then | |||
| FILE_PREFIX=osx | |||
| elif [ $OS = "Linux" ];then | |||
| FILE_PREFIX=linux | |||
| elif [[ $OS =~ "NT" ]]; then | |||
| FILE_PREFIX=win | |||
| # NT use /c/Windows/system32/tar will stuck for big file | |||
| # so we back to GNU tar | |||
| TAR=/usr/bin/tar | |||
| else | |||
| echo "DO NOT SUPPORT OS NOW" | |||
| exit -1 | |||
| fi | |||
| echo "config FILE_PREFIX to: $FILE_PREFIX" | |||
| rm -rf mkl | |||
| for platform in 32 64 | |||
| do | |||
| if [ $OS = "Darwin" ]&&[ $platform = 32 ];then | |||
| echo "strip 32 bit file for Darwin" | |||
| continue | |||
| fi | |||
| mkdir -p mkl/x86_${platform} | |||
| for package in "mkl-include" "mkl-static" | |||
| do | |||
| echo "Installing ${package} for x86_${platform}..." | |||
| URL=${CONDA_BASE_URL}/${package}/${MKL_VERSION}/download/linux-${platform}/${package}-${MKL_VERSION}-intel_${MKL_PATCH}.tar.bz2 | |||
| wget -q --show-progress "${URL}" -O - | tar xj -C mkl/x86_${platform} | |||
| DOWNLOAD_FILE=${package}-${MKL_VERSION}-intel_${MKL_PATCH}.tar.bz2 | |||
| echo "Installing ${DOWNLOAD_FILE} for x86_${platform}..." | |||
| URL=${CONDA_BASE_URL}/${package}/${MKL_VERSION}/download/$FILE_PREFIX-${platform}/${DOWNLOAD_FILE} | |||
| echo "try download mkl package from: ${URL}" | |||
| wget -q --show-progress "${URL}" -O mkl/x86_${platform}/${DOWNLOAD_FILE} | |||
| $TAR xvj -C mkl/x86_${platform} -f mkl/x86_${platform}/${DOWNLOAD_FILE} | |||
| done | |||
| done | |||